OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Re: [xml-dev] XPath brain teaser

[ Lists Home | Date Index | Thread Index ]

From: "Roger L. Costello" <costello@mitre.org>
> 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





 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS