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

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

Warning: The
regex
attribute is an attribute value template. This makes it possible to construct the regex at runtime, using an XPath expression. For example, the regex can be supplied as a stylesheet parameter. The downside of this is that curly braces within the attribute value must be doubled if they are to be treated as part of the regex, rather than having their special meaning for attribute value templates. For example, to match a sequence of three digits, write
regex=“[0-9]{{3}}”
.

The
flags
attribute controls how the regex is to be interpreted. Four flags are defined, each denoted by a single letter, and they can be written in any order. Like the
regex
attribute,
flags
may be written as an attribute value template. The meaning of the flags is defined in detail in Chapter 14 and is summarized below.

Flag
Meaning
i
Selects case-insensitive mode. In simple terms, this means that
X
and
x
will match each other.
m
Selects multiline mode. In this mode, the metacharacters

and
$
match the beginning and end of each line; otherwise, they match the beginning and end of the entire string.
s
Selects dot-all mode. In this mode the metacharacter
.
matches any character, whereas normally it matches any character except a newline (x0A).
x
Allows whitespace to be used as an insignificant separator within the regex.

Content

Either an

element or an

element, or one of each in that order. Followed by zero or more

elements.

An XSLT 2.0 processor will ignore any

instructions; they are allowed so that a stylesheet can specify fallback actions to be taken by an XSLT 1.0 processor when it encounters this element, if it is working in forward-compatible mode.

The elements

and

take no attributes, and their content is in each case a sequence constructor.

Effect

The XPath expression given in the
select
attribute is evaluated and provides the input string to be matched by the regex. A type error occurs if the value of this expression can't be converted to a string using the standard conversion rules described on page 505.

Other books

The Speckled People by Hugo Hamilton
This River Awakens by Erikson, Steven
To Have and to Hold by Rebecca King
Undying by Woodham, Kenneth
Plain Fame by Sarah Price
On Christmas Hill by Nichole Chase
Lady Killer by Michele Jaffe
The Guardian by Bill Eidson
Hav by Jan Morris
Keeping Faith by T.J. Vertigo