Name

[2.0] <xsl:output-character>

Defines a symbol and a string that should replace it. This is similar to an XML <!ENTITY> declaration.

Category

Declaration (this is effectively part of the <xsl:character-map> element).

Required Attributes

character

The character to be replaced.

string

The string that replaces the character.

Optional Attributes

None.

Content

None. <xsl:output-character> is an empty element.

Appears in

The <xsl:character-map> element.

Defined in

XSLT section 20, “Serialization.”

Example

We’ll repeat a small section of our example from the description of the <xsl:character-map> element. Here is a stylesheet that replaces two circled number characters (Unicode code points &#2780; and &#2781;) with graphics:

<?xml version="1.0" encoding="utf-8"?>
<!-- character-map2.xsl -->
<xsl:stylesheet version="2.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:output method="html" use-character-maps="circles"/>

  <xsl:character-map name="circles">
    <xsl:output-character character="&#x2780;"
      string="&lt;img src='images/circle1.gif'
      width='28' height='28'/&gt;"/>
    <xsl:output-character character="&#x2781;"
      string="&lt;img src='images/circle2.gif'
      width='28' height='28'/&gt;"/>
  </xsl:character-map> <xsl:template match="char-test"> <html> <head> <title>A test of some special characters</title> </head> <body style="font-family: sans-serif;"> <h1>A test of some special characters</h1> <xsl:apply-templates select="*"/> </body> </html> </xsl:template> <xsl:template match="special-char"> <p ...

Get XSLT, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.