O'Reilly logo

XQuery from the Experts: A Guide to the W3C XML Query Language by Philip Wadler, Jim Tivy, Jérôme Siméon, Michael Rys, Jonathan Robie, Michael Kay, Mary Fernández, Denise Draper, Don Chamberlin, Howard Katz - Editor

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Predicates

A predicate selects nodes in a path expression that satisfy a given expression. Here is an example:

$auction/articles/article[start_date <= date()] has type element(article)*

The path extracts one or more articles from the auction, and then selects zero, one, or more of these.

Sometimes, predicates are intended to single out a particular item, but, in general, the type system is not clever enough to know this.

$auction/articles/article[@id=$id] has type element(article)*

Here the type assigned suggests that there may be zero, one, or many articles. But if the id attribute is used as a key, then there will be at most one result, and if $id is bound to a valid key, then there will be exactly one result. XQuery provides three functions, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required