1<?xml version='1.0'?>
2<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3                version='1.0'>
4
5<!-- ********************************************************************
6     $Id$
7     ********************************************************************
8
9     This file is part of the XSL DocBook Stylesheet distribution.
10     See /README or http://nwalsh.com/docbook/xsl/ for copyright
11     and other information.
12
13     ******************************************************************** -->
14
15<!-- ==================================================================== -->
16
17<xsl:template match="glossary">
18  <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
19
20  <div id="{$id}" class="{name(.)}">
21    <xsl:call-template name="glossary.titlepage"/>
22
23    <xsl:choose>
24      <xsl:when test="glossdiv">
25        <xsl:apply-templates select="(glossdiv[1]/preceding-sibling::*)"/>
26      </xsl:when>
27      <xsl:otherwise>
28        <xsl:apply-templates select="(glossentry[1]/preceding-sibling::*)"/>
29      </xsl:otherwise>
30    </xsl:choose>
31
32    <xsl:choose>
33      <xsl:when test="glossdiv">
34        <xsl:apply-templates select="glossdiv"/>
35      </xsl:when>
36      <xsl:otherwise>
37        <dl>
38          <xsl:apply-templates select="glossentry"/>
39        </dl>
40      </xsl:otherwise>
41    </xsl:choose>
42
43    <xsl:call-template name="process.footnotes"/>
44  </div>
45</xsl:template>
46
47<xsl:template match="glossary/glossaryinfo"></xsl:template>
48<xsl:template match="glossary/title"></xsl:template>
49<xsl:template match="glossary/subtitle"></xsl:template>
50<xsl:template match="glossary/titleabbrev"></xsl:template>
51
52<xsl:template match="glossary/title" mode="component.title.mode">
53  <h2>
54    <xsl:apply-templates/>
55  </h2>
56</xsl:template>
57
58<xsl:template match="glossary/subtitle" mode="component.title.mode">
59  <h3>
60    <i><xsl:apply-templates/></i>
61  </h3>
62</xsl:template>
63
64<!-- ==================================================================== -->
65
66<xsl:template match="glosslist">
67  <div class="{name(.)}">
68    <a>
69      <xsl:attribute name="name">
70        <xsl:call-template name="object.id"/>
71      </xsl:attribute>
72    </a>
73
74    <dl>
75      <xsl:apply-templates/>
76    </dl>
77  </div>
78</xsl:template>
79
80<!-- ==================================================================== -->
81
82<xsl:template match="glossdiv">
83  <div class="{name(.)}">
84    <xsl:apply-templates select="(glossentry[1]/preceding-sibling::*)"/>
85
86    <dl>
87      <xsl:apply-templates select="glossentry"/>
88    </dl>
89  </div>
90</xsl:template>
91
92<xsl:template match="glossdiv/title">
93  <h3 class="{name(.)}">
94    <xsl:apply-templates/>
95  </h3>
96</xsl:template>
97
98<!-- ==================================================================== -->
99
100<!--
101GlossEntry ::=
102  GlossTerm, Acronym?, Abbrev?,
103  (IndexTerm)*,
104  RevHistory?,
105  (GlossSee | GlossDef+)
106-->
107
108<xsl:template match="glossentry">
109  <xsl:apply-templates/>
110</xsl:template>
111
112<xsl:template match="glossentry/glossterm">
113  <dt>
114    <xsl:apply-templates/>
115  </dt>
116</xsl:template>
117
118<xsl:template match="glossentry/glossterm[1]" priority="2">
119  <dt>
120    <a>
121      <xsl:attribute name="name">
122        <xsl:call-template name="object.id">
123           <xsl:with-param name="object" select=".."/>
124        </xsl:call-template>
125      </xsl:attribute>
126
127      <xsl:apply-templates/>
128    </a>
129  </dt>
130</xsl:template>
131
132<xsl:template match="glossentry/acronym">
133</xsl:template>
134
135<xsl:template match="glossentry/abbrev">
136</xsl:template>
137
138<xsl:template match="glossentry/revhistory">
139</xsl:template>
140
141<xsl:template match="glossentry/glosssee">
142  <xsl:variable name="otherterm" select="@otherterm"/>
143  <xsl:variable name="targets" select="//node()[@id=$otherterm]"/>
144  <xsl:variable name="target" select="$targets[1]"/>
145  <dd>
146    <p>
147      <xsl:call-template name="gentext.template">
148        <xsl:with-param name="context" select="'glossary'"/>
149        <xsl:with-param name="name" select="'see'"/>
150      </xsl:call-template>
151      <xsl:choose>
152        <xsl:when test="@otherterm">
153          <a href="#{@otherterm}">
154            <xsl:apply-templates select="$target" mode="xref"/>
155          </a>
156        </xsl:when>
157        <xsl:otherwise>
158          <xsl:apply-templates/>
159        </xsl:otherwise>
160      </xsl:choose>
161      <xsl:text>.</xsl:text>
162    </p>
163  </dd>
164</xsl:template>
165
166<xsl:template match="glossentry/glossdef">
167  <dd>
168    <xsl:apply-templates select="*[local-name(.) != 'glossseealso']"/>
169    <xsl:if test="glossseealso">
170      <p>
171        <xsl:call-template name="gentext.template">
172          <xsl:with-param name="context" select="'glossary'"/>
173          <xsl:with-param name="name" select="'seealso'"/>
174        </xsl:call-template>
175        <xsl:apply-templates select="glossseealso"/>
176      </p>
177    </xsl:if>
178  </dd>
179</xsl:template>
180
181<xsl:template match="glossseealso">
182  <xsl:variable name="otherterm" select="@otherterm"/>
183  <xsl:variable name="targets" select="//node()[@id=$otherterm]"/>
184  <xsl:variable name="target" select="$targets[1]"/>
185
186  <xsl:choose>
187    <xsl:when test="@otherterm">
188      <a href="#{@otherterm}">
189        <xsl:apply-templates select="$target" mode="xref"/>
190      </a>
191    </xsl:when>
192    <xsl:otherwise>
193      <xsl:apply-templates/>
194    </xsl:otherwise>
195  </xsl:choose>
196
197  <xsl:choose>
198    <xsl:when test="position() = last()">
199      <xsl:text>.</xsl:text>
200    </xsl:when>
201    <xsl:otherwise>
202      <xsl:text>, </xsl:text>
203    </xsl:otherwise>
204  </xsl:choose>
205</xsl:template>
206
207<!-- ==================================================================== -->
208
209<xsl:template match="glossentry" mode="xref">
210  <xsl:apply-templates select="/glossterm[1]" mode="xref"/>
211</xsl:template>
212
213<xsl:template match="glossterm" mode="xref">
214  <xsl:apply-templates/>
215</xsl:template>
216
217<!-- ==================================================================== -->
218
219</xsl:stylesheet>
220