{ for \$b in document("http://www.bn.com/bib.xml")/bib/book where \$b/publisher = "Addison-Wesley" and \$b/@year > 1991 return { \$b/title } } ; { for \$b in document("http://www.bn.com/bib.xml")/bib/book, \$t in \$b/title, \$a in \$b/author return { \$t } { \$a } } ; { for \$b in document("http://www.bn.com/bib.xml")/bib/book return { \$b/title } { \$b/author } } ; { for \$a in distinct-values(document("http://www.bn.com/bib.xml")//author) return { \$a } { for \$b in document("http://www.bn.com/bib.xml")/bib/book where some \$ba in \$b/author satisfies deep-equal(\$ba,\$a) return \$b/title } } ; { for \$b in document("http://www.bn.com/bib.xml")//book, \$a in document("http://www.amazon.com/reviews.xml")//entry where \$b/title = \$a/title return { \$b/title } { \$a/price/text() } { \$b/price/text() } } ; { for \$b in document("http://www.bn.com/bib.xml")//book where count(\$b/author) > 0 return { \$b/title } { for \$a in \$b/author[position()<=2] return \$a } { if (count(\$b/author) > 2) then else () } } ; { for \$b in document("http://www.bn.com/bib.xml")//book where \$b/publisher = "Addison-Wesley" and \$b/@year > 1991 order by \$b/title return { \$b/@year } { \$b/title } } ; for \$b in document("http://www.bn.com/bib.xml")//book let \$e := \$b/*[contains(string(.), "Suciu") and ends-with(local-name(.), "or")] where exists(\$e) return { \$b/title } { \$e } ; { for \$t in document("books.xml")//(chapter | section)/title where contains(\$t/text(), "XML") return \$t } ; { let \$doc := document("prices.xml") for \$t in distinct-values(\$doc//book/title) let \$p := for \$x in \$doc//book[title = \$t]/price return decimal(\$x) return { min(\$p) } } ; { for \$b in document("http://www.bn.com/bib.xml")//book[author] return { \$b/title } { \$b/author } } { for \$b in document("http://www.bn.com/bib.xml")//book[editor] return { \$b/title } {\$b/editor/affiliation} } ; { for \$book1 in document("http://www.bn.com/bib.xml")//book, \$book2 in document("http://www.bn.com/bib.xml")//book let \$aut1 := for \$a in \$book1/author order by \$a/last, \$a/first return \$a let \$aut2 := for \$a in \$book2/author order by \$a/last, \$a/first return \$a where \$book1 << \$book2 and not(\$book1/title = \$book2/title) and sequence-deep-equal(\$aut1, \$aut2) return { \$book1/title } { \$book2/title } } ; define function toc(\$e as element ) as element* { let \$n := local-name( \$e ) return if (\$n = "section") then
{ \$e/@* } { toc(\$e/*) }
else if (\$n = "title") then \$e else () } { toc( document("book.xml")/book ) } ; { for \$f in document("book.xml")//figure return } ; { count(document("book.xml")//section) }, { count(document("book.xml")//figure) } ; { count(document("book.xml")/book/section) } ; { for \$s in document("book.xml")//section let \$f := \$s/figure return
} ; define function section_summary(\$s as element) as element {
{ \$s/@* } { \$s/title } { count(\$s/figure) } { for \$ss in \$s/section return section_summary(\$ss) }