[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: //* and position()
Mike Brown wrote: > > Someone explain this to me: > > [snip] Mike -- This points out the difference between using a predicate as part of a location step (Xpath production [4]) and using a predicate as part of a FilterExpr (Xpath production [20]). In the case of //*[position() < 3], this is an abbreviation for /descendents-or-self::node()/child::*[position() < 3] In other words, this will select any node that is one of the first two children of another node. This is how a predicate is used as part of a location step. In the case of $all_elements[position() < 3] (equivalent to (//*)[position() < 3]), this will select the first two items in the node-set $all-elements. As Mike Kay mentions in his excellent book (at p. 382 at the bottom), [] binds more tightly than /. >The first and 3rd methods return all elements, regardless of position. Well, not really, depending on your input XML. They any node that is one of the first two children of another node. If none of your nodes have more than two children, the first and 3rd methods will return all elements. Try adding a third child to one of your nodes and you'll see that it won't be returned. HTH, Gary 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
|