[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Difference in priority of node() and *
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|