jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexander Klimetschek <aklim...@day.com>
Subject Re: Range of levels in XPath
Date Fri, 08 May 2009 11:55:07 GMT
On Thu, May 7, 2009 at 9:27 PM, hsp_ <piccinatto@ibest.com.br> wrote:
>
> Hi;
> How the xpath could help me in the following case:
> I have to retrieve 3 levels of path below a relative path, for example:
>
> A
> |_B
> |_C
>   |_D
>      |_E
>      |_F
>         |_G
>
> starting in /A, I need to retrieve the nodes:
> /A/B
> /A/C
> /A/C/D
> /A/C/D/E
> /A/C/D/F
>
> (not /A/C/D/F/G and the other that would exists deeper)
>
> Can I do this with xpath?
> With sql I know how, but I need this in xpath.

This is not possible with JCR Xpath. You have the descendant-or-self
axis (//), which returns all descendants up to infinite depth, and
there is no depth-checking function. Doing /jcr:root/A//* gives you
everything in your tree.

However, you could mark your nodes by certain properties. This of
course depends on the semantics of your hierarchy and data, but there
must be some reason behind the 3 levels of depth, and this could also
be encoded in the nodes itself. Since property lookup is very fast
(faster than hierarchical lookups in the Lucene search index
implementation of Jackrabbit), I'd recommend this anyway:

/jcr:root/A//*[@someproperty = 'mycategory']

Regards,
Alex

-- 
Alexander Klimetschek
alexander.klimetschek@day.com

Mime
View raw message