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

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

Because a
Step
in a path expression is now a general expression (see Chapter 9), it becomes possible in XPath 2.0 to use parentheses in a path expression such as
book/(chapter|appendix)/title
.

Context Item Expressions

The
ContextItemExp
r
is simply the expression
.
:

Expression
Syntax
ContextItemExpr
.

The context item may either be a node or an atomic value, or its value may be undefined. If the value is undefined, then evaluating the expression
.
causes an error.

At the outermost level of an XPath expression, the value of the context item is established by the calling environment. For example, in XSLT it is determined by the innermost

or

iteration. Where XPath expressions are evaluated from a host language such as Java or C#, the calling API often provides the application with a way to set the initial context item.

Internally within an XPath expression, there are two constructs that change the context item. Within a predicate
P
of an expression such as
$SEQ[P]
, the predicate is evaluated for each item in
$SEQ
in turn, with that item as the context item, and on the right-hand side of the
/
operator, in a path expression such as
E1/E2
, the context item for evaluating
E2
is set to each item in
E1
in turn.

Other books

My Name Is Parvana by Deborah Ellis
Nomad by Matthew Mather
The Shadow Patrol by Alex Berenson
Legion by Dan Abnett
Leaving Lancaster by Kate Lloyd
Anna on the Farm by Mary Downing Hahn, Diane de Groat
Sanctuary by David Lewis
Toward Night's End by Sargent, M.H.
Codename Spring by Aubrey Ross