I've come to a complete stand-still regarding a certain XQuery-problem. In the beginning, I did not have multiple exhibits with the same title in the XML-document - when I changed that I noticed a certain problem: the result (in XQuisitor) displays all the names of the guides twice or thrice for each unique exhibit, depending the how many exhibits share the same title.
I have no idea why and would be grateful for some input.
Here's the XQuery code I tried with:
for $u in (//Exhibit/@title)
let $guide := for $g in //Guide[../@title=$u]/@gname return element Guide {$g}
return element Exhibit {attribute Title {$u}, $guide }
Example XML-document:
<?xml version="1.0" encoding="UTF-8"?>
<Exhibits>
<Exhibit title = "Renaissance" sdate= "2011-09-05"
edate= "2012-02-05" sarea = "2400">
<Guide gname = "John Smith" >
<Lang sname ="English"/>
<Lang sname ="German"/>
</Guide>
<Guide gname = "Weber Schneider">
<Lang sname = "German"/>
</Guide>
<Guide gname = "Robert Lundstrom">
<Lang sname = "Swedish"/>
</Guide>
<Guide gname = "Paula Munoz">
<Lang sname = "Spanish"/>
<Lang sname = "German"/>
<Lang sname = "English"/>
</Guide>
</Exhibit>
<Exhibit title = "Renaissance" sdate= "2011-10-06"
edate= "2011-11-26" sarea = "2000">
<Guide gname = "John Smith">
<Lang sname ="English"/>
<Lang sname ="German"/>
</Guide>
<Guide gname = "Paula Munoz">
<Lang sname = "Spanish"/>
<Lang sname = "German"/>
<Lang sname = "English"/>
</Guide>
</Exhibit>
</Exhibits>
Thanks!