summaryrefslogtreecommitdiff
path: root/docs/docbook/xslt/db2latex/glossary.mod.xsl
blob: f429187aee0e5091771a5bf78a9eb10f78b4cd91 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
<?xml version='1.0'?>
<!--############################################################################# 
|- #############################################################################
|														
|   PURPOSE:
+ ############################################################################## -->

<xsl:stylesheet 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"
    exclude-result-prefixes="doc" version='1.0'>



    <!--############################################################################# -->
    <!-- DOCUMENTATION                                                                -->
    <doc:reference id="glossary" xmlns="">
	<referenceinfo>
	    <releaseinfo role="meta">
	    </releaseinfo>
	<authorgroup>
	    <author> <firstname>Ramon</firstname> <surname>Casellas</surname> </author>
	    <author> <firstname>James</firstname> <surname>Devenish</surname> </author>
	</authorgroup>
	    <copyright>
		<year>2000</year> <year>2001</year> <year>2002</year> <year>2003</year>
		<holder>Ramon Casellas</holder>
	    </copyright>
	</referenceinfo>
	<title>Glossary <filename>glossary.mod.xsl</filename></title>
	<partintro>
	    <section><title>Introduction</title>
		<para>This reference applies to the glossary element name. Altough LaTeX
		    provides some glossary support, the better glossary management support
		    motivates the bypass of the LaTeX <literal>\makeglossary</literal>
		    command.</para>
	    </section>
	</partintro>
    </doc:reference>
    <!--############################################################################# -->


    <!--############################################################################# -->
    <!-- DOCUMENTATION                                                                -->
    <doc:template match="glossary" xmlns="">
	<refpurpose> Glossary XSL template / entry point  </refpurpose>
	<refdescription><para>The <sgmltag>glossary</sgmltag> element is the entry point
		to a docbook glossary. The DB2LaTeX processing of the element is quite straight-
		forward. First thing is to check whether the document is a book or article. In 
		both cases two new LaTeX commands are defined. <literal>\dbglossary</literal>
		and <literal>\dbglossdiv</literal>. In the former case, they are mapped to 
		<literal>\chapter*</literal> and <literal>\section*</literal>. In the second
		case to <literal>\section*</literal> and <literal>\subsection*</literal>.</para>
	</refdescription>
	<itemizedlist>
	    <listitem><para>Call template map.begin.</para></listitem>
	    <listitem><para>Apply Templates for Preamble, GlossDivs and GlossEntries (serial).</para></listitem>
	    <listitem><para>Call template map.end.</para></listitem>
	</itemizedlist>
	<formalpara><title>Remarks and Bugs</title>
	    <itemizedlist>
		<listitem><para>Template for glossary/glossaryinfo is EMPTY.</para></listitem>
		<listitem><para>Template for glossary/title | glossary/subtitle is EMPTY.</para></listitem>
		<listitem><para>Template for glossary/titleabbrev is EMPTY.</para></listitem>
	    </itemizedlist>
	</formalpara>
    </doc:template>
    <!--############################################################################# -->

    <xsl:template match="glossary">
	<xsl:variable name="divs" select="glossdiv"/>
	<xsl:variable name="entries" select="glossentry"/>
	<xsl:variable name="preamble" select="*[not(self::title or self::subtitle or self::glossdiv or self::glossentry)]"/>
	<xsl:choose>
	    <xsl:when test="local-name(..)='book' or local-name(..)='part'">
		<xsl:text>\newcommand{\dbglossary}[1]{\chapter*{#1}}%&#10;</xsl:text>
		<xsl:text>\newcommand{\dbglossdiv}[1]{\section*{#1}}%&#10;</xsl:text>
	    </xsl:when>
	    <xsl:otherwise>
		<xsl:text>\newcommand{\dbglossary}[1]{\section*{#1}}%&#10;</xsl:text>
		<xsl:text>\newcommand{\dbglossdiv}[1]{\subsection*{#1}}%&#10;</xsl:text>
	    </xsl:otherwise>
	</xsl:choose>
	<xsl:call-template name="map.begin"/>
	<xsl:if test="./subtitle"><xsl:apply-templates select="./subtitle" mode="component.title.mode"/> </xsl:if>
	<xsl:if test="$preamble"> <xsl:apply-templates select="$preamble"/> </xsl:if>
	<xsl:if test="$divs"> <xsl:apply-templates select="$divs"/> </xsl:if>
	<xsl:if test="$entries"> <xsl:apply-templates select="$entries"/></xsl:if>
	<xsl:call-template name="map.end"/>
    </xsl:template>

    <xsl:template match="glossary/glossaryinfo"/>
    <xsl:template match="glossary/title"/>
    <xsl:template match="glossary/subtitle"/>
    <xsl:template match="glossary/titleabbrev"/>
    <xsl:template match="glossary/title" 	mode="component.title.mode"> <xsl:apply-templates/> </xsl:template>
    <xsl:template match="glossary/subtitle" 	mode="component.title.mode"> <xsl:apply-templates/> </xsl:template>




    <!--############################################################################# -->
    <!-- DOCUMENTATION                                                                -->
    <doc:template match="glossdiv|glosslist" xmlns="">
	<refpurpose> Glossary Division and Glossary Lists XSL templates.  </refpurpose>
	<refdescription><para>T.B.D</para>
	</refdescription>
	<itemizedlist>
	    <listitem><para>Call template map.begin.</para></listitem>
	    <listitem><para>Apply Templates.</para></listitem>
	    <listitem><para>Call template map.end.</para></listitem>
	</itemizedlist>
	<formalpara><title>Remarks and Bugs</title>
	    <itemizedlist>
		<listitem><para>Template for glossdiv/glossaryinfo is EMPTY.</para></listitem>
	    </itemizedlist>
	</formalpara>
    </doc:template>
    <!--############################################################################# -->
    <xsl:template match="glossdiv|glosslist">
	<xsl:call-template name="map.begin"/>
	<xsl:apply-templates/>
	<xsl:call-template name="map.end"/>
    </xsl:template>

    <xsl:template match="glossdiv/title" />




    <!--############################################################################# -->
    <!-- DOCUMENTATION                                                                -->
    <doc:template match="glossentry" xmlns="">
	<refpurpose> Glossary Entry XSL template / entry point  </refpurpose>
	<refdescription>
	    <para>T.B.D.</para>
	</refdescription>
	<itemizedlist>
	    <listitem><para>Apply Templates.</para></listitem>
	</itemizedlist>
	<formalpara><title>Remarks and Bugs</title>
	    <itemizedlist>
		<listitem><para>Explicit Templates for <literal>glossentry/glossterm</literal></para></listitem>
		<listitem><para>Explicit Templates for <literal>glossentry/acronym</literal></para></listitem>
		<listitem><para>Explicit Templates for <literal>glossentry/abbrev</literal></para></listitem>
		<listitem><para>Explicit Templates for <literal>glossentry/glossdef</literal></para></listitem>
		<listitem><para>Explicit Templates for <literal>glossentry/glosssee</literal></para></listitem>
		<listitem><para>Explicit Templates for <literal>glossentry/glossseealso</literal></para></listitem>
		<listitem><para>Template for glossentry/revhistory is EMPTY.</para></listitem>
	    </itemizedlist>
	</formalpara>
    </doc:template>
    <!--############################################################################# -->


    <xsl:template match="glossentry">
	<xsl:apply-templates/>
	<xsl:text>&#10;&#10;</xsl:text>
    </xsl:template>

    <xsl:template match="glossentry/glossterm">
	<xsl:text>\item[</xsl:text>
	<xsl:if test="../@id!=''">
		<xsl:text>\hypertarget{</xsl:text>
		<xsl:value-of select="../@id"/>
		<xsl:text>}</xsl:text>
	</xsl:if>
	<xsl:text>{</xsl:text>
	<xsl:call-template name="normalize-scape">
	    <xsl:with-param name="string" select="."/>
	</xsl:call-template>
	<xsl:text>}] </xsl:text>
    </xsl:template>

    <xsl:template match="glossentry/acronym">
	<xsl:text> ( \texttt {</xsl:text> <xsl:apply-templates/> <xsl:text>} ) </xsl:text>
    </xsl:template>

    <xsl:template match="glossentry/abbrev">
	<xsl:text> [ </xsl:text> <xsl:apply-templates/> <xsl:text> ] </xsl:text> 
    </xsl:template>

    <xsl:template match="glossentry/revhistory"/>

    <xsl:template match="glossentry/glossdef">
	<xsl:text>&#10;</xsl:text>
	<xsl:apply-templates/>
    </xsl:template>

    <xsl:template match="glossseealso|glossentry/glosssee">
	<xsl:variable name="otherterm" select="@otherterm"/>
	<xsl:variable name="targets" select="//node()[@id=$otherterm]"/>
	<xsl:variable name="target" select="$targets[1]"/>
	<xsl:call-template name="gentext.element.name"/>
	<xsl:call-template name="gentext.space"/>
	<xsl:call-template name="gentext.startquote"/>
	<xsl:choose>
	    <xsl:when test="@otherterm">
		<xsl:text>\hyperlink{</xsl:text><xsl:value-of select="@otherterm"/>
		<xsl:text>}{</xsl:text><xsl:apply-templates select="$target" mode="xref"/><xsl:text>}</xsl:text>
	    </xsl:when>
	    <xsl:otherwise>
		<xsl:apply-templates/>
	    </xsl:otherwise>
	</xsl:choose>
	<xsl:call-template name="gentext.endquote"/>
	<xsl:text>. </xsl:text>
    </xsl:template>

    <xsl:template match="glossentry" mode="xref">
	<xsl:apply-templates select="./glossterm" mode="xref"/>
    </xsl:template>

    <xsl:template match="glossterm" mode="xref">
	<xsl:apply-templates/>
    </xsl:template>

</xsl:stylesheet>