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

Dark Screams, Volume 1 by Brian James Freeman
The Fall of Tartarus by Eric Brown
A Cruise to Die For (An Alix London Mystery) by Elkins, Aaron, Elkins, Charlotte
Harkham's Corner (Harkham's Series Book 3) by Lowell, Chanse, Marti, Lynch
Dark Night by Stefany Rattles
Trinity Blacio by Embracing the Winds
Gate Wide Open by M. T. Pope
Scraps & Chum by Ryan C. Thomas