Subject: [xsl] Difference in priority of node() and * From: "Mukul Gandhi" <gandhi.mukul@xxxxxxxxx> Date: Fri, 15 Feb 2008 22:08:23 +0530 |
I tested this stylesheet with Saxon 9.0. <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xsl:output method="text" /> <xsl:template match="node()"> 1 <xsl:apply-templates/> </xsl:template> <xsl:template match="*"> 2 <xsl:apply-templates/> </xsl:template> </xsl:stylesheet> This is an arbitrary stylesheet, with no semantic significance. It just studies the priority of template rules. When this is run on a dummy XML (say, below): <aaa> <bbb>123</bbb> <ccc>def</ccc> </aaa> I get output: Recoverable error XTRE0540: Ambiguous rule match for /aaa Matches both "node()" on line 7 of file:/E:/xml/xsleg/xslt/test.xsl and "element()" on line 12 of file:/E:/xml/xsleg/xslt/test.xsl Recoverable error on line 14 of file:/E:/xml/xsleg/xslt/test.xsl: XTRE0540: Ambiguous rule match for /aaa/bbb[1] Matches both "node()" on line 7 of file:/E:/xml/xsleg/xslt/test.xsl and "element()" on line 12 of file:/E:/xml/xsleg/xslt/test.xsl Recoverable error on line 14 of file:/E:/xml/xsleg/xslt/test.xsl: XTRE0540: Ambiguous rule match for /aaa/ccc[1] Matches both "node()" on line 7 of file:/E:/xml/xsleg/xslt/test.xsl and "element()" on line 12 of file:/E:/xml/xsleg/xslt/test.xsl [some more output] I am curious, why these two templates rules are ambiguous. The XSLT 2.0 spec says, "In many cases this means that highly selective patterns have higher priority than less selective patterns." Isn't * more specific than node() ? I was hoping, that * would have higher priority than node(). To solve this problem, I have to put priority attribute to one of the rules. Can somebody please explain this ... -- Regards, Mukul Gandhi
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Want to use XSLT to sort , Glen Mazza | Thread | Re: [xsl] Difference in priority of, Martin Honnen |
Re: [xsl] Want to use XSLT to sort , Glen Mazza | Date | Re: [xsl] Difference in priority of, Martin Honnen |
Month |