I am trying to convert a WSDL definition to a different format for further processing, but I am having a problem. It seems I cannot return the QName values โโfrom a function without turning them into a string.
I reduced the file to the next, while maintaining the error behavior. The original function was to translate the values โโwithout a prefix, using the target-namespace attribute from the containing <xs:schema> or <wsdl:definitions> .
An 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 you run the above code, the Saxon 9.3.0.5 XSLT processor stops 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 that the engine first throws the QName into a string and then tries to drop it back into the 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 the Saxon XSLT processor or something that I misunderstood about XSLT?
Is there any XSLT engine capable of handling the above file?