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 <[email protected]> > 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 > [email protected]
