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.1 2007/03/10 05:14:55 scott Exp $
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"/>
35 <!-- * FIXME: this should handle other *info elements as well -->
36 <!-- * but this is good enough for now. -->
37 <xsl:when test=
"title|info/title">
38 <xsl:apply-templates select=
"title[1]|info/title[1]" mode=
"title.markup">
39 <xsl:with-param name=
"allow-anchors" select=
"$allow-anchors"/>
40 </xsl:apply-templates>
42 <xsl:when test=
"local-name(.) = 'partintro'">
43 <!-- partintro's don't have titles, use the parent (part or reference)
45 <xsl:apply-templates select=
"parent::*" mode=
"title.markup"/>
48 <xsl:if test=
"$verbose != 0">
50 <xsl:text>Request for title of element with no title:
</xsl:text>
51 <xsl:value-of select=
"local-name(.)"/>
54 <xsl:text> (
id=
"</xsl:text>
55 <xsl:value-of select="@id
"/>
56 <xsl:text>")
</xsl:text>
58 <xsl:when test=
"@xml:id">
59 <xsl:text> (xml:
id=
"</xsl:text>
60 <xsl:value-of select="@xml:id
"/>
61 <xsl:text>")
</xsl:text>
66 <xsl:text>???TITLE???
</xsl:text>
71 <xsl:template match=
"title" mode=
"title.markup">
72 <xsl:param name=
"allow-anchors" select=
"0"/>
75 <xsl:when test=
"$allow-anchors != 0">
76 <xsl:apply-templates/>
79 <xsl:apply-templates mode=
"no.anchor.mode"/>
84 <!-- only occurs in HTML Tables! -->
85 <xsl:template match=
"caption" mode=
"title.markup">
86 <xsl:param name=
"allow-anchors" select=
"0"/>
89 <xsl:when test=
"$allow-anchors != 0">
90 <xsl:apply-templates/>
93 <xsl:apply-templates mode=
"no.anchor.mode"/>
98 <xsl:template match=
"set" mode=
"title.markup">
99 <xsl:param name=
"allow-anchors" select=
"0"/>
100 <xsl:apply-templates select=
"(setinfo/title|info/title|title)[1]"
102 <xsl:with-param name=
"allow-anchors" select=
"$allow-anchors"/>
103 </xsl:apply-templates>
106 <xsl:template match=
"book" mode=
"title.markup">
107 <xsl:param name=
"allow-anchors" select=
"0"/>
108 <xsl:apply-templates select=
"(bookinfo/title|info/title|title)[1]"
110 <xsl:with-param name=
"allow-anchors" select=
"$allow-anchors"/>
111 </xsl:apply-templates>
114 <xsl:template match=
"part" mode=
"title.markup">
115 <xsl:param name=
"allow-anchors" select=
"0"/>
116 <xsl:apply-templates select=
"(partinfo/title|info/title|docinfo/title|title)[1]"
118 <xsl:with-param name=
"allow-anchors" select=
"$allow-anchors"/>
119 </xsl:apply-templates>
122 <xsl:template match=
"preface|chapter|appendix" mode=
"title.markup">
123 <xsl:param name=
"allow-anchors" select=
"0"/>
127 <xsl:value-of select="local-name(.)"/>
128 <xsl:text> </xsl:text>
129 <xsl:value-of select="$allow-anchors"/>
133 <xsl:variable name=
"title" select=
"(docinfo/title
139 <xsl:apply-templates select=
"$title" mode=
"title.markup">
140 <xsl:with-param name=
"allow-anchors" select=
"$allow-anchors"/>
141 </xsl:apply-templates>
144 <xsl:template match=
"dedication" mode=
"title.markup">
145 <xsl:param name=
"allow-anchors" select=
"0"/>
147 <xsl:when test=
"title">
148 <xsl:apply-templates select=
"(title|info/title)[1]" mode=
"title.markup">
149 <xsl:with-param name=
"allow-anchors" select=
"$allow-anchors"/>
150 </xsl:apply-templates>
153 <xsl:call-template name=
"gentext">
154 <xsl:with-param name=
"key" select=
"'Dedication'"/>
160 <xsl:template match=
"colophon" mode=
"title.markup">
161 <xsl:param name=
"allow-anchors" select=
"0"/>
163 <xsl:when test=
"title">
164 <xsl:apply-templates select=
"(title|info/title)[1]" mode=
"title.markup">
165 <xsl:with-param name=
"allow-anchors" select=
"$allow-anchors"/>
166 </xsl:apply-templates>
169 <xsl:call-template name=
"gentext">
170 <xsl:with-param name=
"key" select=
"'Colophon'"/>
176 <xsl:template match=
"article" mode=
"title.markup">
177 <xsl:param name=
"allow-anchors" select=
"0"/>
178 <xsl:variable name=
"title" select=
"(artheader/title
183 <xsl:apply-templates select=
"$title" mode=
"title.markup">
184 <xsl:with-param name=
"allow-anchors" select=
"$allow-anchors"/>
185 </xsl:apply-templates>
188 <xsl:template match=
"reference" mode=
"title.markup">
189 <xsl:param name=
"allow-anchors" select=
"0"/>
190 <xsl:apply-templates select=
"(referenceinfo/title|docinfo/title|info/title|title)[1]"
192 <xsl:with-param name=
"allow-anchors" select=
"$allow-anchors"/>
193 </xsl:apply-templates>
196 <xsl:template match=
"refentry" mode=
"title.markup">
197 <xsl:param name=
"allow-anchors" select=
"0"/>
198 <xsl:variable name=
"refmeta" select=
".//refmeta"/>
199 <xsl:variable name=
"refentrytitle" select=
"$refmeta//refentrytitle"/>
200 <xsl:variable name=
"refnamediv" select=
".//refnamediv"/>
201 <xsl:variable name=
"refname" select=
"$refnamediv//refname"/>
202 <xsl:variable name=
"refdesc" select=
"$refnamediv//refdescriptor"/>
204 <xsl:variable name=
"title">
206 <xsl:when test=
"$refentrytitle">
207 <xsl:apply-templates select=
"$refentrytitle[1]" mode=
"title.markup"/>
209 <xsl:when test=
"$refdesc">
210 <xsl:apply-templates select=
"$refdesc" mode=
"title.markup"/>
212 <xsl:when test=
"$refname">
213 <xsl:apply-templates select=
"$refname[1]" mode=
"title.markup"/>
215 <xsl:otherwise>REFENTRY WITHOUT TITLE???
</xsl:otherwise>
219 <xsl:copy-of select=
"$title"/>
222 <xsl:template match=
"refentrytitle|refname|refdescriptor" mode=
"title.markup">
223 <xsl:param name=
"allow-anchors" select=
"0"/>
225 <xsl:when test=
"$allow-anchors != 0">
226 <xsl:apply-templates/>
229 <xsl:apply-templates mode=
"no.anchor.mode"/>
234 <xsl:template match=
"section
235 |sect1|sect2|sect3|sect4|sect5
236 |refsect1|refsect2|refsect3|refsection
239 <xsl:param name=
"allow-anchors" select=
"0"/>
240 <xsl:variable name=
"title" select=
"(info/title
250 |refsectioninfo/title
253 <xsl:apply-templates select=
"$title" mode=
"title.markup">
254 <xsl:with-param name=
"allow-anchors" select=
"$allow-anchors"/>
255 </xsl:apply-templates>
258 <xsl:template match=
"bridgehead" mode=
"title.markup">
259 <xsl:apply-templates mode=
"title.markup"/>
262 <xsl:template match=
"refsynopsisdiv" mode=
"title.markup">
263 <xsl:param name=
"allow-anchors" select=
"0"/>
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=
"'RefSynopsisDiv'"/>
278 <xsl:template match=
"bibliography" mode=
"title.markup">
279 <xsl:param name=
"allow-anchors" select=
"0"/>
280 <xsl:variable name=
"title" select=
"(bibliographyinfo/title|info/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">
289 <xsl:with-param name=
"key" select=
"'Bibliography'"/>
295 <xsl:template match=
"glossary" mode=
"title.markup">
296 <xsl:param name=
"allow-anchors" select=
"0"/>
297 <xsl:variable name=
"title" select=
"(glossaryinfo/title|info/title|title)[1]"/>
299 <xsl:when test=
"$title">
300 <xsl:apply-templates select=
"$title" mode=
"title.markup">
301 <xsl:with-param name=
"allow-anchors" select=
"$allow-anchors"/>
302 </xsl:apply-templates>
305 <xsl:call-template name=
"gentext.element.name">
306 <xsl:with-param name=
"element.name" select=
"local-name(.)"/>
312 <xsl:template match=
"glossdiv" mode=
"title.markup">
313 <xsl:param name=
"allow-anchors" select=
"0"/>
314 <xsl:variable name=
"title" select=
"(info/title|title)[1]"/>
316 <xsl:when test=
"$title">
317 <xsl:apply-templates select=
"$title" mode=
"title.markup">
318 <xsl:with-param name=
"allow-anchors" select=
"$allow-anchors"/>
319 </xsl:apply-templates>
322 <xsl:message>ERROR: glossdiv missing its required title
</xsl:message>
327 <xsl:template match=
"glossentry" mode=
"title.markup">
328 <xsl:param name=
"allow-anchors" select=
"0"/>
329 <xsl:apply-templates select=
"glossterm" mode=
"title.markup">
330 <xsl:with-param name=
"allow-anchors" select=
"$allow-anchors"/>
331 </xsl:apply-templates>
334 <xsl:template match=
"glossterm" mode=
"title.markup">
335 <xsl:param name=
"allow-anchors" select=
"0"/>
338 <xsl:when test=
"$allow-anchors != 0">
339 <xsl:apply-templates/>
342 <xsl:apply-templates mode=
"no.anchor.mode"/>
347 <xsl:template match=
"index" mode=
"title.markup">
348 <xsl:param name=
"allow-anchors" select=
"0"/>
349 <xsl:variable name=
"title" select=
"(indexinfo/title|info/title|title)[1]"/>
351 <xsl:when test=
"$title">
352 <xsl:apply-templates select=
"$title" mode=
"title.markup">
353 <xsl:with-param name=
"allow-anchors" select=
"$allow-anchors"/>
354 </xsl:apply-templates>
357 <xsl:call-template name=
"gentext">
358 <xsl:with-param name=
"key" select=
"'Index'"/>
364 <xsl:template match=
"setindex" mode=
"title.markup">
365 <xsl:param name=
"allow-anchors" select=
"0"/>
366 <xsl:variable name=
"title" select=
"(setindexinfo/title|info/title|title)[1]"/>
368 <xsl:when test=
"$title">
369 <xsl:apply-templates select=
"$title" mode=
"title.markup">
370 <xsl:with-param name=
"allow-anchors" select=
"$allow-anchors"/>
371 </xsl:apply-templates>
374 <xsl:call-template name=
"gentext">
375 <xsl:with-param name=
"key" select=
"'SetIndex'"/>
381 <xsl:template match=
"figure|example|equation" mode=
"title.markup">
382 <xsl:param name=
"allow-anchors" select=
"0"/>
383 <xsl:apply-templates select=
"title|info/title" mode=
"title.markup">
384 <xsl:with-param name=
"allow-anchors" select=
"$allow-anchors"/>
385 </xsl:apply-templates>
388 <xsl:template match=
"table" mode=
"title.markup">
389 <xsl:param name=
"allow-anchors" select=
"0"/>
390 <xsl:apply-templates select=
"title|caption" mode=
"title.markup">
391 <xsl:with-param name=
"allow-anchors" select=
"$allow-anchors"/>
392 </xsl:apply-templates>
395 <xsl:template match=
"procedure" mode=
"title.markup">
396 <xsl:param name=
"allow-anchors" select=
"0"/>
397 <xsl:apply-templates select=
"title" mode=
"title.markup">
398 <xsl:with-param name=
"allow-anchors" select=
"$allow-anchors"/>
399 </xsl:apply-templates>
402 <xsl:template match=
"task" mode=
"title.markup">
403 <xsl:param name=
"allow-anchors" select=
"0"/>
404 <xsl:apply-templates select=
"title" mode=
"title.markup">
405 <xsl:with-param name=
"allow-anchors" select=
"$allow-anchors"/>
406 </xsl:apply-templates>
409 <xsl:template match=
"sidebar" mode=
"title.markup">
410 <xsl:param name=
"allow-anchors" select=
"0"/>
411 <xsl:apply-templates select=
"(info/title|sidebarinfo/title|title)[1]"
413 <xsl:with-param name=
"allow-anchors" select=
"$allow-anchors"/>
414 </xsl:apply-templates>
417 <xsl:template match=
"abstract" mode=
"title.markup">
418 <xsl:param name=
"allow-anchors" select=
"0"/>
420 <xsl:when test=
"title|info/title">
421 <xsl:apply-templates select=
"(title|info/title)[1]" mode=
"title.markup">
422 <xsl:with-param name=
"allow-anchors" select=
"$allow-anchors"/>
423 </xsl:apply-templates>
426 <xsl:call-template name=
"gentext">
427 <xsl:with-param name=
"key" select=
"'Abstract'"/>
433 <xsl:template match=
"caution|tip|warning|important|note" mode=
"title.markup">
434 <xsl:param name=
"allow-anchors" select=
"0"/>
435 <xsl:variable name=
"title" select=
"(title|info/title)[1]"/>
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">
446 <xsl:when test=
"local-name(.)='note'">Note
</xsl:when>
447 <xsl:when test=
"local-name(.)='important'">Important
</xsl:when>
448 <xsl:when test=
"local-name(.)='caution'">Caution
</xsl:when>
449 <xsl:when test=
"local-name(.)='warning'">Warning
</xsl:when>
450 <xsl:when test=
"local-name(.)='tip'">Tip
</xsl:when>
458 <xsl:template match=
"question" mode=
"title.markup">
459 <!-- questions don't have titles -->
460 <xsl:text>Question
</xsl:text>
463 <xsl:template match=
"answer" mode=
"title.markup">
464 <!-- answers don't have titles -->
465 <xsl:text>Answer
</xsl:text>
468 <xsl:template match=
"qandaentry" mode=
"title.markup">
469 <!-- qandaentrys are represented by the first question in them -->
470 <xsl:text>Question
</xsl:text>
473 <xsl:template match=
"qandaset" mode=
"title.markup">
474 <xsl:param name=
"allow-anchors" select=
"0"/>
475 <xsl:variable name=
"title" select=
"(info/title|
479 <xsl:when test=
"$title">
480 <xsl:apply-templates select=
"$title" mode=
"title.markup">
481 <xsl:with-param name=
"allow-anchors" select=
"$allow-anchors"/>
482 </xsl:apply-templates>
485 <xsl:call-template name=
"gentext">
486 <xsl:with-param name=
"key" select=
"'QandASet'"/>
492 <xsl:template match=
"legalnotice" mode=
"title.markup">
493 <xsl:param name=
"allow-anchors" select=
"0"/>
495 <xsl:when test=
"title">
496 <xsl:apply-templates select=
"title" mode=
"title.markup">
497 <xsl:with-param name=
"allow-anchors" select=
"$allow-anchors"/>
498 </xsl:apply-templates>
501 <xsl:call-template name=
"gentext">
502 <xsl:with-param name=
"key" select=
"'LegalNotice'"/>
508 <!-- ============================================================ -->
510 <xsl:template match=
"*" mode=
"titleabbrev.markup">
511 <xsl:param name=
"allow-anchors" select=
"0"/>
512 <xsl:param name=
"verbose" select=
"1"/>
515 <xsl:when test=
"titleabbrev">
516 <xsl:apply-templates select=
"titleabbrev[1]" mode=
"title.markup">
517 <xsl:with-param name=
"allow-anchors" select=
"$allow-anchors"/>
518 </xsl:apply-templates>
521 <xsl:apply-templates select=
"." mode=
"title.markup">
522 <xsl:with-param name=
"allow-anchors" select=
"$allow-anchors"/>
523 <xsl:with-param name=
"verbose" select=
"$verbose"/>
524 </xsl:apply-templates>
529 <xsl:template match=
"book|preface|chapter|appendix" mode=
"titleabbrev.markup">
530 <xsl:param name=
"allow-anchors" select=
"0"/>
531 <xsl:param name=
"verbose" select=
"1"/>
533 <xsl:variable name=
"titleabbrev" select=
"(docinfo/titleabbrev
534 |bookinfo/titleabbrev
536 |prefaceinfo/titleabbrev
537 |chapterinfo/titleabbrev
538 |appendixinfo/titleabbrev
542 <xsl:when test=
"$titleabbrev">
543 <xsl:apply-templates select=
"$titleabbrev" mode=
"title.markup">
544 <xsl:with-param name=
"allow-anchors" select=
"$allow-anchors"/>
545 </xsl:apply-templates>
548 <xsl:apply-templates select=
"." mode=
"title.markup">
549 <xsl:with-param name=
"allow-anchors" select=
"$allow-anchors"/>
550 <xsl:with-param name=
"verbose" select=
"$verbose"/>
551 </xsl:apply-templates>
556 <xsl:template match=
"article" mode=
"titleabbrev.markup">
557 <xsl:param name=
"allow-anchors" select=
"0"/>
558 <xsl:param name=
"verbose" select=
"1"/>
560 <xsl:variable name=
"titleabbrev" select=
"(artheader/titleabbrev
561 |articleinfo/titleabbrev
566 <xsl:when test=
"$titleabbrev">
567 <xsl:apply-templates select=
"$titleabbrev" mode=
"title.markup">
568 <xsl:with-param name=
"allow-anchors" select=
"$allow-anchors"/>
569 </xsl:apply-templates>
572 <xsl:apply-templates select=
"." mode=
"title.markup">
573 <xsl:with-param name=
"allow-anchors" select=
"$allow-anchors"/>
574 <xsl:with-param name=
"verbose" select=
"$verbose"/>
575 </xsl:apply-templates>
580 <xsl:template match=
"section
581 |sect1|sect2|sect3|sect4|sect5
582 |refsect1|refsect2|refsect3
584 mode=
"titleabbrev.markup">
585 <xsl:param name=
"allow-anchors" select=
"0"/>
586 <xsl:param name=
"verbose" select=
"1"/>
588 <xsl:variable name=
"titleabbrev" select=
"(info/titleabbrev
589 |sectioninfo/titleabbrev
590 |sect1info/titleabbrev
591 |sect2info/titleabbrev
592 |sect3info/titleabbrev
593 |sect4info/titleabbrev
594 |sect5info/titleabbrev
595 |refsect1info/titleabbrev
596 |refsect2info/titleabbrev
597 |refsect3info/titleabbrev
601 <xsl:when test=
"$titleabbrev">
602 <xsl:apply-templates select=
"$titleabbrev" mode=
"title.markup">
603 <xsl:with-param name=
"allow-anchors" select=
"$allow-anchors"/>
604 </xsl:apply-templates>
607 <xsl:apply-templates select=
"." mode=
"title.markup">
608 <xsl:with-param name=
"allow-anchors" select=
"$allow-anchors"/>
609 <xsl:with-param name=
"verbose" select=
"$verbose"/>
610 </xsl:apply-templates>
615 <xsl:template match=
"titleabbrev" mode=
"title.markup">
616 <xsl:param name=
"allow-anchors" select=
"0"/>
619 <xsl:when test=
"$allow-anchors != 0">
620 <xsl:apply-templates/>
623 <xsl:apply-templates mode=
"no.anchor.mode"/>
628 <!-- ============================================================ -->
630 <xsl:template match=
"*" mode=
"no.anchor.mode">
631 <!-- Switch to normal mode if no links -->
633 <xsl:when test=
"descendant-or-self::footnote or
634 descendant-or-self::anchor or
635 descendant-or-self::ulink or
636 descendant-or-self::link or
637 descendant-or-self::olink or
638 descendant-or-self::xref or
639 descendant-or-self::indexterm">
641 <xsl:apply-templates mode=
"no.anchor.mode"/>
644 <xsl:apply-templates select=
"."/>
649 <xsl:template match=
"footnote" mode=
"no.anchor.mode">
650 <!-- nop, suppressed -->
653 <xsl:template match=
"anchor" mode=
"no.anchor.mode">
654 <!-- nop, suppressed -->
657 <xsl:template match=
"ulink" mode=
"no.anchor.mode">
658 <xsl:apply-templates/>
661 <xsl:template match=
"link" mode=
"no.anchor.mode">
662 <xsl:apply-templates/>
665 <xsl:template match=
"olink" mode=
"no.anchor.mode">
666 <xsl:apply-templates/>
669 <xsl:template match=
"indexterm" mode=
"no.anchor.mode">
670 <!-- nop, suppressed -->
673 <xsl:template match=
"xref" mode=
"no.anchor.mode">
674 <xsl:variable name=
"targets" select=
"key('id',@linkend)"/>
675 <xsl:variable name=
"target" select=
"$targets[1]"/>
676 <xsl:variable name=
"refelem" select=
"local-name($target)"/>
678 <xsl:call-template name=
"check.id.unique">
679 <xsl:with-param name=
"linkend" select=
"@linkend"/>
683 <xsl:when test=
"count($target) = 0">
685 <xsl:text>XRef to nonexistent id:
</xsl:text>
686 <xsl:value-of select=
"@linkend"/>
688 <xsl:text>???
</xsl:text>
691 <xsl:when test=
"@endterm">
692 <xsl:variable name=
"etargets" select=
"key('id',@endterm)"/>
693 <xsl:variable name=
"etarget" select=
"$etargets[1]"/>
695 <xsl:when test=
"count($etarget) = 0">
697 <xsl:value-of select=
"count($etargets)"/>
698 <xsl:text>Endterm points to nonexistent ID:
</xsl:text>
699 <xsl:value-of select=
"@endterm"/>
701 <xsl:text>???
</xsl:text>
704 <xsl:apply-templates select=
"$etarget" mode=
"endterm"/>
709 <xsl:when test=
"$target/@xreflabel">
710 <xsl:call-template name=
"xref.xreflabel">
711 <xsl:with-param name=
"target" select=
"$target"/>
716 <xsl:apply-templates select=
"$target" mode=
"xref-to-prefix"/>
718 <xsl:apply-templates select=
"$target" mode=
"xref-to">
719 <xsl:with-param name=
"referrer" select=
"."/>
720 <xsl:with-param name=
"xrefstyle">
722 <xsl:when test=
"@role and not(@xrefstyle) and $use.role.as.xrefstyle != 0">
723 <xsl:value-of select=
"@role"/>
726 <xsl:value-of select=
"@xrefstyle"/>
730 </xsl:apply-templates>
732 <xsl:apply-templates select=
"$target" mode=
"xref-to-suffix"/>
737 <!-- ============================================================ -->