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 7533705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:48:07+00:00 2026-05-30T05:48:07+00:00

I am trying to transform a WSDL definition into another format for further processing,

  • 0

I am trying to transform a WSDL definition into another format for further processing, but I ran into a problem. I can’t seem to return QName-values from a function, without them being turned into a string.

I reduced the file to the following, while retaining the error behavior. The original function was supposed to translate non-prefixed values using the target-namespace attribute from the containing <xs:schema> or <wsdl:definitions>.

Example XSLT document:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:my="http://www.example.com/xslt"
    exclude-result-prefixes="#all" version="2.0">

    <xsl:output method="xml" indent="yes"/>

    <xsl:function name="my:resolve-QName2" as="xs:QName">
        <xsl:param name="name" as="xs:string"/>
        <xsl:param name="element" as="element()"/>
        <xsl:value-of select="resolve-QName($name,$element)"/>
    </xsl:function>

    <xsl:template match="/definitions">
        <xsl:variable name="qname" select="my:resolve-QName2('xs:string',.)" as="xs:QName"/>
        <QName>
            <prefix><xsl:value-of select="prefix-from-QName($qname)"/></prefix>
            <local><xsl:value-of select="local-name-from-QName($qname)"/></local>
            <namespace><xsl:value-of select="namespace-uri-from-QName($qname)"/></namespace>
        </QName>
    </xsl:template>
</xsl:stylesheet>

Input file:

<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns:xs="http://www.w3.org/2001/XMLSchema"/>

Expected result:

<?xml version="1.0" encoding="UTF-8"?>
<QName>
    <prefix>xs</prefix>
    <local>string</local>
    <namespace>http://www.w3.org/2001/XMLSchema</namespace>
</QName>

When running the above code, the Saxon 9.3.0.5 XSLT processor is stopping with an error:

Required item type of result of function my:resolve-QName2() is xs:QName. Cannot convert string to type {xs:QName}

It seems the engine is first casting the QName into a string, and then trying to cast it back to QName, which fails. If I remove the two as="xs:QName", I get the following error:

Required item type of first argument of prefix-from-QName() is xs:QName. Cannot convert string to type {xs:QName}

How can I return a QName from a function?

Is this a bug in Saxon XSLT processor, or something I have misunderstood about XSLT?

Is there any XSLT engine that is able to process the above file?

  • 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-30T05:48:09+00:00Added an answer on May 30, 2026 at 5:48 am

    The problem is here:

    <xsl:value-of select="resolve-QName($name,$element)"/>
    

    This produces a text node (string) from the QName that resolve-QName() returns.

    However the my:resolve-QName2 is declared as of type xs:QName — not of xs:string and this causes the correctly reported error.

    Solution:

    Replace the above with:

    <xsl:sequence select="resolve-QName($name,$element)"/>
    

    Now when the corrected transformation:

    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
            xmlns:xs="http://www.w3.org/2001/XMLSchema"
            xmlns:my="http://www.example.com/xslt"
            exclude-result-prefixes="#all" version="2.0">
    
            <xsl:output method="xml" indent="yes"/>
    
            <xsl:function name="my:resolve-QName2" as="xs:QName">
                <xsl:param name="name" as="xs:string"/>
                <xsl:param name="element" as="element()"/>
                <xsl:sequence select="resolve-QName($name,$element)"/>
            </xsl:function>
    
            <xsl:template match="/definitions">
                <xsl:variable name="qname" select="my:resolve-QName2('xs:string',.)" as="xs:QName"/>
                <QName>
                    <prefix><xsl:value-of select="prefix-from-QName($qname)"/></prefix>
                    <local><xsl:value-of select="local-name-from-QName($qname)"/></local>
                    <namespace><xsl:value-of select="namespace-uri-from-QName($qname)"/></namespace>
                </QName>
            </xsl:template>
    </xsl:stylesheet>
    

    is applied on the provided XML document:

    <definitions xmlns:xs="http://www.w3.org/2001/XMLSchema"/>
    

    the wanted, correct result is produced:

    <QName>
       <prefix>xs</prefix>
       <local>string</local>
       <namespace>http://www.w3.org/2001/XMLSchema</namespace>
    </QName>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to transform some XML into HTML using XSLT . Problem: I can't
I'm trying to transform one XML format to another using XSL. Try as I
I'm trying to transform this: http://link_brochure/1/2 OR link_brochure/1/2 into this: class=show-brochure href=http://localhost/main/brochure/1/2 But I'm
I'm trying to transform one method call into another dynamically (at runtime). For instance,
I'm trying to transform an XML document into another XML document. I've tried various
I’ve been trying to transform some simple XML into another simple XML using XSLT.
I am trying to transform XHTML using an XSLT stylesheet, but I can't even
I'm trying to transform each element of a numpy array into an array itself
I have: NSString *promise = @thereAreOtherWorldsThanThese; which I'm trying to transform into the string:
I'm trying to have a script automatically transform an xml file into several html

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.