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
2.97Mb size Format: txt, pdf, ePub
ads

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.
BOOK: XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition
2.97Mb size Format: txt, pdf, ePub
ads

Other books

Ghost Phoenix by Corrina Lawson
The Scent of an Angel by Nancy Springer
To Love a Way of Life by Natalie Hart
B006JIBKIS EBOK by Griffin, H. Terrell
The Garden Intrigue by Lauren Willig
Midnight Blues by Viehl, Lynn