2 <!DOCTYPE xsl:stylesheet [
<!ENTITY % xsldoc.ent SYSTEM
"./xsldoc.ent"> %xsldoc.ent; ]
>
3 <!--#############################################################################
4 | $Id: glossary.mod.xsl,v 1.16 2004/01/26 08:58:10 j-devenish Exp $
5 |- #############################################################################
6 | $Author: j-devenish $
7 + ############################################################################## -->
10 xmlns:
xsl=
"http://www.w3.org/1999/XSL/Transform"
11 xmlns:
doc=
"http://nwalsh.com/xsl/documentation/1.0"
12 exclude-result-prefixes=
"doc" version='
1.0'
>
14 <doc:reference id=
"glossary" xmlns=
"">
16 <releaseinfo role=
"meta">
17 $Id: glossary.mod.xsl,v
1.16 2004/
01/
26 08:
58:
10 j-devenish Exp $
24 <year>2000</year><year>2001</year><year>2002</year><year>2003</year><year>2004</year>
25 <holder>Ramon Casellas
</holder>
28 <doc:revision rcasver=
"1.12">&rev_2003_05;</doc:revision>
31 <title>Glossaries
<filename>glossary.mod.xsl
</filename></title>
35 Although
&LaTeX; provides some glossary support, the better glossary
36 management support motivates the bypass of the
&LaTeX;
37 <function condition=
"latex">makeglossary
</function> command.
43 <doc:template xmlns=
"">
44 <refpurpose>Process
<doc:db>glossary
</doc:db> elements
</refpurpose>
48 The
<doc:db>glossary
</doc:db> element is the entry point to a
49 &DocBook; glossary. The
&DB2LaTeX; processing of the element is
50 quite straight- forward. First thing is to check whether the
51 document is a
<doc:db>book
</doc:db> or
<doc:db>article
</doc:db>. In
52 both cases, two new
&LaTeX; commands are defined:
<function
53 condition=
"latex">dbglossary
</function> and
<function
54 condition=
"latex">dbglossdiv
</function>. In the former case, they
55 are mapped to
<function condition=
"latex">chapter*
</function> and
56 <function condition=
"latex">section*
</function>. In the second case
57 to
<function condition=
"latex">section*
</function> and
<function
58 condition=
"latex">subsection*
</function>. The
<function
59 condition=
"env">description
</function> environment is used for
60 <doc:db basename=
"glossentry">glossentries
</doc:db>.
69 <listitem><para>Call template map.begin.
</para></listitem>
70 <listitem><para>Apply Templates for Preamble, GlossDivs and GlossEntries (serial).
</para></listitem>
71 <listitem><para>Call template map.end.
</para></listitem>
76 <simplelist type='inline'
>
85 <listitem><simpara>&mapping;</simpara></listitem>
89 <xsl:template match=
"glossary">
90 <xsl:variable name=
"divs" select=
"glossdiv"/>
91 <xsl:variable name=
"entries" select=
"glossentry"/>
92 <xsl:variable name=
"preamble" select=
"node()[not(self::glossaryinfo or self::title or self::subtitle or self::titleabbrev or self::glossdiv or self::glossentry or self::bibliography)]"/>
93 <xsl:call-template name=
"map.begin"/>
95 <xsl:if test="./subtitle"><xsl:apply-templates select="./subtitle" mode="component.title.mode"/> </xsl:if>
97 <xsl:if test=
"$preamble"> <xsl:apply-templates select=
"$preamble"/> </xsl:if>
98 <xsl:if test=
"$divs"> <xsl:apply-templates select=
"$divs"/> </xsl:if>
99 <xsl:if test=
"$entries">
100 <xsl:text>\noindent%
</xsl:text>
101 <xsl:text>\begin{description}
</xsl:text>
102 <xsl:apply-templates select=
"$entries"/>
103 <xsl:text>\end{description}
</xsl:text>
105 <xsl:call-template name=
"map.end"/>
108 <doc:template xmlns=
"">
109 <refpurpose>Process
<doc:db>glossdiv
</doc:db> and
<doc:db>glosslist
</doc:db> elements
</refpurpose>
112 Invokes the mapping templates and applies content templates.
120 <listitem><simpara>&mapping;</simpara></listitem>
121 <listitem><simpara><xref linkend=
"template.content-templates"/></simpara></listitem>
125 <xsl:template match=
"glossdiv|glosslist">
126 <xsl:call-template name=
"map.begin"/>
127 <xsl:call-template name=
"content-templates"/>
128 <xsl:call-template name=
"map.end"/>
132 <doc:template match="glossentry" xmlns="">
133 <refpurpose> Glossary Entry XSL template / entry point </refpurpose>
138 <listitem><para>Apply Templates.</para></listitem>
140 <formalpara><title>Remarks and Bugs</title>
142 <listitem><para>Explicit Templates for <literal>glossentry/glossterm</literal></para></listitem>
143 <listitem><para>Explicit Templates for <literal>glossentry/acronym</literal></para></listitem>
144 <listitem><para>Explicit Templates for <literal>glossentry/abbrev</literal></para></listitem>
145 <listitem><para>Explicit Templates for <literal>glossentry/glossdef</literal></para></listitem>
146 <listitem><para>Explicit Templates for <literal>glossentry/glosssee</literal></para></listitem>
147 <listitem><para>Explicit Templates for <literal>glossentry/glossseealso</literal></para></listitem>
148 <listitem><para>Template for glossentry/revhistory is EMPTY.</para></listitem>
153 <doc:template xmlns=
"">
154 <refpurpose>Process
<doc:db>glossentry
</doc:db> elements
</refpurpose>
157 Simply applies templates.
164 <xsl:template match=
"glossentry">
165 <xsl:apply-templates/>
166 <xsl:text> </xsl:text>
169 <doc:template xmlns=
"">
170 <refpurpose>Process a
<doc:db>glossentry
</doc:db>'s
<doc:db>glossterm
</doc:db> elements
</refpurpose>
173 Creates a
&LaTeX; <function condition=
"latex">item
</function> and
174 a
<function condition=
"latex">hypertarget
</function>, then applies
182 <xsl:template match=
"glossentry/glossterm">
183 <xsl:text>\item[
</xsl:text>
184 <xsl:if test=
"../@id!=''">
185 <xsl:text>\hypertarget{
</xsl:text>
186 <xsl:value-of select=
"../@id"/>
187 <xsl:text>}
</xsl:text>
189 <xsl:text>{
</xsl:text>
190 <xsl:apply-templates/>
191 <xsl:text>}]
</xsl:text>
194 <doc:template basename=
"acronym" xmlns=
"">
195 <refpurpose>Process a
<doc:db>glossentry
</doc:db>'s
<doc:db>acronym
</doc:db> elements
</refpurpose>
198 Format an acronym as part of a glossentry.
206 The
<doc:db>acronym
</doc:db> is formatted as monospaced text
207 and delimited by round brackets. It appears in the
<quote>body
</quote>
208 (e.g.
<doc:db>glossdef
</doc:db>) region of the glossary entry, not
209 as part of the
<doc:db>glossterm
</doc:db>.
212 The delimiters should probably be localised.
216 <xsl:template match=
"glossentry/acronym">
217 <xsl:text> (
</xsl:text> <xsl:call-template name=
"inline.monoseq"/> <xsl:text> )
</xsl:text>
220 <doc:template basename=
"abbrev" xmlns=
"">
221 <refpurpose>Process a
<doc:db>glossentry
</doc:db>'s
<doc:db>abbrev
</doc:db> elements
</refpurpose>
224 Format an abbrev as part of a glossentry.
232 The
<doc:db>abbrev
</doc:db> is delimited by square brackets. It
233 appears in the
<quote>body
</quote> (e.g.
234 <doc:db>glossdef
</doc:db>) region of the glossary entry, not as
235 part of the
<doc:db>glossterm
</doc:db>.
238 The delimiters should probably be localised.
242 <xsl:template match=
"glossentry/abbrev">
243 <xsl:text> [
</xsl:text> <xsl:apply-templates/> <xsl:text> ]
</xsl:text>
246 <doc:template basename=
"revhistory" xmlns=
"">
247 <refpurpose>Process a
<doc:db>glossentry
</doc:db>'s
<doc:db>revhistory
</doc:db> elements
</refpurpose>
250 Currently,
<doc:db basename=
"revhistory">revhistories
</doc:db>
251 are suppressed within
<doc:db basename=
"glossentry">glossentries
</doc:db>.
258 <xsl:template match=
"glossentry/revhistory"/>
260 <doc:template basename=
"glossdef" xmlns=
"">
261 <refpurpose>Process a
<doc:db>glossentry
</doc:db>'s
<doc:db>glossdef
</doc:db> elements
</refpurpose>
271 <xsl:template match=
"glossentry/glossdef">
272 <xsl:text> </xsl:text>
273 <xsl:apply-templates/>
276 <doc:template xmlns=
"">
277 <refpurpose>Process
<doc:db>glossseealso
</doc:db> and
<doc:db>glosssee
</doc:db> elements
</refpurpose>
280 Format a glossary cross-reference.
289 Will call the following gentet templates:
290 <literal>gentext.element.name
</literal>,
291 <literal>gentext.space
</literal>,
292 <literal>gentext.startquote
</literal>,
293 <literal>gentext.endquote
</literal>.
294 It will then output a full stop (
<quote>period
</quote>).
299 If the
<quote>otherterm
</quote> was successfully found, and this
300 element is empty, then the appropriate cross-reference will be
301 generated. This this element is not empty but the otherterm was
302 also found, the behaviour will depend on
<xref
303 linkend=
"param.latex.otherterm.is.preferred"/>.
308 <simplelist type='inline'
>
316 <listitem><simpara><xref linkend=
"param.latex.otherterm.is.preferred"/></simpara></listitem>
320 <xsl:template match=
"glossseealso|glosssee">
321 <xsl:variable name=
"otherterm" select=
"@otherterm"/>
322 <xsl:variable name=
"targets" select=
"key('id',$otherterm)"/>
323 <xsl:variable name=
"target" select=
"$targets[1]"/>
324 <xsl:call-template name=
"gentext.element.name"/>
325 <xsl:call-template name=
"gentext.space"/>
326 <xsl:call-template name=
"gentext.startquote"/>
328 <xsl:when test=
"$otherterm">
329 <xsl:text>\hyperlink{
</xsl:text><xsl:value-of select=
"$otherterm"/>
330 <xsl:text>}{
</xsl:text>
332 <xsl:when test=
"$latex.otherterm.is.preferred=1">
333 <xsl:apply-templates select=
"$target" mode=
"xref"/>
336 <xsl:apply-templates/>
339 <xsl:text>}
</xsl:text>
342 <xsl:apply-templates/>
345 <xsl:call-template name=
"gentext.endquote"/>
346 <xsl:text>.
</xsl:text>
349 <xsl:template match=
"glossentry" mode=
"xref">
350 <xsl:apply-templates select=
"./glossterm" mode=
"xref"/>
353 <xsl:template match=
"glossterm" mode=
"xref">
354 <xsl:apply-templates/>
357 <doc:template xmlns=
"">
358 <refpurpose> Essential preamble for
<filename>glossary.mod.xsl
</filename> support
</refpurpose>
362 Defines the
<function condition=
"env">dbglossary
</function>
372 <listitem><simpara>&preamble;</simpara></listitem>
376 <xsl:template name=
"latex.preamble.essential.glossary">
377 <xsl:if test=
"//glossary">
379 <xsl:when test=
"/book or /part">
380 <xsl:text>\newcommand{\dbglossary}[
1]{\chapter*{#
1}%
</xsl:text>
381 <xsl:text>\markboth{\MakeUppercase{#
1}}{\MakeUppercase{#
1}}}%
</xsl:text>
382 <xsl:text>\newcommand{\dbglossdiv}[
1]{\section*{#
1}}%
</xsl:text>
385 <xsl:text>\newcommand{\dbglossary}[
1]{\section*{#
1}}%
</xsl:text>
386 <xsl:text>\newcommand{\dbglossdiv}[
1]{\subsection*{#
1}}%
</xsl:text>