Next update of VFS modules development guide
[gd/samba-autobuild/.git] / docs / xslt / db2latex-xsl / xsl / common / titles.xsl
1 <?xml version='1.0'?>
2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3                 xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"
4                 exclude-result-prefixes="doc"
5                 version='1.0'>
6
7 <!-- ********************************************************************
8      $Id: titles.xsl,v 1.2 2004/01/04 09:25:57 j-devenish Exp $
9      ********************************************************************
10
11      This file is part of the XSL DocBook Stylesheet distribution.
12
13      Copyright (C) 1999, 2000, 2001, 2002 Norman Walsh.
14      ******************************************************************** -->
15
16 <!-- ==================================================================== -->
17
18 <!-- title markup -->
19
20 <doc:mode mode="title.markup" xmlns="">
21 <refpurpose>Provides access to element titles</refpurpose>
22 <refdescription>
23 <para>Processing an element in the
24 <literal role="mode">title.markup</literal> mode produces the
25 title of the element. This does not include the label.
26 </para>
27 </refdescription>
28 </doc:mode>
29
30 <xsl:template match="*" mode="title.markup">
31   <xsl:param name="allow-anchors" select="0"/>
32   <xsl:param name="verbose" select="1"/>
33
34   <xsl:choose>
35     <xsl:when test="title">
36       <xsl:apply-templates select="title[1]" mode="title.markup">
37         <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
38       </xsl:apply-templates>
39     </xsl:when>
40     <xsl:when test="local-name(.) = 'partintro'">
41       <!-- partintro's don't have titles, use the parent (part or reference)
42            title instead. -->
43       <xsl:apply-templates select="parent::*" mode="title.markup"/>
44     </xsl:when>
45     <xsl:otherwise>
46       <xsl:if test="$verbose">
47         <xsl:message>
48           <xsl:text>Request for title of element with no title: </xsl:text>
49           <xsl:value-of select="name(.)"/>
50           <xsl:if test="@id">
51             <xsl:text> (id="</xsl:text>
52             <xsl:value-of select="@id"/>
53             <xsl:text>")</xsl:text>
54           </xsl:if>
55         </xsl:message>
56       </xsl:if>
57       <xsl:text>???TITLE???</xsl:text>
58     </xsl:otherwise>
59   </xsl:choose>
60 </xsl:template>
61
62 <xsl:template match="title" mode="title.markup">
63   <xsl:param name="allow-anchors" select="0"/>
64
65   <xsl:choose>
66     <xsl:when test="$allow-anchors != 0">
67       <xsl:apply-templates/>
68     </xsl:when>
69     <xsl:otherwise>
70       <xsl:apply-templates mode="no.anchor.mode"/>
71     </xsl:otherwise>
72   </xsl:choose>
73 </xsl:template>
74
75 <!-- only occurs in HTML Tables! -->
76 <xsl:template match="caption" mode="title.markup">
77   <xsl:param name="allow-anchors" select="0"/>
78
79   <xsl:choose>
80     <xsl:when test="$allow-anchors != 0">
81       <xsl:apply-templates/>
82     </xsl:when>
83     <xsl:otherwise>
84       <xsl:apply-templates mode="no.anchor.mode"/>
85     </xsl:otherwise>
86   </xsl:choose>
87 </xsl:template>
88
89 <xsl:template match="set" mode="title.markup">
90   <xsl:param name="allow-anchors" select="0"/>
91   <xsl:apply-templates select="(setinfo/title|title)[1]"
92                        mode="title.markup">
93     <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
94   </xsl:apply-templates>
95 </xsl:template>
96
97 <xsl:template match="book" mode="title.markup">
98   <xsl:param name="allow-anchors" select="0"/>
99   <xsl:apply-templates select="(bookinfo/title|title)[1]"
100                        mode="title.markup">
101     <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
102   </xsl:apply-templates>
103 </xsl:template>
104
105 <xsl:template match="part" mode="title.markup">
106   <xsl:param name="allow-anchors" select="0"/>
107   <xsl:apply-templates select="(partinfo/title|docinfo/title|title)[1]"
108                        mode="title.markup">
109     <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
110   </xsl:apply-templates>
111 </xsl:template>
112
113 <xsl:template match="preface|chapter|appendix" mode="title.markup">
114   <xsl:param name="allow-anchors" select="0"/>
115
116 <!--
117   <xsl:message>
118     <xsl:value-of select="name(.)"/>
119     <xsl:text> </xsl:text>
120     <xsl:value-of select="$allow-anchors"/>
121   </xsl:message>
122 -->
123
124   <xsl:variable name="title" select="(docinfo/title
125                                       |prefaceinfo/title
126                                       |chapterinfo/title
127                                       |appendixinfo/title
128                                       |title)[1]"/>
129   <xsl:apply-templates select="$title" mode="title.markup">
130     <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
131   </xsl:apply-templates>
132 </xsl:template>
133
134 <xsl:template match="dedication" mode="title.markup">
135   <xsl:param name="allow-anchors" select="0"/>
136   <xsl:choose>
137     <xsl:when test="title">
138       <xsl:apply-templates select="title" mode="title.markup">
139         <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
140       </xsl:apply-templates>
141     </xsl:when>
142     <xsl:otherwise>
143       <xsl:call-template name="gentext">
144         <xsl:with-param name="key" select="'Dedication'"/>
145       </xsl:call-template>
146     </xsl:otherwise>
147   </xsl:choose>
148 </xsl:template>
149
150 <xsl:template match="colophon" mode="title.markup">
151   <xsl:param name="allow-anchors" select="0"/>
152   <xsl:choose>
153     <xsl:when test="title">
154       <xsl:apply-templates select="title" mode="title.markup">
155         <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
156       </xsl:apply-templates>
157     </xsl:when>
158     <xsl:otherwise>
159       <xsl:call-template name="gentext">
160         <xsl:with-param name="key" select="'Colophon'"/>
161       </xsl:call-template>
162     </xsl:otherwise>
163   </xsl:choose>
164 </xsl:template>
165
166 <xsl:template match="article" mode="title.markup">
167   <xsl:param name="allow-anchors" select="0"/>
168   <xsl:variable name="title" select="(artheader/title
169                                       |articleinfo/title
170                                       |title)[1]"/>
171
172   <xsl:apply-templates select="$title" mode="title.markup">
173     <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
174   </xsl:apply-templates>
175 </xsl:template>
176
177 <xsl:template match="reference" mode="title.markup">
178   <xsl:param name="allow-anchors" select="0"/>
179   <xsl:apply-templates select="(referenceinfo/title|docinfo/title|title)[1]"
180                        mode="title.markup">
181     <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
182   </xsl:apply-templates>
183 </xsl:template>
184
185 <xsl:template match="refentry" mode="title.markup">
186   <xsl:param name="allow-anchors" select="0"/>
187   <xsl:variable name="refmeta" select=".//refmeta"/>
188   <xsl:variable name="refentrytitle" select="$refmeta//refentrytitle"/>
189   <xsl:variable name="refnamediv" select=".//refnamediv"/>
190   <xsl:variable name="refname" select="$refnamediv//refname"/>
191
192   <xsl:variable name="title">
193     <xsl:choose>
194       <xsl:when test="$refentrytitle">
195         <xsl:apply-templates select="$refentrytitle[1]" mode="title.markup"/>
196       </xsl:when>
197       <xsl:when test="$refname">
198         <xsl:apply-templates select="$refname[1]" mode="title.markup"/>
199       </xsl:when>
200       <xsl:otherwise>REFENTRY WITHOUT TITLE???</xsl:otherwise>
201     </xsl:choose>
202   </xsl:variable>
203
204   <xsl:copy-of select="$title"/>
205 </xsl:template>
206
207 <xsl:template match="refentrytitle|refname" mode="title.markup">
208   <xsl:param name="allow-anchors" select="0"/>
209   <xsl:choose>
210     <xsl:when test="$allow-anchors != 0">
211       <xsl:apply-templates/>
212     </xsl:when>
213     <xsl:otherwise>
214       <xsl:apply-templates mode="no.anchor.mode"/>
215     </xsl:otherwise>
216   </xsl:choose>
217 </xsl:template>
218
219 <xsl:template match="section
220                      |sect1|sect2|sect3|sect4|sect5
221                      |refsect1|refsect2|refsect3
222                      |simplesect"
223               mode="title.markup">
224   <xsl:param name="allow-anchors" select="0"/>
225   <xsl:variable name="title" select="(sectioninfo/title
226                                       |sect1info/title
227                                       |sect2info/title
228                                       |sect3info/title
229                                       |sect4info/title
230                                       |sect5info/title
231                                       |refsect1info/title
232                                       |refsect2info/title
233                                       |refsect3info/title
234                                       |title)[1]"/>
235
236   <xsl:apply-templates select="$title" mode="title.markup">
237     <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
238   </xsl:apply-templates>
239 </xsl:template>
240
241 <xsl:template match="bridgehead" mode="title.markup">
242   <xsl:apply-templates mode="title.markup"/>
243 </xsl:template>
244
245 <xsl:template match="refsynopsisdiv" mode="title.markup">
246   <xsl:param name="allow-anchors" select="0"/>
247   <xsl:choose>
248     <xsl:when test="title">
249       <xsl:apply-templates select="title" mode="title.markup">
250         <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
251       </xsl:apply-templates>
252     </xsl:when>
253     <xsl:otherwise>
254       <xsl:call-template name="gentext">
255         <xsl:with-param name="key" select="'RefSynopsisDiv'"/>
256       </xsl:call-template>
257     </xsl:otherwise>
258   </xsl:choose>
259 </xsl:template>
260
261 <xsl:template match="bibliography" mode="title.markup">
262   <xsl:param name="allow-anchors" select="0"/>
263   <xsl:variable name="title" select="(bibliographyinfo/title|title)[1]"/>
264   <xsl:choose>
265     <xsl:when test="$title">
266       <xsl:apply-templates select="$title" mode="title.markup">
267         <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
268       </xsl:apply-templates>
269     </xsl:when>
270     <xsl:otherwise>
271       <xsl:call-template name="gentext">
272         <xsl:with-param name="key" select="'Bibliography'"/>
273       </xsl:call-template>
274     </xsl:otherwise>
275   </xsl:choose>
276 </xsl:template>
277
278 <xsl:template match="glossary" mode="title.markup">
279   <xsl:param name="allow-anchors" select="0"/>
280   <xsl:variable name="title" select="(glossaryinfo/title|title)[1]"/>
281   <xsl:choose>
282     <xsl:when test="$title">
283       <xsl:apply-templates select="$title" mode="title.markup">
284         <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
285       </xsl:apply-templates>
286     </xsl:when>
287     <xsl:otherwise>
288       <xsl:call-template name="gentext.element.name">
289         <xsl:with-param name="element.name" select="name(.)"/>
290       </xsl:call-template>
291     </xsl:otherwise>
292   </xsl:choose>
293 </xsl:template>
294
295 <xsl:template match="glossentry" mode="title.markup">
296   <xsl:param name="allow-anchors" select="0"/>
297   <xsl:apply-templates select="glossterm" mode="title.markup">
298     <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
299   </xsl:apply-templates>
300 </xsl:template>
301
302 <xsl:template match="glossterm" mode="title.markup">
303   <xsl:param name="allow-anchors" select="0"/>
304
305   <xsl:choose>
306     <xsl:when test="$allow-anchors != 0">
307       <xsl:apply-templates/>
308     </xsl:when>
309     <xsl:otherwise>
310       <xsl:apply-templates mode="no.anchor.mode"/>
311     </xsl:otherwise>
312   </xsl:choose>
313 </xsl:template>
314
315 <xsl:template match="index" mode="title.markup">
316   <xsl:param name="allow-anchors" select="0"/>
317   <xsl:variable name="title" select="(indexinfo/title|title)[1]"/>
318   <xsl:choose>
319     <xsl:when test="$title">
320       <xsl:apply-templates select="$title" mode="title.markup">
321         <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
322       </xsl:apply-templates>
323     </xsl:when>
324     <xsl:otherwise>
325       <xsl:call-template name="gentext">
326         <xsl:with-param name="key" select="'Index'"/>
327       </xsl:call-template>
328     </xsl:otherwise>
329   </xsl:choose>
330 </xsl:template>
331
332 <xsl:template match="setindex" mode="title.markup">
333   <xsl:param name="allow-anchors" select="0"/>
334   <xsl:variable name="title" select="(setindexinfo/title|title)[1]"/>
335   <xsl:choose>
336     <xsl:when test="$title">
337       <xsl:apply-templates select="$title" mode="title.markup">
338         <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
339       </xsl:apply-templates>
340     </xsl:when>
341     <xsl:otherwise>
342       <xsl:call-template name="gentext">
343         <xsl:with-param name="key" select="'SetIndex'"/>
344       </xsl:call-template>
345     </xsl:otherwise>
346   </xsl:choose>
347 </xsl:template>
348
349 <xsl:template match="figure|example|equation" mode="title.markup">
350   <xsl:param name="allow-anchors" select="0"/>
351   <xsl:apply-templates select="title" mode="title.markup">
352     <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
353   </xsl:apply-templates>
354 </xsl:template>
355
356 <xsl:template match="table" mode="title.markup">
357   <xsl:param name="allow-anchors" select="0"/>
358   <xsl:apply-templates select="title|caption" mode="title.markup">
359     <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
360   </xsl:apply-templates>
361 </xsl:template>
362
363 <xsl:template match="procedure" mode="title.markup">
364   <xsl:param name="allow-anchors" select="0"/>
365   <xsl:apply-templates select="title" mode="title.markup">
366     <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
367   </xsl:apply-templates>
368 </xsl:template>
369
370 <xsl:template match="abstract" mode="title.markup">
371   <xsl:param name="allow-anchors" select="0"/>
372   <xsl:choose>
373     <xsl:when test="title">
374       <xsl:apply-templates select="title" mode="title.markup">
375         <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
376       </xsl:apply-templates>
377     </xsl:when>
378     <xsl:otherwise>
379       <xsl:call-template name="gentext">
380         <xsl:with-param name="key" select="'Abstract'"/>
381       </xsl:call-template>
382     </xsl:otherwise>
383   </xsl:choose>
384 </xsl:template>
385
386 <xsl:template match="caution|tip|warning|important|note" mode="title.markup">
387   <xsl:param name="allow-anchors" select="0"/>
388   <xsl:variable name="title" select="title[1]"/>
389   <xsl:choose>
390     <xsl:when test="$title">
391       <xsl:apply-templates select="$title" mode="title.markup">
392         <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
393       </xsl:apply-templates>
394     </xsl:when>
395     <xsl:otherwise>
396       <xsl:call-template name="gentext">
397         <xsl:with-param name="key">
398           <xsl:choose>
399             <xsl:when test="local-name(.)='note'">Note</xsl:when>
400             <xsl:when test="local-name(.)='important'">Important</xsl:when>
401             <xsl:when test="local-name(.)='caution'">Caution</xsl:when>
402             <xsl:when test="local-name(.)='warning'">Warning</xsl:when>
403             <xsl:when test="local-name(.)='tip'">Tip</xsl:when>
404           </xsl:choose>
405         </xsl:with-param>
406       </xsl:call-template>
407     </xsl:otherwise>
408   </xsl:choose>
409 </xsl:template>
410
411 <xsl:template match="question" mode="title.markup">
412   <!-- questions don't have titles -->
413   <xsl:text>Question</xsl:text>
414 </xsl:template>
415
416 <xsl:template match="answer" mode="title.markup">
417   <!-- answers don't have titles -->
418   <xsl:text>Answer</xsl:text>
419 </xsl:template>
420
421 <xsl:template match="qandaentry" mode="title.markup">
422   <!-- qandaentrys are represented by the first question in them -->
423   <xsl:text>Question</xsl:text>
424 </xsl:template>
425
426 <xsl:template match="legalnotice" mode="title.markup">
427   <xsl:param name="allow-anchors" select="0"/>
428   <xsl:choose>
429     <xsl:when test="title">
430       <xsl:apply-templates select="title" mode="title.markup">
431         <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
432       </xsl:apply-templates>
433     </xsl:when>
434     <xsl:otherwise>
435       <xsl:call-template name="gentext">
436         <xsl:with-param name="key" select="'LegalNotice'"/>
437       </xsl:call-template>
438     </xsl:otherwise>
439   </xsl:choose>
440 </xsl:template>
441
442 <!-- ============================================================ -->
443
444 <xsl:template match="*" mode="titleabbrev.markup">
445   <xsl:param name="allow-anchors" select="0"/>
446   <xsl:param name="verbose" select="1"/>
447
448   <xsl:choose>
449     <xsl:when test="titleabbrev">
450       <xsl:apply-templates select="titleabbrev[1]" mode="title.markup">
451         <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
452       </xsl:apply-templates>
453     </xsl:when>
454     <xsl:otherwise>
455       <xsl:apply-templates select="." mode="title.markup">
456         <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
457         <xsl:with-param name="verbose" select="$verbose"/>
458       </xsl:apply-templates>
459     </xsl:otherwise>
460   </xsl:choose>
461 </xsl:template>
462
463 <xsl:template match="preface|chapter|appendix" mode="titleabbrev.markup">
464   <xsl:param name="allow-anchors" select="0"/>
465   <xsl:param name="verbose" select="1"/>
466
467   <xsl:variable name="titleabbrev" select="(docinfo/titleabbrev
468                                            |prefaceinfo/titleabbrev
469                                            |chapterinfo/titleabbrev
470                                            |appendixinfo/titleabbrev
471                                            |titleabbrev)[1]"/>
472
473   <xsl:choose>
474     <xsl:when test="$titleabbrev">
475       <xsl:apply-templates select="$titleabbrev" mode="title.markup">
476         <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
477       </xsl:apply-templates>
478     </xsl:when>
479     <xsl:otherwise>
480       <xsl:apply-templates select="." mode="title.markup">
481         <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
482         <xsl:with-param name="verbose" select="$verbose"/>
483       </xsl:apply-templates>
484     </xsl:otherwise>
485   </xsl:choose>
486 </xsl:template>
487
488 <xsl:template match="article" mode="titleabbrev.markup">
489   <xsl:param name="allow-anchors" select="0"/>
490   <xsl:param name="verbose" select="1"/>
491
492   <xsl:variable name="titleabbrev" select="(artheader/titleabbrev
493                                            |articleinfo/titleabbrev
494                                            |titleabbrev)[1]"/>
495
496   <xsl:choose>
497     <xsl:when test="$titleabbrev">
498       <xsl:apply-templates select="$titleabbrev" mode="title.markup">
499         <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
500       </xsl:apply-templates>
501     </xsl:when>
502     <xsl:otherwise>
503       <xsl:apply-templates select="." mode="title.markup">
504         <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
505         <xsl:with-param name="verbose" select="$verbose"/>
506       </xsl:apply-templates>
507     </xsl:otherwise>
508   </xsl:choose>
509 </xsl:template>
510
511 <xsl:template match="section
512                      |sect1|sect2|sect3|sect4|sect5
513                      |refsect1|refsect2|refsect3
514                      |simplesect"
515               mode="titleabbrev.markup">
516   <xsl:param name="allow-anchors" select="0"/>
517   <xsl:param name="verbose" select="1"/>
518
519   <xsl:variable name="titleabbrev" select="(sectioninfo/titleabbrev
520                                       |sect1info/titleabbrev
521                                       |sect2info/titleabbrev
522                                       |sect3info/titleabbrev
523                                       |sect4info/titleabbrev
524                                       |sect5info/titleabbrev
525                                       |refsect1info/titleabbrev
526                                       |refsect2info/titleabbrev
527                                       |refsect3info/titleabbrev
528                                       |titleabbrev)[1]"/>
529
530   <xsl:choose>
531     <xsl:when test="$titleabbrev">
532       <xsl:apply-templates select="$titleabbrev" mode="title.markup">
533         <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
534       </xsl:apply-templates>
535     </xsl:when>
536     <xsl:otherwise>
537       <xsl:apply-templates select="." mode="title.markup">
538         <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
539         <xsl:with-param name="verbose" select="$verbose"/>
540       </xsl:apply-templates>
541     </xsl:otherwise>
542   </xsl:choose>
543 </xsl:template>
544
545 <xsl:template match="titleabbrev" mode="title.markup">
546   <xsl:param name="allow-anchors" select="0"/>
547
548   <xsl:choose>
549     <xsl:when test="$allow-anchors != 0">
550       <xsl:apply-templates/>
551     </xsl:when>
552     <xsl:otherwise>
553       <xsl:apply-templates mode="no.anchor.mode"/>
554     </xsl:otherwise>
555   </xsl:choose>
556 </xsl:template>
557
558 <!-- ============================================================ -->
559
560 <xsl:template match="*" mode="no.anchor.mode">
561   <xsl:apply-templates mode="no.anchor.mode"/>
562 </xsl:template>
563
564 <xsl:template match="footnote" mode="no.anchor.mode">
565   <!-- nop, suppressed -->
566 </xsl:template>
567
568 <xsl:template match="anchor" mode="no.anchor.mode">
569   <!-- nop, suppressed -->
570 </xsl:template>
571
572 <xsl:template match="ulink" mode="no.anchor.mode">
573   <xsl:apply-templates/>
574 </xsl:template>
575
576 <xsl:template match="link" mode="no.anchor.mode">
577   <xsl:apply-templates/>
578 </xsl:template>
579
580 <xsl:template match="olink" mode="no.anchor.mode">
581   <xsl:apply-templates/>
582 </xsl:template>
583
584 <xsl:template match="indexterm" mode="no.anchor.mode">
585   <!-- nop, suppressed -->
586 </xsl:template>
587
588 <xsl:template match="xref" mode="no.anchor.mode">
589   <!-- FIXME: this should generate the text without the link... -->
590 </xsl:template>
591
592 <!-- ============================================================ -->
593
594 </xsl:stylesheet>
595