View Single Post
  #3 (permalink)  
Old December 1st, 2008, 05:38 AM
mhkay's Avatar
mhkay mhkay is offline
Wrox Author
Points: 18,481, Level: 59
Points: 18,481, Level: 59 Points: 18,481, Level: 59 Points: 18,481, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,960
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Yes, they are conflicting, because an element that matches //car[...] will also match "*".

The default priority of a template depends on the syntax of the match pattern. The pattern "*" has lower priority than "//car[...]". So in this case the second will always be chosen (assuming it matches).

Your stylesheet produces no output because the template for the document node applies templates to the top-level element (<cars>), and the template rule that matches <cars> is the one with match="*", which doesn't apply-templates to its children.

Incidentally, you don't need "//" at the start of a match pattern. Its only effects are subtle things you almost certainly don't want: (a) it can change the default priority of the template in unexpected ways, and (b) it will only match the car element if the element is part of a document. Just write match="car[type='555i']"

Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer's Reference
Reply With Quote