3 <reference xml:id="charmap">
5 <title>Common » Character-Map Template Reference</title>
6 <releaseinfo role="meta">
7 $Id: charmap.xsl 7266 2007-08-22 11:58:42Z xmldoc $
11 <partintro xml:id="partintro">
12 <title>Introduction</title>
14 <para>This is technical reference documentation for the
15 character-map templates in the DocBook XSL Stylesheets.</para>
19 <para>These templates are defined in a separate file from the set
20 of “common” templates because some of the common templates
21 reference DocBook XSL stylesheet parameters, requiring the
22 entire set of parameters to be imported/included in any
23 stylesheet that imports/includes the common templates.</para>
26 <para>The character-map templates don’t import or include
27 any DocBook XSL stylesheet parameters, so the
28 character-map templates can be used without importing the
29 whole set of parameters.</para>
33 <para>This is not intended to be user documentation. It is
34 provided for developers writing customization layers for the
39 <refentry xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="template.apply-character-map">
41 <refname>apply-character-map</refname>
42 <refpurpose>Applies an XSLT character map</refpurpose>
45 <synopsis><xsl:template name="apply-character-map">
46 <xsl:param name="content"/>
47 <xsl:param name="map.contents"/>
49 </xsl:template></synopsis>
51 <refsect1><title>Description</title>
53 <para>This template applies an <link xlink:href="http://www.w3.org/TR/xslt20/#character-maps">XSLT character map</link>; that is, it causes certain
54 individual characters to be substituted with strings of one
55 or more characters. It is useful mainly for replacing
56 multiple “special” characters or symbols in the same target
57 content. It uses the value of
58 <parameter>map.contents</parameter> to do substitution on
59 <parameter>content</parameter>, and then returns the
60 modified contents.</para>
64 <para>This template is a very slightly modified version of
65 Jeni Tennison’s <function>replace_strings</function>
66 template in the <link xlink:href="http://www.dpawson.co.uk/xsl/sect2/StringReplace.html#d9351e13">multiple string replacements</link> section of Dave Pawson’s
67 <link xlink:href="http://www.dpawson.co.uk/xsl/index.html">XSLT FAQ</link>.</para>
70 <para>The <function>apply-string-subst-map</function>
71 template is essentially the same template as the
72 <function>apply-character-map</function> template; the
73 only difference is that in the map that
74 <function>apply-string-subst-map</function> expects, <tag class="attribute">oldstring</tag> and <tag class="attribute">newstring</tag> attributes are used
75 instead of <tag class="attribute">character</tag> and <tag class="attribute">string</tag> attributes.</para>
78 </refsect1><refsect1><title>Parameters</title>
81 <varlistentry><term>content</term>
84 <para>The content on which to perform the character-map
89 <varlistentry><term>map.contents</term>
92 <para>A node set of elements, with each element having
93 the following attributes:
97 <simpara><tag class="attribute">character</tag>, a
98 character to be replaced</simpara>
101 <simpara><tag class="attribute">string</tag>, a
102 string with which to replace <tag class="attribute">character</tag></simpara>
112 </refsect1></refentry>
114 <refentry xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="template.read-character-map">
116 <refname>read-character-map</refname>
117 <refpurpose>Reads in all or part of an XSLT character map</refpurpose>
120 <synopsis><xsl:template name="read-character-map">
121 <xsl:param name="use.subset"/>
122 <xsl:param name="subset.profile"/>
123 <xsl:param name="uri"/>
125 </xsl:template></synopsis>
127 <refsect1><title>Description</title>
129 <para>The XSLT 2.0 specification describes <link xlink:href="http://www.w3.org/TR/xslt20/#character-maps">character maps</link> and explains how they may be used
130 to allow a specific character appearing in a text or
131 attribute node in a final result tree to be substituted by
132 a specified string of characters during serialization. The
133 <function>read-character-map</function> template provides a
134 means for reading and using character maps with XSLT
135 1.0-based tools.</para>
138 <para>This template reads the character-map contents from
139 <parameter>uri</parameter> (in full or in part, depending on
140 the value of the <parameter>use.subset</parameter>
141 parameter), then passes those contents to the
142 <function>apply-character-map</function> template, along with
143 <parameter>content</parameter>, the data on which to perform
144 the character substitution.</para>
147 <para>Using the character map “in part” means that it uses only
148 those <tag>output-character</tag> elements that match the
149 XPath expression given in the value of the
150 <parameter>subset.profile</parameter> parameter. The current
151 implementation of that capability here relies on the
152 <function>evaluate</function> extension XSLT function.</para>
154 </refsect1><refsect1><title>Parameters</title>
157 <varlistentry><term>use.subset</term>
160 <para>Specifies whether to use a subset of the character
161 map instead of the whole map; boolean
162 <literal>0</literal> or <literal>1</literal></para>
166 <varlistentry><term>subset.profile</term>
169 <para>XPath expression that specifies what subset of the
170 character map to use</para>
174 <varlistentry><term>uri</term>
177 <para>URI for a character map</para>
183 </refsect1></refentry>