XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition (453 page)

BOOK: XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition
9.57Mb size Format: txt, pdf, ePub

For example, the expression:

//book[author=“Kay”]

means the same as:

//book[some $a in author satisfies $a eq “Kay”]

Similarly, the expression:

//book[author=(“Kay”, “Tennison”, “Carlisle”)]

means the same as:

//book[some $a in author,

            $s in (“Kay”, “Tennison”, “Carlisle”)

       satisfies $a eq $s]

It's a matter of personal style which one you choose in these cases. However, if the operator is something more complex than straight equality—for example, if you are comparing the two values using the
compare()
function with a non-default collation—then the only way to achieve the effect within XPath is to use a
some
or
every
expression.

Errors in
some
and
every
Expressions

Dynamic (runtime) errors can occur in
some
and
every
expressions just as in any other kind of XPath expression, and the rules are the same. But for these expressions the rules have some interesting consequences that are worth exploring.

Let's summarize the rules here:

  • If a dynamic error occurs when evaluating the
    satisfies
    expression, then the
    some
    or
    every
    expression as a whole fails with an error.
  • As soon as the system finds an item in the sequence for which the
    satisfies
    expression is true (in the case of
    some
    ) or false (in the case of
    every
    ), it can stop the evaluation. It doesn't need to look any further. This means that it might not notice errors that would be found if it carried on to the bitter end.
  • The system can process the input sequence in any order that it likes. This means that if there is one item for which evaluating the
    satisfies
    expression returns
    true
    , and another for which it raises an error, then you can't tell whether the
    some
    expression will return
    true
    or raise the error.

Other books

What Not to Were by Dakota Cassidy
Mirrored by Alex Flinn
The Challenging Heights by Max Hennessy
Ultimatum by Simon Kernick
Pride's Harvest by Jon Cleary
Mourn Not Your Dead by Deborah Crombie
Escape 1: Escape From Aliens by T. Jackson King
Highbinders by Ross Thomas
Darkmoor by Victoria Barry