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, ...

Get XQuery from the Experts: A Guide to the W3C XML Query Language now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.