|
[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: XPath brain teaser
From: "Roger L. Costello" <costello@m...> > These two XPath expressions are equivalent: > > //para[1] > /descendant::para[1] > > (a) True > (b) False > > Answer: (b) False This is easier to understand if you think of it in terms of set construction and iterators. The two expressions with abbreviations eliminated are: /descendant-or-self::node()/para[1] /descendant::para[1] The first expression forms a set of all nodes that are descendant-or-self of the document node, IOW all nodes in the document. Then, for each member forms the set of para children, if any, then selects the first node from the set. Obviously, this can yield multiple result nodes. The second expression forms a set of all para nodes, then selects the first node from the set. This can produce at most one result node. Bob Foster
|
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








