~ubuntu-branches/ubuntu/lucid/dblatex/lucid

« back to all changes in this revision

Viewing changes to xsl/glossary.xsl

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Hoenen
  • Date: 2006-05-15 19:59:06 UTC
  • Revision ID: james.westby@ubuntu.com-20060515195906-jg9x08tsfbi35m2x
Tags: upstream-0.1.9
ImportĀ upstreamĀ versionĀ 0.1.9

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version='1.0'?>
 
2
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version='1.0'>
 
3
 
 
4
<!--############################################################################
 
5
    XSLT Stylesheet DocBook -> LaTeX 
 
6
    ############################################################################ -->
 
7
 
 
8
<!-- ############
 
9
     # glossary #
 
10
     ############ -->
 
11
 
 
12
<xsl:template match="glossary">
 
13
  <xsl:variable name="divs" select="glossdiv"/>
 
14
  <xsl:variable name="entries" select="glossentry"/>
 
15
  <xsl:variable name="preamble" select="*[not(self::title
 
16
                                          or self::subtitle
 
17
                                          or self::glossdiv
 
18
                                          or self::glossentry)]"/>
 
19
  <xsl:text>% --------  &#10;</xsl:text>
 
20
  <xsl:text>% GLOSSARY  &#10;</xsl:text>
 
21
  <xsl:text>% --------  &#10;</xsl:text>
 
22
 
 
23
  <!-- defined or default glossary title? -->
 
24
  <xsl:variable name="title">
 
25
    <xsl:choose>
 
26
    <xsl:when test="title">
 
27
      <xsl:call-template name="normalize-scape">
 
28
      <xsl:with-param name="string" select="title"/>
 
29
      </xsl:call-template>
 
30
    </xsl:when>
 
31
    <xsl:otherwise>
 
32
      <xsl:call-template name="gentext.element.name"/>
 
33
    </xsl:otherwise>
 
34
    </xsl:choose>
 
35
  </xsl:variable>
 
36
 
 
37
  <!-- find the appropriate section level -->
 
38
  <xsl:call-template name="map.sect.level">
 
39
    <xsl:with-param name="level">
 
40
      <xsl:call-template name="get.sect.level"/>
 
41
    </xsl:with-param>
 
42
  </xsl:call-template>
 
43
  <xsl:text>{</xsl:text>
 
44
  <xsl:copy-of select="$title"/>
 
45
  <xsl:text>}&#10;</xsl:text>
 
46
  <xsl:call-template name="label.id"/>
 
47
  <xsl:if test="$preamble">
 
48
    <xsl:apply-templates select="$preamble"/>
 
49
  </xsl:if>
 
50
  <xsl:if test="$entries">
 
51
    <xsl:text>&#10;\noindent&#10;</xsl:text>
 
52
    <xsl:text>\begin{description}&#10;</xsl:text>
 
53
    <xsl:apply-templates select="$entries"/>
 
54
    <xsl:text>&#10;\end{description}&#10;</xsl:text>
 
55
  </xsl:if>
 
56
  <xsl:if test="$divs">
 
57
    <xsl:apply-templates select="$divs"/>
 
58
  </xsl:if>
 
59
</xsl:template>
 
60
 
 
61
<xsl:template match="glossary/glossaryinfo"/>
 
62
<xsl:template match="glossary/title"/>
 
63
<xsl:template match="glossary/subtitle"/>
 
64
<xsl:template match="glossary/titleabbrev"/>
 
65
 
 
66
 
 
67
<!-- ############
 
68
     # glossdiv #
 
69
     ############ -->
 
70
 
 
71
<xsl:template match="glossdiv">
 
72
  <!-- find the appropriate section level -->
 
73
  <xsl:variable name="l">
 
74
    <xsl:call-template name="get.sect.level">
 
75
      <xsl:with-param name="n" select="parent::glossary"/>
 
76
    </xsl:call-template>
 
77
  </xsl:variable>
 
78
  <xsl:call-template name="map.sect.level">
 
79
    <xsl:with-param name="level" select="$l+1"/>
 
80
  </xsl:call-template>
 
81
  <xsl:text>{</xsl:text>
 
82
  <xsl:copy-of select="title"/>
 
83
  <xsl:text>}&#10;</xsl:text>
 
84
  <xsl:call-template name="label.id"/>
 
85
 
 
86
  <!-- display the stuff before the entries -->
 
87
  <xsl:apply-templates select="*[not(self::glossentry)]"/>
 
88
  
 
89
  <!-- now, display the description list -->
 
90
  <xsl:text>&#10;\noindent&#10;</xsl:text>
 
91
  <xsl:text>\begin{description}&#10;</xsl:text>
 
92
  <xsl:apply-templates select="glossentry"/>
 
93
  <xsl:text>&#10;\end{description}&#10;</xsl:text>
 
94
</xsl:template>
 
95
 
 
96
 
 
97
<!-- #############
 
98
     # glosslist #
 
99
     ############# -->
 
100
 
 
101
<xsl:template match="glossdiv/title" />
 
102
 
 
103
<xsl:template match="glosslist">
 
104
  <xsl:text>&#10;\noindent&#10;</xsl:text>
 
105
  <xsl:text>\begin{description}&#10;</xsl:text>
 
106
  <xsl:apply-templates/>
 
107
  <xsl:text>&#10;\end{description}&#10;</xsl:text>
 
108
</xsl:template>
 
109
 
 
110
<xsl:template match="glosslist/title" />
 
111
<xsl:template match="glosslist/blockinfo" />
 
112
 
 
113
 
 
114
<!-- ##############
 
115
     # glossentry #
 
116
     ############## -->
 
117
 
 
118
<xsl:template match="glossentry">
 
119
  <xsl:apply-templates/>
 
120
  <xsl:text>&#10;&#10;</xsl:text>
 
121
</xsl:template>
 
122
 
 
123
<xsl:template match="glossentry/glossterm">
 
124
  <xsl:text>\item[</xsl:text>
 
125
  <xsl:if test="../@id">
 
126
    <xsl:text>\hypertarget{</xsl:text>
 
127
    <xsl:value-of select="../@id"/>
 
128
    <xsl:text>}</xsl:text>
 
129
  </xsl:if>
 
130
  <xsl:text>{</xsl:text>
 
131
  <xsl:variable name="term">
 
132
    <xsl:apply-templates/>
 
133
  </xsl:variable>
 
134
  <xsl:value-of select="normalize-space($term)"/>
 
135
  <xsl:text>}] </xsl:text>
 
136
</xsl:template>
 
137
 
 
138
<xsl:template match="glossentry/acronym">
 
139
  <xsl:text> (\texttt{</xsl:text><xsl:apply-templates/><xsl:text>}) </xsl:text>
 
140
</xsl:template>
 
141
  
 
142
<xsl:template match="glossentry/abbrev">
 
143
  <xsl:text> [ </xsl:text><xsl:apply-templates/><xsl:text> ] </xsl:text> 
 
144
</xsl:template>
 
145
 
 
146
<!-- not printed -->
 
147
<xsl:template match="glossentry/revhistory"/>
 
148
  
 
149
<xsl:template match="glossentry/glossdef">
 
150
  <xsl:text>&#10;</xsl:text>
 
151
  <xsl:apply-templates/>
 
152
</xsl:template>
 
153
 
 
154
<xsl:template match="glossseealso|glosssee">
 
155
  <xsl:variable name="otherterm" select="@otherterm"/>
 
156
  <xsl:variable name="targets" select="//node()[@id=$otherterm]"/>
 
157
  <xsl:variable name="target" select="$targets[1]"/>
 
158
  <xsl:variable name="text">
 
159
    <xsl:apply-templates/>
 
160
  </xsl:variable>
 
161
  <xsl:text> </xsl:text>
 
162
  <xsl:call-template name="gentext.element.name"/>
 
163
  <xsl:call-template name="gentext.space"/>
 
164
  <xsl:text>"</xsl:text>
 
165
  <xsl:choose>
 
166
    <xsl:when test="@otherterm">
 
167
      <xsl:text>\hyperlink{</xsl:text>
 
168
      <xsl:value-of select="@otherterm"/>
 
169
      <xsl:text>}{</xsl:text>
 
170
      <xsl:choose>
 
171
      <xsl:when test="$text!=''">
 
172
        <xsl:value-of select="$text"/>
 
173
      </xsl:when>
 
174
      <xsl:otherwise>
 
175
        <xsl:apply-templates select="$target" mode="xref"/>
 
176
      </xsl:otherwise>
 
177
      </xsl:choose>
 
178
      <xsl:text>}</xsl:text>
 
179
    </xsl:when>
 
180
    <xsl:otherwise>
 
181
      <xsl:value-of select="$text"/>
 
182
    </xsl:otherwise>
 
183
  </xsl:choose>
 
184
  <xsl:text>". </xsl:text>
 
185
</xsl:template>
 
186
 
 
187
<xsl:template match="glossentry" mode="xref">
 
188
  <xsl:apply-templates select="./glossterm" mode="xref"/>
 
189
</xsl:template>
 
190
 
 
191
<xsl:template match="glossterm" mode="xref">
 
192
  <xsl:apply-templates/>
 
193
</xsl:template>
 
194
 
 
195
</xsl:stylesheet>
 
196