(: Get a distinct collection of the authors. Over bibliography.xml. parke godfrey 2013-11-06 One way is to use the function "distinct-values". It takes a list of values in, and returns a list of values out with the duplicates removed. In doing so, the return is by value, not by reference! This is because the thinking behind XQuery is that operations like this only make sense value-wise, not "node" wise. So $author is ranging over the content (values) of the author nodes, the text that is the authors' names. Note that there may be more than one node per given author because of repeats in the document. If I want to retrieve _an_ author node per author name, I have to go back to the document. :) { for $author in distinct-values(doc("bibliography.xml")//author/text()) order by $author return (doc("bibliography.xml")//author[text() = $author])[1] }