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

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

If backward-compatibility mode is in use (that is, if
version = “1.0”
is specified), then all strings after the first in the sequence are discarded; only the first string is included in the output. See the section
Version Compatibility
on page 128 for details.

For example, suppose you have a set of images representing an alphabet such as the following, and you want to use these to represent the first character of a paragraph of text.

You could write a template rule to achieve this as follows (ignoring practical details such as how to deal with paragraphs that don't start with a capital letter). It uses the
substring()
function, which is described in Chapter 13.


   


   



A paragraph that starts with the letter A (like this one) will cause the
src
attribute of the

element to be evaluated as
img src = “fancyA.gif”
, so it will be displayed in the browser as shown in
Figure 3-5
.

If you want to include the characters
{
or
}
in an attribute value with their ordinary meaning, they should be doubled as
{{
or
}}
. This is sometimes necessary when generating dynamic HTML, and it also happens often with the
regex
attribute of the

instruction, whose value is a regular expression. However, you should do this only in an attribute that is being interpreted as an attribute value template. In other attributes, curly braces have no special meaning.

Other books

Blood and Circuses by Kerry Greenwood
Captives by Edward W. Robertson
The Small Miracle by Paul Gallico
Oliver's Twist by Craig Oliver
Flood by Andrew Vachss
Probed: The Encounter by Alexis Adaire
Lover's Gold by Kat Martin
Giraffe by J. M. Ledgard
Line of Scrimmage by Marie Force