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"
7 <!-- ********************************************************************
8 $Id: titles.xsl,v 1.2 2004/01/04 09:25:57 j-devenish Exp $
9 ********************************************************************
11 This file is part of the XSL DocBook Stylesheet distribution.
13 Copyright (C) 1999, 2000, 2001, 2002 Norman Walsh.
14 ******************************************************************** -->
16 <!-- ==================================================================== -->
20 <doc:mode mode="title.markup" xmlns="">
21 <refpurpose>Provides access to element titles</refpurpose>
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.
30 <xsl:template match="*" mode="title.markup">
31 <xsl:param name="allow-anchors" select="0"/>
32 <xsl:param name="verbose" select="1"/>
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>
40 <xsl:when test="local-name(.) = 'partintro'">
41 <!-- partintro's don't have titles, use the parent (part or reference)
43 <xsl:apply-templates select="parent::*" mode="title.markup"/>
46 <xsl:if test="$verbose">
48 <xsl:text>Request for title of element with no title: </xsl:text>
49 <xsl:value-of select="name(.)"/>
51 <xsl:text> (id="</xsl:text>
52 <xsl:value-of select="@id"/>
53 <xsl:text>")</xsl:text>
57 <xsl:text>???TITLE???</xsl:text>
62 <xsl:template match="title" mode="title.markup">
63 <xsl:param name="allow-anchors" select="0"/>
66 <xsl:when test="$allow-anchors != 0">
67 <xsl:apply-templates/>
70 <xsl:apply-templates mode="no.anchor.mode"/>
75 <!-- only occurs in HTML Tables! -->
76 <xsl:template match="caption" mode="title.markup">
77 <xsl:param name="allow-anchors" select="0"/>
80 <xsl:when test="$allow-anchors != 0">
81 <xsl:apply-templates/>
84 <xsl:apply-templates mode="no.anchor.mode"/>
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]"
93 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
94 </xsl:apply-templates>
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]"
101 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
102 </xsl:apply-templates>
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]"
109 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
110 </xsl:apply-templates>
113 <xsl:template match="preface|chapter|appendix" mode="title.markup">
114 <xsl:param name="allow-anchors" select="0"/>
118 <xsl:value-of select="name(.)"/>
119 <xsl:text> </xsl:text>
120 <xsl:value-of select="$allow-anchors"/>
124 <xsl:variable name="title" select="(docinfo/title
129 <xsl:apply-templates select="$title" mode="title.markup">
130 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
131 </xsl:apply-templates>
134 <xsl:template match="dedication" mode="title.markup">
135 <xsl:param name="allow-anchors" select="0"/>
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>
143 <xsl:call-template name="gentext">
144 <xsl:with-param name="key" select="'Dedication'"/>
150 <xsl:template match="colophon" mode="title.markup">
151 <xsl:param name="allow-anchors" select="0"/>
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>
159 <xsl:call-template name="gentext">
160 <xsl:with-param name="key" select="'Colophon'"/>
166 <xsl:template match="article" mode="title.markup">
167 <xsl:param name="allow-anchors" select="0"/>
168 <xsl:variable name="title" select="(artheader/title
172 <xsl:apply-templates select="$title" mode="title.markup">
173 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
174 </xsl:apply-templates>
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]"
181 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
182 </xsl:apply-templates>
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"/>
192 <xsl:variable name="title">
194 <xsl:when test="$refentrytitle">
195 <xsl:apply-templates select="$refentrytitle[1]" mode="title.markup"/>
197 <xsl:when test="$refname">
198 <xsl:apply-templates select="$refname[1]" mode="title.markup"/>
200 <xsl:otherwise>REFENTRY WITHOUT TITLE???</xsl:otherwise>
204 <xsl:copy-of select="$title"/>
207 <xsl:template match="refentrytitle|refname" mode="title.markup">
208 <xsl:param name="allow-anchors" select="0"/>
210 <xsl:when test="$allow-anchors != 0">
211 <xsl:apply-templates/>
214 <xsl:apply-templates mode="no.anchor.mode"/>
219 <xsl:template match="section
220 |sect1|sect2|sect3|sect4|sect5
221 |refsect1|refsect2|refsect3
224 <xsl:param name="allow-anchors" select="0"/>
225 <xsl:variable name="title" select="(sectioninfo/title
236 <xsl:apply-templates select="$title" mode="title.markup">
237 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
238 </xsl:apply-templates>
241 <xsl:template match="bridgehead" mode="title.markup">
242 <xsl:apply-templates mode="title.markup"/>
245 <xsl:template match="refsynopsisdiv" mode="title.markup">
246 <xsl:param name="allow-anchors" select="0"/>
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>
254 <xsl:call-template name="gentext">
255 <xsl:with-param name="key" select="'RefSynopsisDiv'"/>
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]"/>
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>
271 <xsl:call-template name="gentext">
272 <xsl:with-param name="key" select="'Bibliography'"/>
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]"/>
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>
288 <xsl:call-template name="gentext.element.name">
289 <xsl:with-param name="element.name" select="name(.)"/>
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>
302 <xsl:template match="glossterm" mode="title.markup">
303 <xsl:param name="allow-anchors" select="0"/>
306 <xsl:when test="$allow-anchors != 0">
307 <xsl:apply-templates/>
310 <xsl:apply-templates mode="no.anchor.mode"/>
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]"/>
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>
325 <xsl:call-template name="gentext">
326 <xsl:with-param name="key" select="'Index'"/>
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]"/>
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>
342 <xsl:call-template name="gentext">
343 <xsl:with-param name="key" select="'SetIndex'"/>
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>
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>
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>
370 <xsl:template match="abstract" mode="title.markup">
371 <xsl:param name="allow-anchors" select="0"/>
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>
379 <xsl:call-template name="gentext">
380 <xsl:with-param name="key" select="'Abstract'"/>
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]"/>
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>
396 <xsl:call-template name="gentext">
397 <xsl:with-param name="key">
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>
411 <xsl:template match="question" mode="title.markup">
412 <!-- questions don't have titles -->
413 <xsl:text>Question</xsl:text>
416 <xsl:template match="answer" mode="title.markup">
417 <!-- answers don't have titles -->
418 <xsl:text>Answer</xsl:text>
421 <xsl:template match="qandaentry" mode="title.markup">
422 <!-- qandaentrys are represented by the first question in them -->
423 <xsl:text>Question</xsl:text>
426 <xsl:template match="legalnotice" mode="title.markup">
427 <xsl:param name="allow-anchors" select="0"/>
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>
435 <xsl:call-template name="gentext">
436 <xsl:with-param name="key" select="'LegalNotice'"/>
442 <!-- ============================================================ -->
444 <xsl:template match="*" mode="titleabbrev.markup">
445 <xsl:param name="allow-anchors" select="0"/>
446 <xsl:param name="verbose" select="1"/>
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>
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>
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"/>
467 <xsl:variable name="titleabbrev" select="(docinfo/titleabbrev
468 |prefaceinfo/titleabbrev
469 |chapterinfo/titleabbrev
470 |appendixinfo/titleabbrev
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>
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>
488 <xsl:template match="article" mode="titleabbrev.markup">
489 <xsl:param name="allow-anchors" select="0"/>
490 <xsl:param name="verbose" select="1"/>
492 <xsl:variable name="titleabbrev" select="(artheader/titleabbrev
493 |articleinfo/titleabbrev
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>
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>
511 <xsl:template match="section
512 |sect1|sect2|sect3|sect4|sect5
513 |refsect1|refsect2|refsect3
515 mode="titleabbrev.markup">
516 <xsl:param name="allow-anchors" select="0"/>
517 <xsl:param name="verbose" select="1"/>
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
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>
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>
545 <xsl:template match="titleabbrev" mode="title.markup">
546 <xsl:param name="allow-anchors" select="0"/>
549 <xsl:when test="$allow-anchors != 0">
550 <xsl:apply-templates/>
553 <xsl:apply-templates mode="no.anchor.mode"/>
558 <!-- ============================================================ -->
560 <xsl:template match="*" mode="no.anchor.mode">
561 <xsl:apply-templates mode="no.anchor.mode"/>
564 <xsl:template match="footnote" mode="no.anchor.mode">
565 <!-- nop, suppressed -->
568 <xsl:template match="anchor" mode="no.anchor.mode">
569 <!-- nop, suppressed -->
572 <xsl:template match="ulink" mode="no.anchor.mode">
573 <xsl:apply-templates/>
576 <xsl:template match="link" mode="no.anchor.mode">
577 <xsl:apply-templates/>
580 <xsl:template match="olink" mode="no.anchor.mode">
581 <xsl:apply-templates/>
584 <xsl:template match="indexterm" mode="no.anchor.mode">
585 <!-- nop, suppressed -->
588 <xsl:template match="xref" mode="no.anchor.mode">
589 <!-- FIXME: this should generate the text without the link... -->
592 <!-- ============================================================ -->