2
<!DOCTYPE xsl:stylesheet [ <!ENTITY % xsldoc.ent SYSTEM "./xsldoc.ent"> %xsldoc.ent; ]>
3
<!--#############################################################################
4
| $Id: latex.mapping.xsl,v 1.18 2004/01/14 14:54:32 j-devenish Exp $
5
|- #############################################################################
6
| $Author: j-devenish $
9
+ ############################################################################## -->
12
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
13
xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"
14
exclude-result-prefixes="doc" version='1.0'>
16
<!--############################################################################# -->
17
<!-- DOCUMENTATION -->
18
<doc:reference id="latex.mapping" xmlns="">
20
<releaseinfo role="meta">
21
$Id: latex.mapping.xsl,v 1.18 2004/01/14 14:54:32 j-devenish Exp $
27
<year>2000</year> <year>2001</year> <year>2002</year> <year>2003</year>
28
<holder>Ramon Casellas</holder>
31
<doc:revision rcasver="1.11">&rev_2003_05;</doc:revision>
34
<title>The &DB2LaTeX; mapping system <filename>latex.mapping.xsl</filename></title>
36
<section><title>Introduction</title>
37
<para>The &DB2LaTeX; mapping system centralises the mapping
38
of &DocBook; tags (e.g. <doc:db>chapter</doc:db>)
39
to &LaTeX; commands (e.g. <function condition="latex">chapter</function>).
40
It uses an auxiliary file, <filename>latex.mapping.xml</filename>,
41
to define the start and end of each mapping.
42
You can override this <quote>mapping file</quote>
43
in order to customise &DB2LaTeX;.</para>
47
<!--############################################################################# -->
49
<doc:param name="latex.mapping.xml">
50
<refpurpose>The primary mapping file</refpurpose>
53
&DB2LaTeX; will search for mappings in this file.
54
The value of this variable must be an XML document.
55
If mappings cannot be found in this file, &DB2LaTeX; will
56
search the <link linkend="param.latex.mapping.xml.default">default mapping file</link>.
60
<simplelist type='inline'>
65
<xsl:param name="latex.mapping.xml" select="document('latex.mapping.xml')"/>
67
<doc:param name="latex.mapping.xml.default">
68
<refpurpose>The default mapping file</refpurpose>
71
Defines the mapping file that &DB2LaTeX; will search
72
when it cannot find a template in the
73
<link linkend="param.latex.mapping.xml">primary mapping file</link>.
74
The value of this variable must be an XML document.
78
<xsl:param name="latex.mapping.xml.default" select="document('latex.mapping.xml')"/>
80
<doc:template xmlns="">
81
<refpurpose>Perform &DocBook; to &LaTeX; mapping</refpurpose>
92
<listitem><simpara><xref linkend="param.latex.mapping.xml"/></simpara></listitem>
93
<listitem><simpara><xref linkend="param.latex.mapping.xml.default"/></simpara></listitem>
97
<xsl:template name="latex.mapping">
98
<xsl:param name="object" select="."/>
99
<xsl:param name="keyword" select="local-name($object)"/>
100
<xsl:param name="role" select="begin"/>
101
<xsl:param name="string">
102
<xsl:call-template name="extract.object.title">
103
<xsl:with-param name="object" select="$object"/>
106
<xsl:variable name="id">
107
<xsl:call-template name="generate.label.id">
108
<xsl:with-param name="object" select="$object"/>
111
<xsl:variable name="title">
113
<xsl:when test="starts-with(local-name($object),'informal')">
114
<xsl:if test="$string!=''">
115
<xsl:message>Ignoring title for <xsl:value-of select="local-name($object)"/>.</xsl:message>
118
<xsl:when test="$string=''">
119
<xsl:call-template name="gentext.element.name"/>
122
<xsl:value-of select="normalize-space($string)"/>
126
<xsl:variable name="local.mapping" select="$latex.mapping.xml/latexbindings/latexmapping[@role=$role]/mapping[@key=$keyword]"/>
127
<xsl:variable name="default.mapping" select="$latex.mapping.xml.default/latexbindings/latexmapping[@role=$role]/mapping[@key=$keyword]"/>
130
<xsl:when test="$local.mapping and ($local.mapping/@text!='' or not($local.mapping/line))">
131
<xsl:call-template name="string-replace">
132
<xsl:with-param name="to"><xsl:value-of select="$id"/></xsl:with-param>
133
<xsl:with-param name="from">%id%</xsl:with-param>
134
<xsl:with-param name="string">
135
<xsl:call-template name="string-replace">
136
<xsl:with-param name="to"><xsl:value-of select="$title"/></xsl:with-param>
137
<xsl:with-param name="from">%title%</xsl:with-param>
138
<xsl:with-param name="string">
139
<xsl:value-of select="$local.mapping/@text"/>
146
<xsl:when test="$local.mapping/line">
147
<xsl:for-each select="$local.mapping/line">
148
<xsl:call-template name="string-replace">
149
<xsl:with-param name="to"><xsl:value-of select="$id"/></xsl:with-param>
150
<xsl:with-param name="from">%id%</xsl:with-param>
151
<xsl:with-param name="string">
152
<xsl:call-template name="string-replace">
153
<xsl:with-param name="to"><xsl:value-of select="$title"/></xsl:with-param>
154
<xsl:with-param name="from">%title%</xsl:with-param>
155
<xsl:with-param name="string" select="."/>
162
<xsl:when test="$default.mapping/@text!=''">
163
<xsl:call-template name="string-replace">
164
<xsl:with-param name="to"><xsl:value-of select="$id"/></xsl:with-param>
165
<xsl:with-param name="from">%id%</xsl:with-param>
166
<xsl:with-param name="string">
167
<xsl:call-template name="string-replace">
168
<xsl:with-param name="to"><xsl:value-of select="$title"/></xsl:with-param>
169
<xsl:with-param name="from">%title%</xsl:with-param>
170
<xsl:with-param name="string">
171
<xsl:value-of select="$default.mapping/@text"/>
178
<xsl:when test="$default.mapping">
179
<xsl:for-each select="$default.mapping/line">
180
<xsl:call-template name="string-replace">
181
<xsl:with-param name="to"><xsl:value-of select="$id"/></xsl:with-param>
182
<xsl:with-param name="from">%id%</xsl:with-param>
183
<xsl:with-param name="string">
184
<xsl:call-template name="string-replace">
185
<xsl:with-param name="to"><xsl:value-of select="$title"/></xsl:with-param>
186
<xsl:with-param name="from">%title%</xsl:with-param>
187
<xsl:with-param name="string" select="."/>
195
<xsl:message terminate="no">
196
<xsl:text>Warning: Unable to find LaTeX mapping for </xsl:text>
197
<xsl:text>KEYWORD:</xsl:text><xsl:value-of select="$keyword"/><xsl:text> </xsl:text>
198
<xsl:text>ROLE:</xsl:text><xsl:value-of select="$role"/><xsl:text> </xsl:text>
207
<xsl:template name="map.begin">
208
<xsl:param name="object" select="."/>
209
<xsl:param name="keyword" select="local-name($object)"/>
210
<xsl:param name="string">
211
<xsl:call-template name="extract.object.title">
212
<xsl:with-param name="object" select="$object"/>
215
<xsl:call-template name="latex.mapping">
216
<xsl:with-param name="keyword" select="$keyword"/>
217
<xsl:with-param name="role">begin</xsl:with-param>
218
<xsl:with-param name="string" select="$string"/>
222
<xsl:template name="map.end">
223
<xsl:param name="object" select="."/>
224
<xsl:param name="keyword" select="local-name($object)"/>
225
<xsl:param name="role" select="begin"/>
226
<xsl:param name="string">
227
<xsl:call-template name="extract.object.title">
228
<xsl:with-param name="object" select="$object"/>
231
<xsl:call-template name="latex.mapping">
232
<xsl:with-param name="keyword" select="$keyword"/>
233
<xsl:with-param name="string" select="$string"/>
234
<xsl:with-param name="role">end</xsl:with-param>
238
<doc:template name="extract.object.title">
239
<refpurpose>Choose a title for an object</refpurpose>
242
Processes the <sgmltag class="element">title</sgmltag> child
243
of the specified object. Uses the context node as the default object.
248
<listitem><simpara><xref linkend="param.latex.apply.title.templates"/></simpara></listitem>
253
<varlistentry><term>object</term><listitem><simpara>The node for which a title is desired.</simpara></listitem></varlistentry>
257
<xsl:template name="extract.object.title">
258
<xsl:param name="object" select="."/>
260
<xsl:when test="$latex.apply.title.templates='1'">
261
<xsl:apply-templates select="$object/title" mode="latex"/>
264
<xsl:call-template name="normalize-scape">
265
<xsl:with-param name="string" select="$object/title"/>
271
<doc:template match="title" mode="latex">
272
<refpurpose>Process <doc:db>title</doc:db> elements</refpurpose>
274
<para>Applies templates with no mode. This template is called by <xref linkend="template.extract.object.title"/>.</para>
275
<para>This differs from the modeless <doc:db>title</doc:db>
276
templates because they suppress the output of titles.</para>
279
<xsl:template match="title" mode="latex"><xsl:apply-templates/></xsl:template>