I am tying to get xslt2 transformation using XQSharp, but i get an exception when trying to call ApplyTemplates.
My code:
<WebMethod()>
Public Function test(ByVal inputXml As String, ByVal inputXsl As String) As String
Dim nameTable As XmlNameTable = New NameTable()
Dim xmlReaderSettings As New XmlReaderSettings()
xmlReaderSettings.NameTable = nameTable
Dim document As XdmDocument
Using reader As New StringReader(inputXml)
document = New XdmDocument(reader)
End Using
Dim querySettings As New XsltSettings(nameTable)
querySettings.ContextItemType = XdmType.Node
querySettings.ModuleResolver = New XmlUrlResolver()
Dim query As Xslt = Xslt.Compile(New StringReader(inputXsl),
querySettings)
Dim contextItem As XPathNavigator = document.CreateNavigator()
Dim result As Stream = New MemoryStream()
query.ApplyTemplates(contextItem, result)
Using reader As StreamReader = New StreamReader(result)
Return reader.ReadToEnd()
End Using
End Function
XmlInput:
<?xml version="1.0"?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>hoi</title>
</head>
<body>
<p>Test</p>
</body>
</html>
XslInput:
<?xml version="1.0"?>
<xsl:stylesheet version="2.0" xmlns="http://www.w3.org/1999/xhtml" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/02/xpath-functions" xmlns:xdt="http://www.w3.org/2005/02/xpath-datatypes" exclude-result-prefixes="xhtml xsl fn xs xdt">
<xsl:output method="xml" version="1.0" encoding="UTF-8" omit-xml-declaration="yes" indent="yes" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"/>
</xsl:stylesheet>
Exception
System.ArgumentNullException was unhandled by user code
Message=Value cannot be null.
Parameter name: format
ParamName=format
Source=mscorlib
StackTrace:
at System.String.Format(IFormatProvider provider, String format, Object[] args)
at XQSharp.XdmException.WrongParamNameTable(LineInfo lineInfo, XmlQualifiedName parameterName)
at XQSharp.DocumentSet.ImportParamNode(LineInfo lineInfo, XPathNavigator navigator, XmlQualifiedName parameterName)
at XQSharp.DynamicContext.ConvertArgument(IEnumerable`1 value, LineInfo lineInfo, DocumentSet documentSet, StaticModuleContext context, XmlQualifiedName name, BoundType declaredType)
at XQSharp.DynamicContext..ctor(StaticModuleContext staticContext, DynamicContextSettings settings, XmlQualifiedName initialMode, XmlQualifiedName initialTemplate, Int32 stackSpace, Int32 globalSpace, IResultDocumentHandler resultDocumentHandler)
at XQSharp.Xslt.Evaluate(XmlQualifiedName initialMode, XmlQualifiedName initialTemplate, DynamicContextSettings settings, IResultDocumentHandler resultDocumentHandler)
at XQSharp.Xslt.ApplyTemplates(IXPathNavigable contextNode, Stream resultDocument)
at Cmsservices.XSLTEngine.test(String inputXml, String inputXsl) in
D:\Projecten\cmsservices\App_Code\CmsservicesXSLTEngine.vb:line 44
InnerException:
What i am doing wrong?