{
for $act in doc("hamlet.xml")//ACT
let $speakers := distinct-values($act//SPEAKER)
return
{ string($act/TITLE) }
{
for $speaker in $speakers
return - { $speaker }
}
}
(: -------- :)
{
for $book in doc("books.xml")//book
return
if (contains($book/author/text(),"Herbert") or contains($book/author/text(),"Asimov"))
then $book
else $book/text()
let $let :=
"test"
return element element {
attribute attribute { 1 },
element test { 'a' },
attribute foo { "bar" },
fn:doc()[ foo/@bar eq $let ],
//x }
}
(: -------- :)
{
for $b in doc("http://bstore1.example.com/bib.xml")/bib/book
where $b/publisher = "Addison-Wesley" and $b/@year > 1991
return
{ $b/title }
}
(: -------- :)