jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "BOWLER Paul" <Paul.Bow...@alcatel-lucent.com>
Subject RE: Query for Nodes from a given Path
Date Tue, 07 Jul 2009 10:46:08 GMT
Thanks for the response.

The problem is that the pcf:Color node can appear at many levels within the tree so specifying
an absolute path won't work.

Any ideas how I can get around this?

P.

-----Original Message-----
From: Fabián Mandelbaum [mailto:fmandelbaum@gmail.com] 
Sent: 07 July 2009 11:39
To: users@jackrabbit.apache.org
Subject: Re: Query for Nodes from a given Path

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