You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by Shane Preater <sh...@googlemail.com> on 2006/10/04 14:32:33 UTC

XPath question 1

HI,
I am looking to return the following nodes:
/jcr:root/people/users/hashing-bit/*
(hashing bit is the hashing we are using to ensure node depth and therefore
performance).

I need to return the nodes above in a search where they have an additional
child node called author

essentially all the users with the author role.
I have tried the following:
/jcr:root/people/users/hashing-bit/*/author/parent::*
/jcr:root/people/users/hashing-bit/*[element(author, nt:unstructured)]
/jcr:root/people/users/hashing-bit/*[node-name(./*) = 'author']

All to no avail.
I am not sure if this is a specific jackrabbit question or a more general
xpath if its the latter I apologise.

Many thanks,
Shane Preater

Re: XPath question 1

Posted by Jukka Zitting <ju...@gmail.com>.
Hi,

On 10/4/06, Shane Preater <sh...@googlemail.com> wrote:
> I need to return the nodes above in a search where they have an additional
> child node called author
> [...]
> I am not sure if this is a specific jackrabbit question or a more general
> xpath if its the latter I apologise.

Unfortunately the search features specified in JSR 170 or implemented
in Jackrabbit don't allow such queries. See JCR-247 for the related
improvement issue.

A workaround you can use is to query for the author node
(/jcr:root/people/users/hashing-bit/*/author), and postprocess the
results to get the parent nodes you were looking for.

Another alternative would be to model the "has author information"
constraint as an explicit mixin type, which would allow you to use a
query like /jcr:root/people/users/hashing-bit/element(*,authored).

BR,

Jukka Zitting

-- 
Yukatan - http://yukatan.fi/ - info@yukatan.fi
Software craftsmanship, JCR consulting, and Java development