为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>
它返回:
<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>
如何回归&#34; 2004-03-21&#34; &#34; 2004-05-05&#34;,而不是$ g /占用/ @从$ g /占用/ @到?
答案 0 :(得分:3)
试试这个。在return
和first_day
的{{1}}中缺少{}。正如@dirkk
last_day