[Home] [By Thread] [By Date] [Recent Entries]


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


Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member