jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Fabián Mandelbaum <fmandelb...@gmail.com>
Subject Re: Query for Nodes from a given Path
Date Tue, 07 Jul 2009 10:38:43 GMT
BOWLER Paul wrote:
> Hi,
>
> I need to query a subtree for specific nodes, but do not know the syntax
> for this.
>
> Currently I have:
>
> def query = qm.createQuery("//pcf:Color", Query.XPATH)
> return query.execute()
>
> This returns ALL pcf:Color nodes in the repository, but I'd like to
> limit the search down a specific path (or from a specific node).
>
> Any ideas how I could do this?
>
> Thanks,
>
> Paul.
>
>
>   
Hello Paul,

you simply prepend the starting path to your path specification in the
createQuery statement, for example, if you want to query the pcf:Color
nodes below /the/starting/node, you say:

query = qm.createQuery("/the/starting/node/pcf:Color", Query.XPATH);

if this still doesn't work, you prepend /jcr:root at the beginning, like
this:

query = qm.createQuery("/jcr:root/the/starting/node/pcf:Color",
Query.XPATH);

Good luck!

Mime
View raw message