Read XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition Online
Authors: Michael Kay
See Also
xsl:character-map
The
Changes in 2.0
Character maps are a new feature in XSLT 2.0, designed as a replacement for
disable-output- escaping
, which is now deprecated.
Format
name = qname
use-character-maps? = qnames>
Position
Attributes
Name | Value | Meaning |
name mandatory | Lexical QName | The name of this character map |
use-character-maps optional | Whitespace-separated list of lexical QNames | The names of other character maps to be incorporated into this character map |
Content
Zero or more
Effect
The
name
attribute is mandatory, and defines the name of the character map. It must be a lexical QName: a name with or without a namespace prefix. If the name uses a prefix, it must refer to a namespace declaration that is in scope at this point in the stylesheet, and as usual it is the namespace URI rather than the prefix that is used when matching names. If several character maps in the stylesheet have the same name, then the one with highest import precedence is used; an error is reported if this rule does not identify a character map uniquely. Import precedence is explained on page 359.
The character map contains zero or more
indicates that the nonbreaking space character (Unicode codepoint 160) is to be represented on output by the string
. This illustrates one of the possible uses of character maps, which is to render specific characters using XML or HTML entity references.
The
use-character-maps
attribute is optional. It is used to build up one character map from a number of others. If present, its value must be a whitespace-separated list of tokens, each of which is a valid
QName
that refers to another named character map in the stylesheet. For example:
…
…
use-character-maps=“NBSP
latin-1-symbols
latin-1-accented-characters”/>
This example creates a composite character map called
latin-1-entities
that is effectively the union of three underlying character maps. The effect in this case is as if all the
The rules for merging character maps are as follows. Firstly, there must be no circularities (a character map must not reference itself, directly or indirectly). The
expanded content
of a character map can then be defined (recursively) as the concatenation of the expanded content of each of the character maps referenced in its
use-character-maps
attribute, in the order in which they are named, followed by the
Usage and Examples
Character maps have no effect on the XSLT transformation proper; they only affect the way that the result tree is serialized. If the result tree is used in some way other than passing it to a serializer (for example, if it is input to another transformation in a pipeline), then character maps have no effect.
For advice on using character maps as part of the serialization process, and worked examples, see Chapter 15
Serialization
.
See Also
Character Maps
in Chapter 15, page 941
xsl:choose
The
If there are two alternatives it performs the equivalent of
if-then-else
in other languages; if there are more than two, it performs the equivalent of a
switch
or
select
statement.
Changes in 2.0
There are no changes to the syntax of
In many situations where
if
-
then
-
else
) instead, which can sometimes make the code much more compact.
Format
Position
Attributes
None.
Content
One or more
Optionally, an
Effect
The
The
test
expression in
Usage
The
if
-
then
-
else
and
switch
or
Select
Case
constructs found in other programming languages.
Using
else
branch after all.
When