You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by bu...@apache.org on 2003/10/20 21:42:32 UTC

DO NOT REPLY [Bug 23933] - XPath with predicate [1] returns multiple nodes

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=23933>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=23933

XPath with predicate [1]  returns multiple nodes

David_N_Bertoni@lotus.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID
            Summary|XPath with predicate [1]    |XPath with predicate [1]
                   |returns multiple nodes      |returns multiple nodes



------- Additional Comments From David_N_Bertoni@lotus.com  2003-10-20 19:42 -------
Xalan-C's result is correct and I have verified it with multiple XPath/XSLT 
implementations.  Are you sure this is the XPath expression you want to 
evaluate?  "//" is short for "/descendant-or-self/node()/", so "//descendant-or-
self::Assertion[parent::Security][1]" expands to "/descendant-or-self/node
()/descendant-or-self::Assertion[parent::Security][1]", which is probably not 
what you want.

If I change your XPath expression to:

"/descendant-or-self::Assertion[parent::Security][1]" 

or :

"(//Assertion[parent::Security])[1]"

I get what you probably expect.  The positional predicates and "//" have some 
interesting interactions, as state here:

http://www.w3.org/TR/xpath#path-abbrev

In particular, the last part:

"// is short for /descendant-or-self::node()/. For example, //para is short 
for /descendant-or-self::node()/child::para and so will select any para element 
in the document (even a para element that is a document element will be 
selected by //para since the document element node is a child of the root 
node); div//para is short for div/descendant-or-self::node()/child::para and so 
will select all para descendants of div children.

NOTE: The location path //para[1] does not mean the same as the location 
path /descendant::para[1]. The latter selects the first descendant para 
element; the former selects all descendant para elements that are the first 
para children of their parents."