to the main page about the tutorial  THE XML REVOLUTION  -  TECHNOLOGIES FOR THE FUTURE WEB back up next

List expressions

XQuery expressions manipulate lists of values, for which many operators are supported: When lists are viewed as sets:

The following query lists each publisher and the average price of their books:
for $p in distinct-values(document("bib.xml")//publisher)
let $a := avg(document("bib.xml")//book[publisher = $p]/price)
return
  <publisher>
     <name>{ $p/text() }</name>
     <avgprice>{ $a }</avgprice>
  </publisher>

Compare this with the verbose XQueryX syntax.

back COPYRIGHT © 2000-2003 ANDERS MØLLER & MICHAEL I. SCHWARTZBACH next