[jboss-user] [Beginner's Corner] - JCR xpath query

Ming Yu do-not-reply at jboss.com
Wed Nov 2 13:52:01 EDT 2011

Ming Yu [http://community.jboss.org/people/my600080] created the discussion

"JCR xpath query"

To view the discussion, visit: http://community.jboss.org/message/634669#634669

Hi, I have a question regarding a jcr xpath query. Here is an example similar to the one on jboss's website:

| //element(*,my:type)[./*/*/@id=1 and ./*/*/@name='test'] |

This xpath query is equivillent to the following sql select statement:

| SELECT * FROM [my:type] 
JOIN [nt:base] as nodeSet1 ON ISCHILDNODE(nodeSet1,[my:type]) 
JOIN [nt:base] as nodeSet2 ON ISCHILDNODE(nodeSet2,nodeSet1) 
WHERE nodeSet2.id = 1 and nodeSet2.name = 'test' |

What I want to achieve is to get all entries from my:type that have a two level down childnode with id = 1 AND name = 'test'. So, these two constraints have to be met on any ONE child node.

But this query will actually do this: any two level down childnode contains id = 1 or name = 'test'.  The childnode can be different childnode as long as one meets id = 1 and the other one meets name = 'test'.

How can I achive my goal with xpath query?

Thanks a lot!


Reply to this message by going to Community

Start a new discussion in Beginner's Corner at Community

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20111102/f1664807/attachment.html 

More information about the jboss-user mailing list