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 question
Date Fri, 14 May 2010 17:09:30 GMT
On Fri, May 14, 2010 at 16:56, Rakesh Vidyadharan <rakesh@sptci.com> wrote:
> Is it possible to filter based on parent node properties when executing an XPath query
(JR 1.6).  Let me explain the scenario that I have.
>
> We have a repository for all the books published by a press.  Each book has child nodes
that identify the various formats it has been published in (cloth bound, paperback, etc.)
and are termed as distributions.  All publication dates are associated with the distributions,
since the book really has no  publication date of its own.  Each book may belong to an array
of subjects, so the subjects are stored as a multi-value property in the book node.
>
> The structure is something along these lines
>
> /books
>  /book
>    /A (alphabetical index as well as keep node count under control)
>      /bo<Database PK value> <-- represents each book
>        /distribution <- Container node for the various distributions
>           /di<Database PK value> <-- represents a published format of the
book
>
> Example path for a distribution is: /books/book/T/bo5822950/distribution/di5822950
>
> I need to generate RSS feeds of the new books (based on dates at the distribution node)
as well as  subject specific RSS for new books.  The XPath query for the new books is as
follows:
>
> //*[@nodeType = 'di' and @date > xs:dateTime('2010-03-13T17:29:50.050Z') and @date
<= xs:dateTime('2010-05-13T17:29:50.050Z') and @binding != 'ec0214db-8bb2-4f23-a925-341cd98196f7']
order by @date descending
>
> Would it be possible in XPath to add some additional predicates to filter by subject
at the book node level?  I can iterate over the results and filter on parent.parent, but
wondered if it is possible in the query.

Something like this should be possible:

/jcr:root/books/book/*[jcr:title= 'My Booktitle']//*[@nodeType = 'di'
and @date > xs:dateTime('2010-03-13T17:29:50.050Z') and @date <=
xs:dateTime('2010-05-13T17:29:50.050Z') and @binding !=
'ec0214db-8bb2-4f23-a925-341cd98196f7'] order by @date descending

Please note that path-based location steps (eg. the /books/book part)
are not indexed, so this query might be slower than your first one.

Regards,
Alex

-- 
Alexander Klimetschek
alexander.klimetschek@day.com

Mime
View raw message