View Full Version : XPath Ambiguity

07-25-2007, 12:21 PM
Hi all,

I am currently working on an XPath engine written in C++.

Consider the following XML fragment:

<item id="1">Hello World!</item>
<item id="2">Hello Mars!</item>

And consider the following XPath query:


It is clear from the XML fragment that this query could, logically, operate in one of two ways.

Firstly, it could return one copy of item 1 and two copies of item 2, because item 2 is reachable in two ways using the xpath query given.

Secondly, it could return one copy of item 1 and one copy of item 2 because the two paths to item 2 both terminate at the same XML object.

It is easy for me to implement either behaviour in the C++, and both behaviours are logically correct, but the question is, which behaviour is generally considered to be "preferentially" correct?