[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Difference in priority of node() and *

Subject: Difference in priority of node() and *
From: "Mukul Gandhi" <gandhi.mukul@xxxxxxxxx>
Date: Fri, 15 Feb 2008 22:08:23 +0530
 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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.