Query that joins two documents

For each book found in both bib.xml and reviews.xml, list the title of the book and its price from each source.

<books-with-prices>
 {
   for $b in document("bib.xml")//book,
     $a in document("reviews.xml")//entry
   where $b/title = $a/title
   return
    <book-with-prices>
     { $b/title },
       <price-amazon> { $a/price/text() } </price-amazon>
       <price-bn> { $b/price/text() } </price-bn>
    </book-with-prices>
 }
</books-with-prices>

Adapted from XML Query Use Cases


Previous | Next | Top | Cafe con Leche

Copyright 2002, 2003 Elliotte Rusty Harold
elharo@metalab.unc.edu
Last Modified September 13, 2001