You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@sling.apache.org by Federico Paparoni <fe...@gmail.com> on 2010/07/29 16:21:59 UTC

XPATH Child query

Hi all,

I easily put my contents under path like this
http://localhost:8080/content/david/2010/07/25/example.html

but I don't really understand how can I create a query to search a property
on all the children of my application root node.
I tried some XPATH queries but probably there is something I don't
understand.
Can someone help me with this issue?

Bye

-- 
Federico

Re: XPATH Child query

Posted by Eric Norman <er...@gmail.com>.
If I understand your question correctly, you want to find all nodes whose
node name matches some pattern?

You can do an xpath query that does an exact match of the node name with the
fn:name() function like this:
   /jcr:root/content/david//element(*,nt:unstructured)[fn:name()
= 'myNodeName')]

But as far as I know, the jcr:like or jcr:contains will not work to do a
wildcard search of the node name since the name is not a property of the
node.

I generally like to add a 'displayName' property to each node that I can use
to query for and display in the UI since node name is often not very user
friendly.

Regards,
-Eric

On Thu, Jul 29, 2010 at 9:19 AM, Federico Paparoni <
federico.paparoni@gmail.com> wrote:

> Hi Eric,
>
> 2010/7/29 Eric Norman <er...@gmail.com>
>
> > Hi Federico,
> >
> > I believe the following query would do what you are asking for.  The
> xpath
> > query uses the "//" abbreviation for the descendant-or-self axis.
> >
> > var query =
> > queryManager.createQuery("/jcr:root/content/david//element(*,
> > nt:unstructured) order by @created descending", "xpath");
> >
> > Regards,
> > -Eric
> >
> >
> Thanks, this works, but anyway not all nodes have the same property, so
> probably I'll use the previous query.
> If I search in this way I get all the nodes, if I want to get a node with a
> particular property I can write
>
> /jcr:root/content/david//element(*,nt:unstructured)[jcr:like(@title,
> '%WORD%')]
>
> but if I want to search all nodes with the name like to some words?
>
> --
> Federico
>

Re: XPATH Child query

Posted by Federico Paparoni <fe...@gmail.com>.
Hi Eric,

2010/7/29 Eric Norman <er...@gmail.com>

> Hi Federico,
>
> I believe the following query would do what you are asking for.  The xpath
> query uses the "//" abbreviation for the descendant-or-self axis.
>
> var query =
> queryManager.createQuery("/jcr:root/content/david//element(*,
> nt:unstructured) order by @created descending", "xpath");
>
> Regards,
> -Eric
>
>
Thanks, this works, but anyway not all nodes have the same property, so
probably I'll use the previous query.
If I search in this way I get all the nodes, if I want to get a node with a
particular property I can write

/jcr:root/content/david//element(*,nt:unstructured)[jcr:like(@title,
'%WORD%')]

but if I want to search all nodes with the name like to some words?

-- 
Federico

Re: XPATH Child query

Posted by Eric Norman <er...@gmail.com>.
Hi Federico,

I believe the following query would do what you are asking for.  The xpath
query uses the "//" abbreviation for the descendant-or-self axis.

var query =
queryManager.createQuery("/jcr:root/content/david//element(*,
nt:unstructured) order by @created descending", "xpath");

Regards,
-Eric

On Thu, Jul 29, 2010 at 8:01 AM, Federico Paparoni <
federico.paparoni@gmail.com> wrote:

> 2010/7/29 Federico Paparoni <fe...@gmail.com>
>
> > Hi all,
> >
> > I easily put my contents under path like this
> > http://localhost:8080/content/david/2010/07/25/example.html
> >
> > but I don't really understand how can I create a query to search a
> property
> > on all the children of my application root node.
> > I tried some XPATH queries but probably there is something I don't
> > understand.
> > Can someone help me with this issue?
> >
> > Bye
> >
> > --
> > Federico
> >
>
>
> I solved the issue using the next query
>
> var query =
> queryManager.createQuery("/jcr:root/content/david/*/*/*/element(*,
> nt:unstructured) order by @created descending", "xpath");
>
> because all my nodes are like /YEAR/MONTH/DAY/entry. But If I want to make
> a
> full search on every children?
>
> --
> Federico
>

Re: XPATH Child query

Posted by Federico Paparoni <fe...@gmail.com>.
2010/7/29 Federico Paparoni <fe...@gmail.com>

> Hi all,
>
> I easily put my contents under path like this
> http://localhost:8080/content/david/2010/07/25/example.html
>
> but I don't really understand how can I create a query to search a property
> on all the children of my application root node.
> I tried some XPATH queries but probably there is something I don't
> understand.
> Can someone help me with this issue?
>
> Bye
>
> --
> Federico
>


I solved the issue using the next query

var query =
queryManager.createQuery("/jcr:root/content/david/*/*/*/element(*,
nt:unstructured) order by @created descending", "xpath");

because all my nodes are like /YEAR/MONTH/DAY/entry. But If I want to make a
full search on every children?

-- 
Federico