|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: the nearest ancestor with the attribute
Since I started this confusion in the first place, can I summarise and check that I've got it right now? A node set is always unordered until you do anything with it like iterate over it, get a value from it or whatever. Of course a node set is pretty useless unless you do something with it, so saying a node set is unordered doesn't particularly help :) When you use a node set to do something with nodes within an XSLT attribute (e.g. xsl:value-of/@select or xsl:apply-templates/@select or xsl:for-each/@select) then the node set is always sorted into *document order* no matter what axes you use. When you use a predicate on a node set that's already been generated, such as a node-set variable, a union or just by putting brackets around it (e.g. $foo[1], (//*/@*)[1] or (foo|bar)[1]) then the node set is always sorted into *document order* no matter what axes you use. When you use a predicate on a node set within a step (e.g. //*/@*[1] or foo[1]) then the node set is sorted according to the axis. If it's preceding::, preceding-sibling::, ancestor:: or ancestor-or-self:: then it's a reverse axis, otherwise it's a forward axis. If it's a reverse axis, then it's sorted into *reverse document order* before the predicate is assessed; if it's a forward axis, then it's sorted into *document order* before the predicate is assessed. Having said all that, the attribute:: axis and the namespace:: axis are a bit weird because there is no real concept of 'document order' for attributes or namespace nodes. So, although @*[1] gives you the first attribute in document order, this could actually be any attribute on the element. It rarely makes sense to use a positional predicate with an attribute or namespace axis because attributes and namespaces have no inherent position in an element. For attributes and namespaces, document order is implementation dependent: it's fairly likely (?) that they'll just be sorted alphabetically. Namespace nodes always come before attribute nodes, though, and both occur before any child nodes. Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
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
|

Cart








