Error XTTE0505 When Using @as On xsl:template with a *
Added by Adrian Bird 3 months ago
Is there a reason why a xsl:template produces as error, but a xsl:variable doesn't when I have the following in the as attribute:
element(Q{http://myns}*)+
I'm trying to output multiple different top level elements in the same namespace which is why I'm using *.
Adrian
Replies (7)
Please register to reply
RE: Error XTTE0505 When Using @as On xsl:template with a * - Added by Michael Kay 3 months ago
The reason is that the XPath 3.1 grammar (production ElementTest) doesn't allow it.
Is there a reason for that? We decided that there isn't, so the XPath 4.0 grammar does allow it.
RE: Error XTTE0505 When Using @as On xsl:template with a * - Added by Michael Kay 3 months ago
On the current build I'm getting
Error in xsl:variable/@as on line 5 column 47 of test.xsl:
XPST0003 Wildcard syntax in item types requires 4.0 to be enabled
but it's possible there are earlier releases in which we allow the syntax through without checking.
RE: Error XTTE0505 When Using @as On xsl:template with a * - Added by Adrian Bird 3 months ago
For interest here's my test case (which is attached as well):
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="3.0"
xmlns:myns="http://myns"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" />
<xsl:variable name="var01" as="element(Q{http://myns}*)+">
<myns:node>var01</myns:node>
</xsl:variable>
<xsl:template name="xsl:initial-template">
<root>
<xsl:copy-of select="$var01" />
<xsl:call-template name="template01" />
</root>
</xsl:template>
<xsl:template name="template01" as="element(Q{http://myns}*)+">
<myns:node>template01</myns:node>
</xsl:template>
</xsl:stylesheet>
In 12.5 and 12.4 I get this error (which is a bit odd as it says the node is in the wrong namespace, but the supplied value shows it is in the correct namespace):
Type error on line 20 column 16 of As.xslt:
XTTE0505 The required item type of the result of template template01 is Q{http://myns}*;
the supplied value <myns:node> does not match. The node is in the wrong namespace
In template template01 on line 19 column 66 of As.xslt:
invoked by xsl:call-template at file:/L:/Tests/XSLT/XSLT_As/As.xslt#15
In template xsl:initial-template on line 12 column 45 of As.xslt:
The required item type of the result of template template01 is Q{http://myns}*; the supplied value <myns:node> does not match. The node is in the wrong namespace
In 12.3 I get:
Error in xsl:variable/@as on line 8 column 61 of As.xslt:
XPST0003 Unexpected <prefix:*> after '(' in SequenceType
Error in xsl:template/@as on line 19 column 66 of As.xslt:
XPST0003 Unexpected <prefix:*> after '(' in SequenceType
Errors were reported during stylesheet compilation
RE: Error XTTE0505 When Using @as On xsl:template with a * - Added by Adrian Bird 3 months ago
I should have said I'm using SaxonJ-HE.
RE: Error XTTE0505 When Using @as On xsl:template with a * - Added by Michael Kay 3 months ago
It looks as if the check to disallow this syntax unless 4.0 is enabled was added after the last maintenance release; so the code as issued is probably allowing the 4.0 syntax but not implementing the semantics.
RE: Error XTTE0505 When Using @as On xsl:template with a * - Added by Michael Kay 3 months ago
In fact I think I made this change in the course of investigating bug #6532
RE: Error XTTE0505 When Using @as On xsl:template with a * - Added by Adrian Bird 3 months ago
It looks as if the check to disallow this syntax unless 4.0 is enabled was added after the last maintenance release; so the code as issued is probably allowing the 4.0 syntax but not implementing the semantics.
I don't know what the semantics are, but If I add the following to the variable (and get rid of the error related to the template):
<myns:node2>var01</myns:node2>
I get both nodes output:
<myns:node>var01</myns:node>
<myns:node2>var01</myns:node2>
Please register to reply