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

« back to all changes in this revision

Viewing changes to xsl/biblio.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
<!-- ##################
 
10
     # biblio section #
 
11
     ################## -->
 
12
 
 
13
<xsl:template name="biblio.title">
 
14
  <xsl:choose>
 
15
  <xsl:when test="title|bibliographyinfo/title">
 
16
    <xsl:value-of select="(title|bibliographyinfo/title)[1]"/>
 
17
  </xsl:when>
 
18
  <xsl:otherwise>
 
19
    <xsl:text>\bibname</xsl:text>
 
20
  </xsl:otherwise>
 
21
  </xsl:choose>
 
22
</xsl:template>
 
23
 
 
24
<xsl:template name="biblioentry.process">
 
25
  <xsl:param name="level"/>
 
26
 
 
27
  <xsl:text>\begin{btSect}{}&#10;</xsl:text>
 
28
 
 
29
  <!-- display the heading -->
 
30
  <xsl:if test="$level &gt;= 0">
 
31
    <xsl:call-template name="map.sect.level">
 
32
      <xsl:with-param name="level" select="$level"/>
 
33
    </xsl:call-template>
 
34
    <xsl:text>{</xsl:text>
 
35
    <xsl:call-template name="biblio.title"/>
 
36
    <xsl:text>}&#10;</xsl:text>
 
37
    <xsl:call-template name="label.id"/>
 
38
  </xsl:if>
 
39
 
 
40
  <xsl:text>\begin{bibgroup}&#10;</xsl:text>
 
41
  <xsl:text>\begin{thebibliography}{</xsl:text>
 
42
  <xsl:value-of select="$latex.bibwidelabel"/>
 
43
  <xsl:text>}&#10;</xsl:text>
 
44
  <xsl:if test="biblioentry">
 
45
    <xsl:choose>
 
46
    <xsl:when test="$latex.biblio.output ='cited'">
 
47
      <xsl:apply-templates select="biblioentry" mode="bibliography.cited">
 
48
        <xsl:sort select="./abbrev"/>
 
49
        <xsl:sort select="./@xreflabel"/>
 
50
        <xsl:sort select="./@id"/>
 
51
      </xsl:apply-templates>
 
52
    </xsl:when>
 
53
    <xsl:otherwise>
 
54
      <xsl:apply-templates select="biblioentry">
 
55
        <xsl:sort select="./abbrev"/>
 
56
        <xsl:sort select="./@xreflabel"/>
 
57
        <xsl:sort select="./@id"/>
 
58
      </xsl:apply-templates>
 
59
    </xsl:otherwise>
 
60
    </xsl:choose>
 
61
  </xsl:if>
 
62
  <xsl:if test="bibliomixed">
 
63
    <xsl:apply-templates select="bibliomixed"/>
 
64
  </xsl:if>
 
65
  <xsl:text>&#10;\end{thebibliography}&#10;</xsl:text>
 
66
  <xsl:text>\end{bibgroup}&#10;</xsl:text>
 
67
  <xsl:text>\end{btSect}&#10;</xsl:text>
 
68
</xsl:template>
 
69
 
 
70
 
 
71
<!-- ################
 
72
     # bibliography #
 
73
     ################ -->
 
74
 
 
75
<xsl:template match="bibliography">
 
76
  <xsl:message>Processing Bibliography</xsl:message>
 
77
  <xsl:message>Output Mode: <xsl:value-of select="$latex.biblio.output"/></xsl:message>
 
78
  <xsl:text>% ------------------------------------------- &#10;</xsl:text>
 
79
  <xsl:text>% Bibliography&#10;</xsl:text>
 
80
  <xsl:text>% -------------------------------------------  &#10;</xsl:text>
 
81
  <xsl:text>\bibliography{</xsl:text>
 
82
  <xsl:value-of select="$latex.bibfiles"/>
 
83
  <xsl:text>}&#10;</xsl:text>
 
84
 
 
85
  <!-- get the section level -->
 
86
  <xsl:variable name="level">
 
87
    <xsl:call-template name="get.sect.level"/>
 
88
  </xsl:variable>
 
89
 
 
90
  <xsl:choose>
 
91
  <xsl:when test="biblioentry|bibliomixed">
 
92
    <!-- process the entries -->
 
93
    <xsl:call-template name="biblioentry.process">
 
94
      <xsl:with-param name="level" select="$level"/>
 
95
    </xsl:call-template>
 
96
  </xsl:when>
 
97
  <xsl:otherwise>
 
98
    <!-- no entries here, only a section block -->
 
99
    <xsl:call-template name="map.sect.level">
 
100
      <xsl:with-param name="level" select="$level"/>
 
101
    </xsl:call-template>
 
102
    <xsl:text>{</xsl:text>
 
103
    <xsl:call-template name="biblio.title"/>
 
104
    <xsl:text>}&#10;</xsl:text>
 
105
    <xsl:call-template name="label.id"/>
 
106
  </xsl:otherwise>
 
107
  </xsl:choose>
 
108
  <xsl:apply-templates select="bibliodiv"/> 
 
109
</xsl:template>
 
110
 
 
111
<xsl:template match="bibliography/title"/>
 
112
<xsl:template match="bibliography/subtitle"/>
 
113
<xsl:template match="bibliography/titleabbrev"/>
 
114
 
 
115
<!-- ###############
 
116
     #  bibliodiv  #
 
117
     ############### -->
 
118
 
 
119
<xsl:template match="bibliodiv">
 
120
  <xsl:message>Processing Bibliography - Bibliodiv</xsl:message>
 
121
  <xsl:variable name="level">
 
122
    <xsl:call-template name="get.sect.level">
 
123
      <xsl:with-param name="n" select="parent::bibliography"/>
 
124
    </xsl:call-template>
 
125
  </xsl:variable>
 
126
  <xsl:call-template name="biblioentry.process">
 
127
    <xsl:with-param name="level" select="$level+1"/>
 
128
  </xsl:call-template>
 
129
</xsl:template>
 
130
 
 
131
<xsl:template match="bibliodiv/title"/>
 
132
 
 
133
<!-- ###############
 
134
     #  bibliolist #
 
135
     ############### -->
 
136
 
 
137
<xsl:template match="bibliolist">
 
138
  <xsl:call-template name="biblioentry.process">
 
139
    <xsl:with-param name="level" select="'-1'"/>
 
140
  </xsl:call-template>
 
141
</xsl:template>
 
142
 
 
143
<xsl:template match="bibliodiv/title"/>
 
144
 
 
145
<!-- ###############
 
146
     # biblioentry #
 
147
     ############### -->
 
148
 
 
149
<xsl:template match="biblioentry" mode="bibliography.cited">
 
150
  <xsl:param name="bibid" select="@id"/>
 
151
  <xsl:param name="ab" select="abbrev"/>
 
152
  <xsl:variable name="nx" select="//xref[@linkend=$bibid]"/>
 
153
  <xsl:variable name="nc" select="//citation[text()=$ab]"/>
 
154
  <xsl:if test="count($nx) &gt; 0 or count($nc) &gt; 0">
 
155
    <xsl:call-template name="biblioentry.output"/>
 
156
  </xsl:if>
 
157
</xsl:template>
 
158
 
 
159
<xsl:template match="biblioentry" mode="bibliography.all">
 
160
  <xsl:call-template name="biblioentry.output"/>
 
161
</xsl:template>
 
162
 
 
163
<xsl:template match="biblioentry">
 
164
  <xsl:call-template name="biblioentry.output"/>
 
165
</xsl:template>
 
166
 
 
167
<xsl:template match="biblioentry/title">
 
168
  <xsl:text>\emph{</xsl:text>
 
169
  <xsl:apply-templates/>
 
170
  <xsl:text>}</xsl:text>
 
171
</xsl:template>
 
172
 
 
173
<!-- biblioentry engine -->
 
174
 
 
175
<xsl:template name="bibitem">
 
176
  <xsl:variable name="tag">
 
177
    <xsl:choose>
 
178
    <xsl:when test="@xreflabel">
 
179
      <xsl:value-of select="normalize-space(@xreflabel)"/> 
 
180
    </xsl:when>
 
181
    <xsl:when test="abbrev">
 
182
      <xsl:apply-templates select="abbrev" mode="bibliography.mode"/> 
 
183
    </xsl:when>
 
184
    <xsl:when test="@id">
 
185
      <xsl:value-of select="normalize-space(@id)"/> 
 
186
    </xsl:when>
 
187
    <xsl:otherwise>
 
188
      <xsl:text>UNKNOWN</xsl:text>
 
189
    </xsl:otherwise>
 
190
    </xsl:choose>
 
191
  </xsl:variable>
 
192
  <xsl:text>&#10;</xsl:text>
 
193
  <xsl:text>\bibitem</xsl:text>
 
194
  <xsl:if test="$tag!='UNKNOWN'">
 
195
    <xsl:text>[</xsl:text>
 
196
    <xsl:call-template name="normalize-scape">
 
197
      <xsl:with-param name="string" select="$tag"/>
 
198
    </xsl:call-template>
 
199
    <xsl:text>]</xsl:text> 
 
200
  </xsl:if>
 
201
  <xsl:text>{</xsl:text>
 
202
  <xsl:value-of select="$tag"/>
 
203
  <xsl:text>}&#10;</xsl:text> 
 
204
</xsl:template>
 
205
 
 
206
<xsl:template name="biblioentry.output">
 
207
  <xsl:call-template name="bibitem"/>
 
208
  <!-- first, biblioentry information (if any) -->
 
209
  <xsl:variable name="data" select="subtitle|
 
210
                                    volumenum|
 
211
                                    edition|
 
212
                                    copyright|
 
213
                                    publisher|
 
214
                                    pubdate|
 
215
                                    pagenums|
 
216
                                    isbn|
 
217
                                    issn|
 
218
                                    pubsnumber"/>
 
219
  <xsl:apply-templates select="author|authorgroup" mode="bibliography.mode"/>
 
220
  <xsl:if test="title">
 
221
    <xsl:if test="author|authorgroup">
 
222
      <xsl:value-of select="$biblioentry.item.separator"/>
 
223
    </xsl:if>
 
224
    <xsl:apply-templates select="title"/>
 
225
  </xsl:if>
 
226
  <xsl:if test="$data">
 
227
    <xsl:for-each select="$data">
 
228
      <xsl:value-of select="$biblioentry.item.separator"/>
 
229
      <xsl:apply-templates select="." mode="bibliography.mode"/> 
 
230
    </xsl:for-each>
 
231
    <xsl:text>.</xsl:text>
 
232
  </xsl:if>
 
233
  <!-- then, biblioset information (if any) -->
 
234
  <xsl:for-each select="biblioset">
 
235
    <xsl:text>&#10;&#10;</xsl:text>
 
236
    <xsl:apply-templates select="." mode="bibliography.mode"/>
 
237
  </xsl:for-each>
 
238
  <xsl:call-template name="label.id"/> 
 
239
  <xsl:text>&#10;</xsl:text>
 
240
</xsl:template>
 
241
 
 
242
<xsl:template match="bibliomixed">
 
243
  <xsl:call-template name="bibitem"/>
 
244
  <xsl:apply-templates select="." mode="bibliography.mode"/>
 
245
  <xsl:text>&#10;</xsl:text>
 
246
</xsl:template>
 
247
 
 
248
 
 
249
<!-- by default no specific behaviour -->
 
250
 
 
251
<xsl:template match="*" mode="bibliography.mode">
 
252
  <xsl:apply-templates mode="bibliography.mode"/>
 
253
</xsl:template>
 
254
 
 
255
<!-- specific behaviour for bibliography -->
 
256
 
 
257
<xsl:template match="biblioset" mode="bibliography.mode">
 
258
  <xsl:if test="author|authorgroup">
 
259
    <xsl:apply-templates select="author|authorgroup" mode="bibliography.mode"/>
 
260
    <xsl:value-of select="$biblioentry.item.separator"/>
 
261
  </xsl:if>
 
262
  <xsl:apply-templates select="title" mode="bibliography.mode"/>
 
263
  <xsl:for-each select="subtitle|
 
264
                        volumenum|
 
265
                        edition|
 
266
                        copyright|
 
267
                        publisher|
 
268
                        pubdate|
 
269
                        pagenums|
 
270
                        isbn|
 
271
                        issn|
 
272
                        pubsnumber">
 
273
    <xsl:value-of select="$biblioentry.item.separator"/>
 
274
    <xsl:apply-templates select="." mode="bibliography.mode"/> 
 
275
  </xsl:for-each>
 
276
  <xsl:text>.</xsl:text>
 
277
</xsl:template>
 
278
 
 
279
<xsl:template match="biblioset/title|biblioset/citetitle" 
 
280
              mode="bibliography.mode">
 
281
  <xsl:variable name="relation" select="../@relation"/>
 
282
  <xsl:choose>
 
283
    <xsl:when test="$relation='article'">
 
284
      <xsl:call-template name="dingbat">
 
285
        <xsl:with-param name="dingbat">ldquo</xsl:with-param>
 
286
      </xsl:call-template>
 
287
      <xsl:apply-templates/>
 
288
      <xsl:call-template name="dingbat">
 
289
        <xsl:with-param name="dingbat">rdquo</xsl:with-param>
 
290
      </xsl:call-template>
 
291
    </xsl:when>
 
292
    <xsl:otherwise>
 
293
      <xsl:apply-templates/>
 
294
    </xsl:otherwise>
 
295
  </xsl:choose>
 
296
</xsl:template>
 
297
 
 
298
<xsl:template match="author" mode="bibliography.mode">
 
299
  <xsl:variable name="authorsstring">
 
300
    <xsl:call-template name="person.name"/>
 
301
  </xsl:variable>
 
302
  <xsl:value-of select="normalize-space($authorsstring)"/>
 
303
</xsl:template>
 
304
 
 
305
<xsl:template match="authorgroup" mode="bibliography.mode">
 
306
  <xsl:variable name="authorsstring">
 
307
    <xsl:call-template name="person.name.list"/>
 
308
  </xsl:variable>
 
309
  <xsl:value-of select="normalize-space($authorsstring)"/>
 
310
</xsl:template>
 
311
 
 
312
<xsl:template match="editor" mode="bibliography.mode">
 
313
    <xsl:call-template name="person.name"/>
 
314
    <xsl:value-of select="$biblioentry.item.separator"/>
 
315
</xsl:template>
 
316
 
 
317
<xsl:template match="copyright" mode="bibliography.mode">
 
318
  <xsl:call-template name="gentext.element.name"/>
 
319
  <xsl:call-template name="gentext.space"/>
 
320
  <xsl:call-template name="dingbat">
 
321
    <xsl:with-param name="dingbat">copyright</xsl:with-param>
 
322
  </xsl:call-template>
 
323
  <xsl:call-template name="gentext.space"/>
 
324
  <xsl:apply-templates select="year" mode="bibliography.mode"/>
 
325
  <xsl:call-template name="gentext.space"/>
 
326
  <xsl:apply-templates select="holder" mode="bibliography.mode"/>
 
327
</xsl:template>
 
328
 
 
329
<xsl:template match="year" mode="bibliography.mode">
 
330
  <xsl:apply-templates/>
 
331
  <xsl:if test="position()!=last()">
 
332
    <xsl:text>, </xsl:text>
 
333
  </xsl:if>
 
334
</xsl:template>
 
335
 
 
336
 
 
337
<!-- to manage entities correctly (such as &amp;) -->
 
338
<xsl:template match="holder|publishername|edition" mode="bibliography.mode">
 
339
  <xsl:apply-templates/>
 
340
</xsl:template>
 
341
 
 
342
<!-- suppressed things -->
 
343
<xsl:template match="printhistory" mode="bibliography.mode"/>
 
344
<xsl:template match="abstract" mode="bibliography.mode"/>
 
345
<xsl:template match="authorblurb" mode="bibliography.mode"/>
 
346
 
 
347
 
 
348
</xsl:stylesheet>