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
13.59Mb 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

Aurelius and I by Benjamin James Barnard
The Beast of the Camargue by Xavier-Marie Bonnot
Girl's by Darla Phelps
Leave the Last Page by Stephen Barnard
1618686836 (F) by Dawn Peers
Africa39 by Wole Soyinka
A Ship for The King by Richard Woodman
The Oak Island Mystery by Lionel & Patricia Fanthorpe
What I Know For Sure by Oprah Winfrey