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

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

The Syntax of Patterns

The rest of this chapter gives the detailed syntax rules for patterns.

The indented hierarchy that follows shows the overall structure of the rules. Constructs marked with the symbol § are defined in the XPath grammar, specifically in Chapter 7.

    Pattern

       PathPattern

          RelativePathPattern

             PatternStep

                PatternAxis

                NodeTest

                Predicates

                   Expr §

          IdKeyPattern

             Literal §

             VariableReference §

The rules are presented in top-down order, starting with the
Pattern
construct itself.

The production rules use the same syntax notation that is used to define the syntax of XPath expressions as described in Chapter 7. The entry for each construct defines the syntax using a BNF notation, it describes the meaning of the construct in a section headed
Effect
and then includes sections relating to the
Usage
of the construct, followed by
Examples
. The BNF uses chevrons to enclose literal symbols but is otherwise conventional: alternatives are indicated using
|
, repetition by
*
, and optional constructs by
?

Pattern

This is the top-level construct for the XSLT Pattern syntax. A pattern defines a condition that is either true or false for any given node in a document. The syntax for a
Pattern
is a subset of the syntax for a
UnionExpr
(and therefore for an
Expr
) in the XPath expression syntax.

Syntax

Expression
Syntax
Pattern
PathPattern |
Pattern
|
PathPattern

A
Pattern
is either a
PathPattern
or a sequence of
PathPatterns
separated by the union operator
|
.

The syntax of a
PathPattern
is given in the next section.

Effect

A node matches a
Pattern
if it matches any of the
PathPatterns
contained in the
Pattern
.

Usage

Although
|
is technically a union operator, it is simpler to read it as
or
—a node matches the pattern
A|B
if it matches either A or B or both.

Other books

Found Objects by Michael Boehm
Thin Air by Kate Thompson
THE BRIDGE by CAROL ERICSON
Train Tracks by Michael Savage
What Are You Hungry For? by Deepak Chopra
Nightmare by Steven Harper