When writing this code for Basex
<tourism>
{
for $hotel in doc("tourism.xml")/tourism/hotel
let $r:=$hotel/room
let $g:=doc("tourism.xml")/tourism/guest
where $g/@name="Udo Lindenberg" and $g/customer/@hotel=$hotel/@id and $r/@id=$g/occupies/@room
return
<hotel>
<hotel_name>{string($hotel/@name)}</hotel_name>
<first_day>$g/occupies/@from</first_day>
<last_day>$g/occupies/@to</last_day>
</hotel>
}
</tourism>
It returns this:
<tourism>
<hotel>
<hotel_name>Interconti</hotel_name>
<first_day>$g/occupies/@from</first_day>
<last_day>$g/occupies/@to</last_day>
</hotel>
<hotel>
<hotel_name>Tourist Inn</hotel_name>
<first_day>$g/occupies/@from</first_day>
<last_day>$g/occupies/@to</last_day>
</hotel>
How to return "2004-03-21" "2004-05-05", Instead of $g/occupies/@from $g/occupies/@to ?
Try this. Missing {} in the
return
forfirst_day
andlast_day
. Sample XML structure would be of great help, as suggested by @dirkk