You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by Paul Davis <pa...@gmail.com> on 2008/08/06 22:00:11 UTC

querying nodes?

Hi,
If I create some nodes like:
curl -D - -F"sling:resourceType=editorial/tracks"  ...other params...
"http://admin:admin@localhost:8080/sling/modules/editorial/tracks/*"

where sling creates the path, how can I query for a list of nodes
created that way?

thanks

Re: querying nodes?

Posted by Christopher Elkins <ch...@esha.com>.
On Aug 6, 2008, at 1:00 PM, Paul Davis wrote:

> Hi,
> If I create some nodes like:
> curl -D - -F"sling:resourceType=editorial/tracks"  ...other params...
> "http://admin:admin@localhost:8080/sling/modules/editorial/tracks/*"
>
> where sling creates the path, how can I query for a list of nodes
> created that way?
>
> thanks


There are a number of ways to do it. For JCR resources, Sling passes  
the query to the repository's QueryManager, which by specification  
must support XPath. Here are two examples (in code and via HTTP,  
respectively):

   ResourceResolver rr = [get ResourceResolver instance];
   Iterator results = rr.queryResources("// 
*[@sling:resourceType='editorial/tracks']", "xpath");

   http://localhost:8080/sling/modules.query.json?statement=// 
*[@sling:resourceType='editorial/tracks']&queryType=xpath

The JSR 170 specification has many more examples, including SQL  
syntax, which is optional but supported by Jackrabbit.

HTH

-- 
Christopher Elkins