List books including their year and title:
<bib> { for $book in doc("bib.xml")/bib/book return <book year ="{ $book/@year }"> { $book/title } </book> } </bib>
Adapted from XML Query Use Cases