jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Will Scheidegger <willscheideg...@mac.com>
Subject Re: select all nodes not having certain subnodes?
Date Thu, 19 Aug 2010 12:57:44 GMT
Thanks Alex for the help!

If it was only that easy... but unfortunately it's not. I need to find all rooms not having
a reservation subnode which touches the specified timespan, not all rooms which have reservations
for some other time than the one specified.

Your query would not return any room not having any reservation or it would also return any
room having a reservation outside of the specified timespan ignoring the fact that it also
might have one in that timespan.

So what I really would need would be a query like
/jcr:root/path/to/rooms/element(*,rooms)[count(/reservations/element(*,reservation)[@endTime
> xs:dateTime(x) and @startTime < xs:dateTime(y)]) == 0]

but afaik
- the count() function is not implemented by Jackrabbit
- XPaht does not allow "subqueries" like this

-will

On 19.08.2010, at 13:08, Alexander Klimetschek wrote:

> On Thu, Aug 19, 2010 at 10:48, Will Scheidegger <willscheidegger@mac.com> wrote:
>> I have "room" nodes with "calendar" subnodes (i.e. reservations). Now I would like
to find all rooms not having any reservations between x and y. The opposite is fairly easy:
>> 
>> /jcr:root/path/to/rooms/element(*,rooms)/reservations/element(*,reservation)[@endTime
> xs:dateTime(x) and @startTime < xs:dateTime(y)]
>> 
>> Is there any efficient way to reverse this?
> 
> Plain de Morgan's Law applied, I think:
> 
> ! (end > x and start < y)
> 
> = !(end > x) or !(start < y)
> 
> = end <= x or start >= y
> 
> Hence:
> 
> /jcr:root/path/to/rooms/element(*,rooms)/reservations/element(*,reservation)[@endTime
> <= xs:dateTime(x) or @startTime >= xs:dateTime(y)]
> 
> This has the same level of efficiency as the other query.
> 
> Regards,
> Alex
> 
> -- 
> Alexander Klimetschek
> alexander.klimetschek@day.com


Mime
View raw message