commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joerg Heinicke <jheini...@virbus.de>
Subject [jxpath] order of returned objects: //* vs. descendant::*
Date Fri, 09 May 2003 14:27:04 GMT
Hello,

for testing our own XPath implementation I wrote some XPath tests. Some of 
the tests showed strange behaviour. The two XPathes I have in mind are '//*' 
and 'descendant::*', both evaluated on the root context.

The order of the returned objects is different.

XML:

<element1>
   <element1-1>
     <element1-1-1/>
     <element1-1-2/>
   </element1-1>
   <element1-2>
     <element1-2-1/>
     <element1-2-2/>
   </element1-2>
   <element1-3>
     <element1-3-1/>
     <element1-3-2/>
   </element1-3>
</element1>

result of '//*' (same for non-abbreviated syntax 
'/descendant-or-self::node()/child::*'):

element1
element1-1
element1-2
element1-3
element1-1-1
element1-1-2
element1-2-1
element1-2-2
element1-3-1
element1-3-2

result of 'descendant::*'

element1
element1-1
element1-1-1
element1-1-2
element1-2
element1-2-1
element1-2-2
element1-3
element1-3-1
element1-3-2

The second order is the one I expect even if it's a node set and so has no 
sorting (document order) or alphabetically sorted as I heard in JXPath.

What's really strange is the different behaviour of the two expressions.

Regards,

Joerg

-- 

System Development
VIRBUS AG
Fon  +49(0)341-979-7419
Fax  +49(0)341-979-7409
joerg.heinicke@virbus.de
www.virbus.de


Mime
View raw message