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

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

I'll cover the
,
operator (which concatenates two sequences), together with the
ForExpr
and the
QuantifiedExpr
in Chapter 10, which is all about expressions on sequences. The
IfExpr
(which allows you to write conditional
if..then..else
expressions) is covered in this chapter, on page 551, and the
OrExpr
, which allows you to use the boolean
or
operator, and provides the entry point to most of the rest of the XPath syntax, is described in Chapter 8.

The
ExprSingle
construct has a special role in the grammar. Because the
,
symbol is overloaded (it's used both as an operator for concatenating two lists and also as a syntactic delimiter in constructs such as a function call), there are places where you might expect the grammar to allow any
Expr
to appear but where, in fact, only an
ExprSingle
is allowed. This means that if you want to use a
,
operator in such contexts, you have to enclose the expression in parentheses.

The constructs
IfExpr
,
ForExpr
, and
QuantifiedExpr
are syntactically unusual in the XPath grammar because they start with keywords and contain multiple subexpressions. In a conventional language, they would probably be called statements rather than expressions. Nevertheless, they are true expressions, in the sense that they can be evaluated to produce a result, and they can appear anywhere in the grammar where an expression is required.

The
OrExpr
starts a list of productions that contains all the conventional expressions of the language, as follows:

Expression
Syntax
OrExpr
AndExpr (
or
AndExpr )*
AndExpr
ComparisonExpr (
and
ComparisonExpr )*
ComparisonExpr
RangeExpr
( (ValueComp | GeneralComp | NodeComp) RangeExpr )?
RangeExpr
AdditiveExpr (
to
AdditiveExpr )?
AdditiveExpr
MultiplicativeExpr ( (
+
|

) MultiplicativeExpr )*
MultiplicativeExpr
UnionExpr
( (
*
|
div
|
idiv
|
mod
) UnionExpr )*

Other books

The Governess Club: Sara by Ellie Macdonald
River of the Brokenhearted by David Adams Richards
Twitter for Dummies by Laura Fitton, Michael Gruen, Leslie Poston
Ice Games by Jessica Clare
Happy Is The Bride by Caroline Clemmons
Privateer's Apprentice by Susan Verrico
Shattered Dreams by Brenda Kennedy
Vanished by Joseph Finder