jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexander Klimetschek <aklim...@day.com>
Subject Re: XPath query with path constraint and same name siblings
Date Tue, 16 Mar 2010 11:30:27 GMT
On Tue, Mar 16, 2010 at 11:34, Gadbury <gadbury@googlemail.com> wrote:
> "/jcr:root/root/providers/provider//element(*, atl:account)"
>
> The idea is to retrieve all account node types under a given provider node;
> the first provider in this case, ignoring the other two providers accounts.
> The trouble is, my query is returning all accounts for all providers.
>
> Is this a problem due to same name sibling nodes?

Not a a problem, that's how XML and Xpath work ;-) In the document xml
view (which is what is used for Xpath queries), all your provider
nodes have the same name "provider", hence
/jcr:root/root/providers/provider matches multiple elements.

>  Should the path to the first provider be provider[1]?

Yes, see http://www.day.com/specs/jcr/1.0/6.6.4.1_Same-Name_Siblings.html

However, with same-name siblings you will see this problem in various
places, so I strongly recommend to change your content model and give
those SNS a distinctive name (eg. name of the provider, date, or even
some id if it is common). How do you know the first provider is the
right one anyway?

Regards,
Alex

-- 
Alexander Klimetschek
alexander.klimetschek@day.com

Mime
View raw message