jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexander Klimetschek <aklim...@day.com>
Subject Re: select all nodes not having certain subnodes?
Date Thu, 19 Aug 2010 11:08:22 GMT
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