Name
[2.0] <xsl:character-map>
Defines a set of characters, each of which should be
replaced by a string of characters. This allows you to put nonstandard
characters in the values of elements and attributes. An <xsl:character-map> works much like an
XML <!ENTITY> declaration.
Use a <xsl:character-map> in
place of the disable-output-escaping attributes of
<xsl:text> and <xsl:value-of> defined in XSLT 1.0.
(Using the disable-output-escaping
attribute is deprecated in XSLT 2.0.)
Category
Declaration.
Required Attribute
nameThe name of this character map.
Optional Attribute
use-character-mapsThe space-separated names of any character maps included in this character map. As you would expect, it is a fatal error if a character map includes itself, directly or indirectly. It is also a fatal error if a character map attempts to include a character map that does not exist.
Content
Zero or more <xsl:output-character>
elements.
Appears in
<xsl:character-map>
appears as a child of the <xsl:stylesheet> element.
Defined in
XSLT section 20, “Serialization.”
Example
We’ll define a simple example that has a couple of useful
functions. First of all, we’ll create a character mapping that
replaces tab characters (	)
with two spaces; tab characters are often displayed as eight
characters wide, which can cause problems when displaying indented
code listings. We’ll also create a couple of graphics that should be
displayed in place of certain characters. Here’s the XML source we’ll
use:
<?xml version="1.0" encoding="utf-8"?> ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access