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

ChristmasisComing by Shelley Munro
A Touch of Grace by Lauraine Snelling
Cassie by E. L. Todd
Burden by Annmarie McKenna
Arisen, Book Six - The Horizon by Michael Stephen Fuchs, Glynn James
One of Us by Tawni O'Dell
Tangled Up in You by Rachel Gibson