Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6125037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:12:06+00:00 2026-05-23T16:12:06+00:00

I am tying to get xslt2 transformation using XQSharp, but i get an exception

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T16:12:06+00:00Added an answer on May 23, 2026 at 4:12 pm

    The ArgumentNullException was raised because we had incorrectly referenced the error message in a resource file. This has been fixed for the next version (2.2).

    The problem is that the document is compiled with a different name table to the query.

    The problem lies in the following lines of your source code:

    Using reader As New StringReader(inputXml)
        document = New XdmDocument(reader)
    End Using
    

    You are not specifying the name table to use to construct the XdmDocument, and so a new name table is created for the document.

    I was going to suggest that you should simply pass the name table to the constructors for XdmDocument, but have just noticed that we neglected to add constructors taking a name table. Again this should be improved in the next version.

    To fix your query, construct your XdmDocument from an XmlReader instead:

    Using reader As New StringReader(inputXml)
        Using xmlReader As XmlReader = XmlReader.Create(reader, xmlReaderSettings)
            document = New XdmDocument(xmlReader)
        End Using
    End Using
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying get values from a GridView using the following code: foreach (GridViewRow row
Trying to get parameters from a PUT request using HttpServlet#doPut: public void doPut(HttpServletRequest request,
I am trying to get the data from input xml message using functoids. But
Trying to get an ASP application deployed; it worked for a while but then
Trying to get comfortable with jQuery and I have encountered some sample code that
Trying to get this to work, with no luck: [DataMember] public Type ParameterType {
I'm trying to apply an xlst transformation using the following file. This is very
I'm trying to get a node-set from a xsl variable for calculating. But my
I'm trying to get an example that I found for using XSLT 2.0 to
I'm trying to add a tag like <div itemscope> in my xslt transformation but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.