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

Quantified expressions

XQuery allows quantified expressions, which decide properties for all elements in a list:

The following example finds the titles of all books which mention both sailing and windsurfing in the same paragraph:

for $b in document("bib.xml")//book
where some $p in $b//paragraph satisfies
  (contains($p,"sailing") AND contains($p,"windsurfing"))
return $b/title

The next example finds the titles of all books which mention sailing in every paragraph:

for $b in document("bib.xml")//book
where every $p in $b//paragraph satisfies
  contains($p,"sailing")
return $b/title

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