You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Ben Short <be...@benshort.co.uk> on 2009/10/05 14:34:25 UTC
XPath help
Hi,
I have 2 nodes:
/catalog/products/wooly_hat
/catalog/products/top_hat
both nodes have a title property.
I can't figure out how to write a XPATH query that will return nodes that
have a supplied value as there title. An SQL equivalent would be something
like select * from products where title = 'Wooly Hat'.
I have a query as follows but I'm not sure where to go with it. It feels
like I need to have a wild card to indicate that I want to search in each of
the products child nodes.
//catalog/products[@name = 'Wooly Hat']
Can anyone give me a pointer?
Regards
Ben
Re: XPath help
Posted by Ben Short <be...@benshort.co.uk>.
Thanks. I have clicked now :)
2009/10/5 Alexander Klimetschek <ak...@day.com>
> On Mon, Oct 5, 2009 at 14:34, Ben Short <be...@benshort.co.uk> wrote:
> > I have 2 nodes:
> >
> > /catalog/products/wooly_hat
> > /catalog/products/top_hat
> >
> > both nodes have a title property.
> >
> > I can't figure out how to write a XPATH query that will return nodes that
> > have a supplied value as there title. An SQL equivalent would be
> something
> > like select * from products where title = 'Wooly Hat'.
> >
> > I have a query as follows but I'm not sure where to go with it. It feels
> > like I need to have a wild card to indicate that I want to search in each
> of
> > the products child nodes.
> >
> > //catalog/products[@name = 'Wooly Hat']
> >
> > Can anyone give me a pointer?
>
> /jcr:root/catalog/products/*[@name = 'Wooly Hat']
>
> or
>
> /jcr:root/catalog/products//*[@name = 'Wooly Hat']
>
> if you want to search not only the direct children of products, but
> also any descendants.
>
> Regards,
> Alex
>
> --
> Alexander Klimetschek
> alexander.klimetschek@day.com
>
Re: XPath help
Posted by Alexander Klimetschek <ak...@day.com>.
On Mon, Oct 5, 2009 at 14:34, Ben Short <be...@benshort.co.uk> wrote:
> I have 2 nodes:
>
> /catalog/products/wooly_hat
> /catalog/products/top_hat
>
> both nodes have a title property.
>
> I can't figure out how to write a XPATH query that will return nodes that
> have a supplied value as there title. An SQL equivalent would be something
> like select * from products where title = 'Wooly Hat'.
>
> I have a query as follows but I'm not sure where to go with it. It feels
> like I need to have a wild card to indicate that I want to search in each of
> the products child nodes.
>
> //catalog/products[@name = 'Wooly Hat']
>
> Can anyone give me a pointer?
/jcr:root/catalog/products/*[@name = 'Wooly Hat']
or
/jcr:root/catalog/products//*[@name = 'Wooly Hat']
if you want to search not only the direct children of products, but
also any descendants.
Regards,
Alex
--
Alexander Klimetschek
alexander.klimetschek@day.com