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