-
1. Re: Testing XPath in ModeShape
rhauch Mar 10, 2010 10:22 PM (in response to bgoetzmann)First of all, thanks for giving ModeShape a try.
I finally was able to duplicate your problem in a test case, and for me queries such as the following:
//odl:odelia-technologies[@odl:url='http://www.odelia-technologies.com']
do not find nodes that are immediately under the root, but it does find nodes that match that criteria in any location other than right under the root. For example, in your case, the "/odl:odelia-technologies" node should match the criteria, but for some reason it isn't included in the results. I think if you tried and there were nodes matching the criteria other than right under the root, the queries will work.
Also, the following query:
//odl:odelia-technologies
does work because it is translated into different criteria (a simple name match), and thus this works regardless of where the node is.
This behavior is definitely a bug because both queries are valid and should work, so I'll log a defect and we'll get that fixed in 1.1. Luckily, in this case there are several simple workarounds:
1) In this example, the node you're searching for is right under the root, so you could constrain the query a bit more (resulting in different constraints that are processed correctly for all nodes):
/jcr:root/odl:odelia-technologies[@odl:url='http://www.odelia-technologies.com']
2) In the case where the location of the nodes is more variable (or unknown) but you know the name, you can use the 'element(name)' function to constrain the name of the node:
//element(odl:odelia-technologies)[@odl:url='http://www.odelia-technologies.com']
Hopefully these will work for you, and we'll get this fixed in 1.1, which we hope to release in a few weeks!
-