(: Get a distinct collection of the authors. Over bibliography.xml. parke godfrey 2013-11-06 A second way is to use "group by". Yes, this is quite similar to group by in SQL! Again, it is value based, not node based! I kind of like this solution better for "distinct". It seems cleaner, and the meaning is quite clear. :) { for $author in doc("bibliography.xml")//author/text() group by $author order by $author return (doc("bibliography.xml")//author[text() = $author])[1] }