[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: simple XPath question
> Now that I think about it some more, I believe in the > previous chapter the > author wrote that elements in node-sets do not have an order. This often confuses people. Nodes have an order, called document order. Node-sets have no ordering of their own, but the nodes themselves still have an order. Think of it as being like sets of integers. {1,2,3} and {3,1,2} represent the same set of integers, because the set has no ordering. But it's still possible to ask for the "second-highest integer in the set", because integers are ordered. Similarly in a set of <country> nodes, you can ask for the <country> that is second in document order. > Thus it could > not be that select='item/country' could select the two > <country> nodes, > country[1] being US and country[2] being Canada. > > And the position() values are really a separate thing > entirely. They are > positions in the source tree, not in the node-set, since > nodes in node-sets don't have positions. No, quite the contrary. position() has nothing to do with the position of a node in the source tree, it's the position of the node in the current node list that matters. For example, if you do xsl:for-each with an xsl:sort, it's the position of the node in sorted order. Mike Kay Software AG 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
|