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

Other books

Dakota Dusk by Lauraine Snelling
The First Last Kiss by Ali Harris
Hrolf Kraki's Saga by Poul Anderson
Dreams Bigger Than the Night by Levitt, Paul M.
Lightning Kissed by Lila Felix
The Kissing Game by Marie Turner
Chasing the Secret by Maya Snow