<system>{
for $hotel in doc("doc.xml")//Hotel
let $hotelName := $hotel/@name
return
<Hotel Name="{ ($hotelName) }">
{
let $beginWeek := fn:current-date() - xs:dayTimeDuration(concat('P', 7, 'D'))
let $endWeek := fn:current-date() - xs:dayTimeDuration(concat('P', 1, 'D'))
for $beginDate in xs:date($hotel/reservation/@begin_date)
for $endDate in xs:date($hotel/reservation/@end_date)
where ($beginDate gt $beginWeek and $beginDate lt $endWeek)
and ($endDate gt $beginWeek and $endDate lt $endWeek)
return <day date="{ count($hotel/reservation/client/room/guest) }"/>
}
</Hotel>
}
</system>