Query with distinct

For each author in the bibliography, list the author's name and the titles of all books by that author, grouped inside a result element.

<results>
 {
   for $a in distinct-values(document("bib.xml")//author)
   return
    <result>
     { $a }
     {  for $b in document("bib.xml")/bib/book[author=$a]
        return $b/title
     }
    </result>
 }
</results>

Adapted from XML Query Use Cases


Previous | Next | Top | Cafe con Leche

Copyright 2002, 2003 Elliotte Rusty Harold
elharo@metalab.unc.edu
Last Modified February 4, 2002