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 <!-- ********************************************************************
9 ********************************************************************
11 This file is part of the XSL DocBook Stylesheet distribution.
12 See ../README or http://nwalsh.com/docbook/xsl/ for copyright
13 and other information.
15 ******************************************************************** -->
17 <!-- ==================================================================== -->
21 <doc:mode mode="title.markup" xmlns="">
22 <refpurpose>Provides access to element titles</refpurpose>
24 <para>Processing an element in the
25 <literal role="mode">title.markup</literal> mode produces the
26 title of the element. This does not include the label.
31 <xsl:template match="*" mode="title.markup">
32 <xsl:param name="allow-anchors" select="0"/>
33 <xsl:param name="verbose" select="1"/>
36 <xsl:when test="title">
37 <xsl:apply-templates select="title[1]" mode="title.markup">
38 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
39 </xsl:apply-templates>
41 <xsl:when test="local-name(.) = 'partintro'">
42 <!-- partintro's don't have titles, use the parent (part or reference)
44 <xsl:apply-templates select="parent::*" mode="title.markup"/>
47 <xsl:if test="$verbose != 0">
49 <xsl:text>Request for title of element with no title: </xsl:text>
50 <xsl:value-of select="name(.)"/>
52 <xsl:text> (id="</xsl:text>
53 <xsl:value-of select="@id"/>
54 <xsl:text>")</xsl:text>
58 <xsl:text>???TITLE???</xsl:text>
63 <xsl:template match="title" mode="title.markup">
64 <xsl:param name="allow-anchors" select="0"/>
67 <xsl:when test="$allow-anchors != 0">
68 <xsl:apply-templates/>
71 <xsl:apply-templates mode="no.anchor.mode"/>
76 <!-- only occurs in HTML Tables! -->
77 <xsl:template match="caption" mode="title.markup">
78 <xsl:param name="allow-anchors" select="0"/>
81 <xsl:when test="$allow-anchors != 0">
82 <xsl:apply-templates/>
85 <xsl:apply-templates mode="no.anchor.mode"/>
90 <xsl:template match="set" mode="title.markup">
91 <xsl:param name="allow-anchors" select="0"/>
92 <xsl:apply-templates select="(setinfo/title|info/title|title)[1]"
94 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
95 </xsl:apply-templates>
98 <xsl:template match="book" mode="title.markup">
99 <xsl:param name="allow-anchors" select="0"/>
100 <xsl:apply-templates select="(bookinfo/title|info/title|title)[1]"
102 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
103 </xsl:apply-templates>
106 <xsl:template match="part" mode="title.markup">
107 <xsl:param name="allow-anchors" select="0"/>
108 <xsl:apply-templates select="(partinfo/title|info/title|docinfo/title|title)[1]"
110 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
111 </xsl:apply-templates>
114 <xsl:template match="preface|chapter|appendix" mode="title.markup">
115 <xsl:param name="allow-anchors" select="0"/>
119 <xsl:value-of select="name(.)"/>
120 <xsl:text> </xsl:text>
121 <xsl:value-of select="$allow-anchors"/>
125 <xsl:variable name="title" select="(docinfo/title
131 <xsl:apply-templates select="$title" mode="title.markup">
132 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
133 </xsl:apply-templates>
136 <xsl:template match="dedication" mode="title.markup">
137 <xsl:param name="allow-anchors" select="0"/>
139 <xsl:when test="title">
140 <xsl:apply-templates select="title" mode="title.markup">
141 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
142 </xsl:apply-templates>
145 <xsl:call-template name="gentext">
146 <xsl:with-param name="key" select="'Dedication'"/>
152 <xsl:template match="colophon" mode="title.markup">
153 <xsl:param name="allow-anchors" select="0"/>
155 <xsl:when test="title">
156 <xsl:apply-templates select="title" mode="title.markup">
157 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
158 </xsl:apply-templates>
161 <xsl:call-template name="gentext">
162 <xsl:with-param name="key" select="'Colophon'"/>
168 <xsl:template match="article" mode="title.markup">
169 <xsl:param name="allow-anchors" select="0"/>
170 <xsl:variable name="title" select="(artheader/title
175 <xsl:apply-templates select="$title" mode="title.markup">
176 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
177 </xsl:apply-templates>
180 <xsl:template match="reference" mode="title.markup">
181 <xsl:param name="allow-anchors" select="0"/>
182 <xsl:apply-templates select="(referenceinfo/title|docinfo/title|info/title|title)[1]"
184 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
185 </xsl:apply-templates>
188 <xsl:template match="refentry" mode="title.markup">
189 <xsl:param name="allow-anchors" select="0"/>
190 <xsl:variable name="refmeta" select=".//refmeta"/>
191 <xsl:variable name="refentrytitle" select="$refmeta//refentrytitle"/>
192 <xsl:variable name="refnamediv" select=".//refnamediv"/>
193 <xsl:variable name="refname" select="$refnamediv//refname"/>
194 <xsl:variable name="refdesc" select="$refnamediv//refdescriptor"/>
196 <xsl:variable name="title">
198 <xsl:when test="$refentrytitle">
199 <xsl:apply-templates select="$refentrytitle[1]" mode="title.markup"/>
201 <xsl:when test="$refdesc">
202 <xsl:apply-templates select="$refdesc" mode="title.markup"/>
204 <xsl:when test="$refname">
205 <xsl:apply-templates select="$refname[1]" mode="title.markup"/>
207 <xsl:otherwise>REFENTRY WITHOUT TITLE???</xsl:otherwise>
211 <xsl:copy-of select="$title"/>
214 <xsl:template match="refentrytitle|refname|refdescriptor" mode="title.markup">
215 <xsl:param name="allow-anchors" select="0"/>
217 <xsl:when test="$allow-anchors != 0">
218 <xsl:apply-templates/>
221 <xsl:apply-templates mode="no.anchor.mode"/>
226 <xsl:template match="section
227 |sect1|sect2|sect3|sect4|sect5
228 |refsect1|refsect2|refsect3
231 <xsl:param name="allow-anchors" select="0"/>
232 <xsl:variable name="title" select="(info/title
244 <xsl:apply-templates select="$title" mode="title.markup">
245 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
246 </xsl:apply-templates>
249 <xsl:template match="bridgehead" mode="title.markup">
250 <xsl:apply-templates mode="title.markup"/>
253 <xsl:template match="refsynopsisdiv" mode="title.markup">
254 <xsl:param name="allow-anchors" select="0"/>
256 <xsl:when test="title">
257 <xsl:apply-templates select="title" mode="title.markup">
258 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
259 </xsl:apply-templates>
262 <xsl:call-template name="gentext">
263 <xsl:with-param name="key" select="'RefSynopsisDiv'"/>
269 <xsl:template match="bibliography" mode="title.markup">
270 <xsl:param name="allow-anchors" select="0"/>
271 <xsl:variable name="title" select="(bibliographyinfo/title|info/title|title)[1]"/>
273 <xsl:when test="$title">
274 <xsl:apply-templates select="$title" mode="title.markup">
275 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
276 </xsl:apply-templates>
279 <xsl:call-template name="gentext">
280 <xsl:with-param name="key" select="'Bibliography'"/>
286 <xsl:template match="glossary" mode="title.markup">
287 <xsl:param name="allow-anchors" select="0"/>
288 <xsl:variable name="title" select="(glossaryinfo/title|info/title|title)[1]"/>
290 <xsl:when test="$title">
291 <xsl:apply-templates select="$title" mode="title.markup">
292 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
293 </xsl:apply-templates>
296 <xsl:call-template name="gentext.element.name">
297 <xsl:with-param name="element.name" select="name(.)"/>
303 <xsl:template match="glossentry" mode="title.markup">
304 <xsl:param name="allow-anchors" select="0"/>
305 <xsl:apply-templates select="glossterm" mode="title.markup">
306 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
307 </xsl:apply-templates>
310 <xsl:template match="glossterm" mode="title.markup">
311 <xsl:param name="allow-anchors" select="0"/>
314 <xsl:when test="$allow-anchors != 0">
315 <xsl:apply-templates/>
318 <xsl:apply-templates mode="no.anchor.mode"/>
323 <xsl:template match="index" mode="title.markup">
324 <xsl:param name="allow-anchors" select="0"/>
325 <xsl:variable name="title" select="(indexinfo/title|info/title|title)[1]"/>
327 <xsl:when test="$title">
328 <xsl:apply-templates select="$title" mode="title.markup">
329 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
330 </xsl:apply-templates>
333 <xsl:call-template name="gentext">
334 <xsl:with-param name="key" select="'Index'"/>
340 <xsl:template match="setindex" mode="title.markup">
341 <xsl:param name="allow-anchors" select="0"/>
342 <xsl:variable name="title" select="(setindexinfo/title|info/title|title)[1]"/>
344 <xsl:when test="$title">
345 <xsl:apply-templates select="$title" mode="title.markup">
346 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
347 </xsl:apply-templates>
350 <xsl:call-template name="gentext">
351 <xsl:with-param name="key" select="'SetIndex'"/>
357 <xsl:template match="figure|example|equation" mode="title.markup">
358 <xsl:param name="allow-anchors" select="0"/>
359 <xsl:apply-templates select="title|info/title" mode="title.markup">
360 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
361 </xsl:apply-templates>
364 <xsl:template match="table" mode="title.markup">
365 <xsl:param name="allow-anchors" select="0"/>
366 <xsl:apply-templates select="title|caption" mode="title.markup">
367 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
368 </xsl:apply-templates>
371 <xsl:template match="procedure" mode="title.markup">
372 <xsl:param name="allow-anchors" select="0"/>
373 <xsl:apply-templates select="title" mode="title.markup">
374 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
375 </xsl:apply-templates>
378 <xsl:template match="abstract" mode="title.markup">
379 <xsl:param name="allow-anchors" select="0"/>
381 <xsl:when test="title">
382 <xsl:apply-templates select="title" mode="title.markup">
383 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
384 </xsl:apply-templates>
387 <xsl:call-template name="gentext">
388 <xsl:with-param name="key" select="'Abstract'"/>
394 <xsl:template match="caution|tip|warning|important|note" mode="title.markup">
395 <xsl:param name="allow-anchors" select="0"/>
396 <xsl:variable name="title" select="title[1]"/>
398 <xsl:when test="$title">
399 <xsl:apply-templates select="$title" mode="title.markup">
400 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
401 </xsl:apply-templates>
404 <xsl:call-template name="gentext">
405 <xsl:with-param name="key">
407 <xsl:when test="local-name(.)='note'">Note</xsl:when>
408 <xsl:when test="local-name(.)='important'">Important</xsl:when>
409 <xsl:when test="local-name(.)='caution'">Caution</xsl:when>
410 <xsl:when test="local-name(.)='warning'">Warning</xsl:when>
411 <xsl:when test="local-name(.)='tip'">Tip</xsl:when>
419 <xsl:template match="question" mode="title.markup">
420 <!-- questions don't have titles -->
421 <xsl:text>Question</xsl:text>
424 <xsl:template match="answer" mode="title.markup">
425 <!-- answers don't have titles -->
426 <xsl:text>Answer</xsl:text>
429 <xsl:template match="qandaentry" mode="title.markup">
430 <!-- qandaentrys are represented by the first question in them -->
431 <xsl:text>Question</xsl:text>
434 <xsl:template match="legalnotice" mode="title.markup">
435 <xsl:param name="allow-anchors" select="0"/>
437 <xsl:when test="title">
438 <xsl:apply-templates select="title" mode="title.markup">
439 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
440 </xsl:apply-templates>
443 <xsl:call-template name="gentext">
444 <xsl:with-param name="key" select="'LegalNotice'"/>
450 <!-- ============================================================ -->
452 <xsl:template match="*" mode="titleabbrev.markup">
453 <xsl:param name="allow-anchors" select="0"/>
454 <xsl:param name="verbose" select="1"/>
457 <xsl:when test="titleabbrev">
458 <xsl:apply-templates select="titleabbrev[1]" mode="title.markup">
459 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
460 </xsl:apply-templates>
463 <xsl:apply-templates select="." mode="title.markup">
464 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
465 <xsl:with-param name="verbose" select="$verbose"/>
466 </xsl:apply-templates>
471 <xsl:template match="book|preface|chapter|appendix" mode="titleabbrev.markup">
472 <xsl:param name="allow-anchors" select="0"/>
473 <xsl:param name="verbose" select="1"/>
475 <xsl:variable name="titleabbrev" select="(docinfo/titleabbrev
476 |bookinfo/titleabbrev
478 |prefaceinfo/titleabbrev
479 |chapterinfo/titleabbrev
480 |appendixinfo/titleabbrev
484 <xsl:when test="$titleabbrev">
485 <xsl:apply-templates select="$titleabbrev" mode="title.markup">
486 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
487 </xsl:apply-templates>
490 <xsl:apply-templates select="." mode="title.markup">
491 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
492 <xsl:with-param name="verbose" select="$verbose"/>
493 </xsl:apply-templates>
498 <xsl:template match="article" mode="titleabbrev.markup">
499 <xsl:param name="allow-anchors" select="0"/>
500 <xsl:param name="verbose" select="1"/>
502 <xsl:variable name="titleabbrev" select="(artheader/titleabbrev
503 |articleinfo/titleabbrev
508 <xsl:when test="$titleabbrev">
509 <xsl:apply-templates select="$titleabbrev" mode="title.markup">
510 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
511 </xsl:apply-templates>
514 <xsl:apply-templates select="." mode="title.markup">
515 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
516 <xsl:with-param name="verbose" select="$verbose"/>
517 </xsl:apply-templates>
522 <xsl:template match="section
523 |sect1|sect2|sect3|sect4|sect5
524 |refsect1|refsect2|refsect3
526 mode="titleabbrev.markup">
527 <xsl:param name="allow-anchors" select="0"/>
528 <xsl:param name="verbose" select="1"/>
530 <xsl:variable name="titleabbrev" select="(info/titleabbrev
531 |sectioninfo/titleabbrev
532 |sect1info/titleabbrev
533 |sect2info/titleabbrev
534 |sect3info/titleabbrev
535 |sect4info/titleabbrev
536 |sect5info/titleabbrev
537 |refsect1info/titleabbrev
538 |refsect2info/titleabbrev
539 |refsect3info/titleabbrev
543 <xsl:when test="$titleabbrev">
544 <xsl:apply-templates select="$titleabbrev" mode="title.markup">
545 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
546 </xsl:apply-templates>
549 <xsl:apply-templates select="." mode="title.markup">
550 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
551 <xsl:with-param name="verbose" select="$verbose"/>
552 </xsl:apply-templates>
557 <xsl:template match="titleabbrev" mode="title.markup">
558 <xsl:param name="allow-anchors" select="0"/>
561 <xsl:when test="$allow-anchors != 0">
562 <xsl:apply-templates/>
565 <xsl:apply-templates mode="no.anchor.mode"/>
570 <!-- ============================================================ -->
572 <xsl:template match="*" mode="no.anchor.mode">
573 <!-- Switch to normal mode if no links -->
575 <xsl:when test="descendant-or-self::footnote or
576 descendant-or-self::anchor or
577 descendant-or-self::ulink or
578 descendant-or-self::link or
579 descendant-or-self::olink or
580 descendant-or-self::xref or
581 descendant-or-self::indexterm">
583 <xsl:apply-templates mode="no.anchor.mode"/>
586 <xsl:apply-templates select="."/>
591 <xsl:template match="footnote" mode="no.anchor.mode">
592 <!-- nop, suppressed -->
595 <xsl:template match="anchor" mode="no.anchor.mode">
596 <!-- nop, suppressed -->
599 <xsl:template match="ulink" mode="no.anchor.mode">
600 <xsl:apply-templates/>
603 <xsl:template match="link" mode="no.anchor.mode">
604 <xsl:apply-templates/>
607 <xsl:template match="olink" mode="no.anchor.mode">
608 <xsl:apply-templates/>
611 <xsl:template match="indexterm" mode="no.anchor.mode">
612 <!-- nop, suppressed -->
615 <xsl:template match="xref" mode="no.anchor.mode">
616 <xsl:variable name="targets" select="key('id',@linkend)"/>
617 <xsl:variable name="target" select="$targets[1]"/>
618 <xsl:variable name="refelem" select="local-name($target)"/>
620 <xsl:call-template name="check.id.unique">
621 <xsl:with-param name="linkend" select="@linkend"/>
625 <xsl:when test="count($target) = 0">
627 <xsl:text>XRef to nonexistent id: </xsl:text>
628 <xsl:value-of select="@linkend"/>
630 <xsl:text>???</xsl:text>
633 <xsl:when test="@endterm">
634 <xsl:variable name="etargets" select="key('id',@endterm)"/>
635 <xsl:variable name="etarget" select="$etargets[1]"/>
637 <xsl:when test="count($etarget) = 0">
639 <xsl:value-of select="count($etargets)"/>
640 <xsl:text>Endterm points to nonexistent ID: </xsl:text>
641 <xsl:value-of select="@endterm"/>
643 <xsl:text>???</xsl:text>
646 <xsl:apply-templates select="$etarget" mode="endterm"/>
651 <xsl:when test="$target/@xreflabel">
652 <xsl:call-template name="xref.xreflabel">
653 <xsl:with-param name="target" select="$target"/>
658 <xsl:apply-templates select="$target" mode="xref-to-prefix"/>
660 <xsl:apply-templates select="$target" mode="xref-to">
661 <xsl:with-param name="referrer" select="."/>
662 <xsl:with-param name="xrefstyle">
664 <xsl:when test="@role and not(@xrefstyle) and $use.role.as.xrefstyle != 0">
665 <xsl:value-of select="@role"/>
668 <xsl:value-of select="@xrefstyle"/>
672 </xsl:apply-templates>
674 <xsl:apply-templates select="$target" mode="xref-to-suffix"/>
679 <!-- ============================================================ -->