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
11.74Mb size Format: txt, pdf, ePub
ads

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.

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

Other books

Waltz This Way (v1.1) by Dakota Cassidy
Faery Worlds - Six Complete Novels by Tara Maya, Elle Casey, J L Bryan, Anthea Sharp, Jenna Elizabeth Johnson, Alexia Purdy
Mind (Naughty Wishes #3) by Joey W. Hill
Midnight Sex Shop by Grey, T. A.
Spycatcher by Peter Wright
Far Too Tempting by Lauren Blakely
Where the Dark Streets Go by Dorothy Salisbury Davis
Controlled Burn by Delilah Devlin