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

An Accidental Tragedy by Roderick Graham
Perfecting Fiona by Beaton, M.C.
Angel Seduced by Jaime Rush
Dance of Demons by Gary Gygax
Unfold Me by Talia Ellison
Dread Nemesis of Mine by John Corwin
The Farming of Bones by Edwidge Danticat
Further Than Passion by Cheryl Holt
Triplanetary by E. E. (Doc) Smith