Advanced programming examples from the book (not XQuery)