]> git.stg.codes - stg.git/blob - doc/xslt/common/titles.xsl
Set output encoding to utf-8.
[stg.git] / doc / xslt / 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                 xmlns:xlink="http://www.w3.org/1999/xlink"
5                 exclude-result-prefixes="doc"
6                 version='1.0'>
7
8 <!-- ********************************************************************
9      $Id: titles.xsl 8599 2010-03-20 10:47:36Z mzjn $
10      ********************************************************************
11
12      This file is part of the XSL DocBook Stylesheet distribution.
13      See ../README or http://docbook.sf.net/release/xsl/current/ for
14      copyright and other information.
15
16      ******************************************************************** -->
17
18 <!-- ==================================================================== -->
19
20 <!-- title markup -->
21
22 <doc:mode mode="title.markup" xmlns="">
23 <refpurpose>Provides access to element titles</refpurpose>
24 <refdescription id="title.markup-desc">
25 <para>Processing an element in the
26 <literal role="mode">title.markup</literal> mode produces the
27 title of the element. This does not include the label.
28 </para>
29 </refdescription>
30 </doc:mode>
31
32 <xsl:template match="*" mode="title.markup">
33   <xsl:param name="allow-anchors" select="0"/>
34   <xsl:param name="verbose" select="1"/>
35   <xsl:choose>
36     <!-- * FIXME: this should handle other *info elements as well -->
37     <!-- * but this is good enough for now. -->
38     <xsl:when test="title|info/title">
39       <xsl:apply-templates select="(title|info/title)[1]" mode="title.markup">
40         <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
41       </xsl:apply-templates>
42     </xsl:when>
43     <xsl:when test="local-name(.) = 'partintro'">
44       <!-- partintro's don't have titles, use the parent (part or reference)
45            title instead. -->
46       <xsl:apply-templates select="parent::*" mode="title.markup"/>
47     </xsl:when>
48     <xsl:otherwise>
49       <xsl:if test="$verbose != 0">
50         <xsl:message>
51           <xsl:text>Request for title of element with no title: </xsl:text>
52           <xsl:value-of select="local-name(.)"/>
53           <xsl:choose>
54             <xsl:when test="@id">
55               <xsl:text> (id="</xsl:text>
56               <xsl:value-of select="@id"/>
57               <xsl:text>")</xsl:text>
58             </xsl:when>
59             <xsl:when test="@xml:id">
60               <xsl:text> (xml:id="</xsl:text>
61               <xsl:value-of select="@xml:id"/>
62               <xsl:text>")</xsl:text>
63             </xsl:when>
64           </xsl:choose>
65         </xsl:message>
66       </xsl:if>
67       <xsl:text>???TITLE???</xsl:text>
68     </xsl:otherwise>
69   </xsl:choose>
70 </xsl:template>
71
72 <xsl:template match="title" mode="title.markup">
73   <xsl:param name="allow-anchors" select="0"/>
74
75   <xsl:choose>
76     <xsl:when test="$allow-anchors != 0">
77       <xsl:apply-templates/>
78     </xsl:when>
79     <xsl:otherwise>
80       <xsl:apply-templates mode="no.anchor.mode"/>
81     </xsl:otherwise>
82   </xsl:choose>
83 </xsl:template>
84
85 <!-- only occurs in HTML Tables! -->
86 <xsl:template match="caption" mode="title.markup">
87   <xsl:param name="allow-anchors" select="0"/>
88
89   <xsl:choose>
90     <xsl:when test="$allow-anchors != 0">
91       <xsl:apply-templates/>
92     </xsl:when>
93     <xsl:otherwise>
94       <xsl:apply-templates mode="no.anchor.mode"/>
95     </xsl:otherwise>
96   </xsl:choose>
97 </xsl:template>
98
99 <xsl:template match="set" mode="title.markup">
100   <xsl:param name="allow-anchors" select="0"/>
101   <xsl:apply-templates select="(setinfo/title|info/title|title)[1]"
102                        mode="title.markup">
103     <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
104   </xsl:apply-templates>
105 </xsl:template>
106
107 <xsl:template match="book" mode="title.markup">
108   <xsl:param name="allow-anchors" select="0"/>
109   <xsl:apply-templates select="(bookinfo/title|info/title|title)[1]"
110                        mode="title.markup">
111     <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
112   </xsl:apply-templates>
113 </xsl:template>
114
115 <xsl:template match="part" mode="title.markup">
116   <xsl:param name="allow-anchors" select="0"/>
117   <xsl:apply-templates select="(partinfo/title|info/title|docinfo/title|title)[1]"
118                        mode="title.markup">
119     <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
120   </xsl:apply-templates>
121 </xsl:template>
122
123 <xsl:template match="preface|chapter|appendix" mode="title.markup">
124   <xsl:param name="allow-anchors" select="0"/>
125
126 <!--
127   <xsl:message>
128     <xsl:value-of select="local-name(.)"/>
129     <xsl:text> </xsl:text>
130     <xsl:value-of select="$allow-anchors"/>
131   </xsl:message>
132 -->
133
134   <xsl:variable name="title" select="(docinfo/title
135                                       |info/title
136                                       |prefaceinfo/title
137                                       |chapterinfo/title
138                                       |appendixinfo/title
139                                       |title)[1]"/>
140   <xsl:apply-templates select="$title" mode="title.markup">
141     <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
142   </xsl:apply-templates>
143 </xsl:template>
144
145 <xsl:template match="dedication" mode="title.markup">
146   <xsl:param name="allow-anchors" select="0"/>
147   <xsl:choose>
148     <xsl:when test="title|info/title">
149       <xsl:apply-templates select="(title|info/title)[1]" mode="title.markup">
150         <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
151       </xsl:apply-templates>
152     </xsl:when>
153     <xsl:otherwise>
154       <xsl:call-template name="gentext">
155         <xsl:with-param name="key" select="'Dedication'"/>
156       </xsl:call-template>
157     </xsl:otherwise>
158   </xsl:choose>
159 </xsl:template>
160
161 <xsl:template match="acknowledgements" mode="title.markup">
162   <xsl:param name="allow-anchors" select="0"/>
163   <xsl:choose>
164     <xsl:when test="title|info/title">
165       <xsl:apply-templates select="(title|info/title)[1]" mode="title.markup">
166         <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
167       </xsl:apply-templates>
168     </xsl:when>
169     <xsl:otherwise>
170       <xsl:call-template name="gentext">
171         <xsl:with-param name="key" select="'Acknowledgements'"/>
172       </xsl:call-template>
173     </xsl:otherwise>
174   </xsl:choose>
175 </xsl:template>
176
177 <xsl:template match="colophon" mode="title.markup">
178   <xsl:param name="allow-anchors" select="0"/>
179   <xsl:choose>
180     <xsl:when test="title|info/title">
181       <xsl:apply-templates select="(title|info/title)[1]" mode="title.markup">
182         <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
183       </xsl:apply-templates>
184     </xsl:when>
185     <xsl:otherwise>
186       <xsl:call-template name="gentext">
187         <xsl:with-param name="key" select="'Colophon'"/>
188       </xsl:call-template>
189     </xsl:otherwise>
190   </xsl:choose>
191 </xsl:template>
192
193 <xsl:template match="article" mode="title.markup">
194   <xsl:param name="allow-anchors" select="0"/>
195   <xsl:variable name="title" select="(artheader/title
196                                       |articleinfo/title
197                                       |info/title
198                                       |title)[1]"/>
199
200   <xsl:apply-templates select="$title" mode="title.markup">
201     <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
202   </xsl:apply-templates>
203 </xsl:template>
204
205 <xsl:template match="reference" mode="title.markup">
206   <xsl:param name="allow-anchors" select="0"/>
207   <xsl:apply-templates select="(referenceinfo/title|docinfo/title|info/title|title)[1]"
208                        mode="title.markup">
209     <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
210   </xsl:apply-templates>
211 </xsl:template>
212
213 <xsl:template match="refentry" mode="title.markup">
214   <xsl:param name="allow-anchors" select="0"/>
215   <xsl:variable name="refmeta" select=".//refmeta"/>
216   <xsl:variable name="refentrytitle" select="$refmeta//refentrytitle"/>
217   <xsl:variable name="refnamediv" select=".//refnamediv"/>
218   <xsl:variable name="refname" select="$refnamediv//refname"/>
219   <xsl:variable name="refdesc" select="$refnamediv//refdescriptor"/>
220
221   <xsl:variable name="title">
222     <xsl:choose>
223       <xsl:when test="$refentrytitle">
224         <xsl:apply-templates select="$refentrytitle[1]" mode="title.markup"/>
225       </xsl:when>
226       <xsl:when test="$refdesc">
227         <xsl:apply-templates select="$refdesc" mode="title.markup"/>
228       </xsl:when>
229       <xsl:when test="$refname">
230         <xsl:apply-templates select="$refname[1]" mode="title.markup"/>
231       </xsl:when>
232       <xsl:otherwise>REFENTRY WITHOUT TITLE???</xsl:otherwise>
233     </xsl:choose>
234   </xsl:variable>
235
236   <xsl:copy-of select="$title"/>
237 </xsl:template>
238
239 <xsl:template match="refentrytitle|refname|refdescriptor" mode="title.markup">
240   <xsl:param name="allow-anchors" select="0"/>
241   <xsl:choose>
242     <xsl:when test="$allow-anchors != 0">
243       <xsl:apply-templates/>
244     </xsl:when>
245     <xsl:otherwise>
246       <xsl:apply-templates mode="no.anchor.mode"/>
247     </xsl:otherwise>
248   </xsl:choose>
249 </xsl:template>
250
251 <xsl:template match="section
252                      |sect1|sect2|sect3|sect4|sect5
253                      |refsect1|refsect2|refsect3|refsection
254                      |simplesect"
255               mode="title.markup">
256   <xsl:param name="allow-anchors" select="0"/>
257   <xsl:variable name="title" select="(info/title
258                                       |sectioninfo/title
259                                       |sect1info/title
260                                       |sect2info/title
261                                       |sect3info/title
262                                       |sect4info/title
263                                       |sect5info/title
264                                       |refsect1info/title
265                                       |refsect2info/title
266                                       |refsect3info/title
267                                       |refsectioninfo/title
268                                       |title)[1]"/>
269
270   <xsl:apply-templates select="$title" mode="title.markup">
271     <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
272   </xsl:apply-templates>
273 </xsl:template>
274
275 <xsl:template match="bridgehead" mode="title.markup">
276   <xsl:apply-templates mode="title.markup"/>
277 </xsl:template>
278
279 <xsl:template match="refsynopsisdiv" mode="title.markup">
280   <xsl:param name="allow-anchors" select="0"/>
281   <xsl:choose>
282     <xsl:when test="title|info/title">
283       <xsl:apply-templates select="(title|info/title)[1]" 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">
289         <xsl:with-param name="key" select="'RefSynopsisDiv'"/>
290       </xsl:call-template>
291     </xsl:otherwise>
292   </xsl:choose>
293 </xsl:template>
294
295 <xsl:template match="bibliography" mode="title.markup">
296   <xsl:param name="allow-anchors" select="0"/>
297   <xsl:variable name="title" select="(bibliographyinfo/title|info/title|title)[1]"/>
298   <xsl:choose>
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>
303     </xsl:when>
304     <xsl:otherwise>
305       <xsl:call-template name="gentext">
306         <xsl:with-param name="key" select="'Bibliography'"/>
307       </xsl:call-template>
308     </xsl:otherwise>
309   </xsl:choose>
310 </xsl:template>
311
312 <xsl:template match="glossary" mode="title.markup">
313   <xsl:param name="allow-anchors" select="0"/>
314   <xsl:variable name="title" select="(glossaryinfo/title|info/title|title)[1]"/>
315   <xsl:choose>
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>
320     </xsl:when>
321     <xsl:otherwise>
322       <xsl:call-template name="gentext.element.name">
323         <xsl:with-param name="element.name" select="local-name(.)"/>
324       </xsl:call-template>
325     </xsl:otherwise>
326   </xsl:choose>
327 </xsl:template>
328
329 <xsl:template match="glossdiv" mode="title.markup">
330   <xsl:param name="allow-anchors" select="0"/>
331   <xsl:variable name="title" select="(info/title|title)[1]"/>
332   <xsl:choose>
333     <xsl:when test="$title">
334       <xsl:apply-templates select="$title" mode="title.markup">
335         <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
336       </xsl:apply-templates>
337     </xsl:when>
338     <xsl:otherwise>
339       <xsl:message>ERROR: glossdiv missing its required title</xsl:message>
340     </xsl:otherwise>
341   </xsl:choose>
342 </xsl:template>
343
344 <xsl:template match="glossentry" mode="title.markup">
345   <xsl:param name="allow-anchors" select="0"/>
346   <xsl:apply-templates select="glossterm" mode="title.markup">
347     <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
348   </xsl:apply-templates>
349 </xsl:template>
350
351 <xsl:template match="glossterm|firstterm" mode="title.markup">
352   <xsl:param name="allow-anchors" select="0"/>
353
354   <xsl:choose>
355     <xsl:when test="$allow-anchors != 0">
356       <xsl:apply-templates/>
357     </xsl:when>
358     <xsl:otherwise>
359       <xsl:apply-templates mode="no.anchor.mode"/>
360     </xsl:otherwise>
361   </xsl:choose>
362 </xsl:template>
363
364 <xsl:template match="index" mode="title.markup">
365   <xsl:param name="allow-anchors" select="0"/>
366   <xsl:variable name="title" select="(indexinfo/title|info/title|title)[1]"/>
367   <xsl:choose>
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>
372     </xsl:when>
373     <xsl:otherwise>
374       <xsl:call-template name="gentext">
375         <xsl:with-param name="key" select="'Index'"/>
376       </xsl:call-template>
377     </xsl:otherwise>
378   </xsl:choose>
379 </xsl:template>
380
381 <xsl:template match="setindex" mode="title.markup">
382   <xsl:param name="allow-anchors" select="0"/>
383   <xsl:variable name="title" select="(setindexinfo/title|info/title|title)[1]"/>
384   <xsl:choose>
385     <xsl:when test="$title">
386       <xsl:apply-templates select="$title" mode="title.markup">
387         <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
388       </xsl:apply-templates>
389     </xsl:when>
390     <xsl:otherwise>
391       <xsl:call-template name="gentext">
392         <xsl:with-param name="key" select="'SetIndex'"/>
393       </xsl:call-template>
394     </xsl:otherwise>
395   </xsl:choose>
396 </xsl:template>
397
398 <xsl:template match="figure|example|equation" mode="title.markup">
399   <xsl:param name="allow-anchors" select="0"/>
400   <xsl:apply-templates select="(title|info/title)[1]" mode="title.markup">
401     <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
402   </xsl:apply-templates>
403 </xsl:template>
404
405 <xsl:template match="table" mode="title.markup">
406   <xsl:param name="allow-anchors" select="0"/>
407   <xsl:apply-templates select="(title|info/title|caption)[1]" mode="title.markup">
408     <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
409   </xsl:apply-templates>
410 </xsl:template>
411
412 <xsl:template match="procedure" mode="title.markup">
413   <xsl:param name="allow-anchors" select="0"/>
414   <xsl:apply-templates select="(title|info/title)[1]" mode="title.markup">
415     <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
416   </xsl:apply-templates>
417 </xsl:template>
418
419 <xsl:template match="task" mode="title.markup">
420   <xsl:param name="allow-anchors" select="0"/>
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>
424 </xsl:template>
425
426 <xsl:template match="sidebar" mode="title.markup">
427   <xsl:param name="allow-anchors" select="0"/>
428   <xsl:apply-templates select="(info/title|sidebarinfo/title|title)[1]"
429                        mode="title.markup">
430     <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
431   </xsl:apply-templates>
432 </xsl:template>
433
434 <xsl:template match="abstract" mode="title.markup">
435   <xsl:param name="allow-anchors" select="0"/>
436   <xsl:choose>
437     <xsl:when test="title|info/title">
438       <xsl:apply-templates select="(title|info/title)[1]" mode="title.markup">
439         <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
440       </xsl:apply-templates>
441     </xsl:when>
442     <xsl:otherwise>
443       <xsl:call-template name="gentext">
444         <xsl:with-param name="key" select="'Abstract'"/>
445       </xsl:call-template>
446     </xsl:otherwise>
447   </xsl:choose>
448 </xsl:template>
449
450 <xsl:template match="caution|tip|warning|important|note" mode="title.markup">
451   <xsl:param name="allow-anchors" select="0"/>
452   <xsl:variable name="title" select="(title|info/title)[1]"/>
453   <xsl:choose>
454     <xsl:when test="$title">
455       <xsl:apply-templates select="$title" mode="title.markup">
456         <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
457       </xsl:apply-templates>
458     </xsl:when>
459     <xsl:otherwise>
460       <xsl:call-template name="gentext">
461         <xsl:with-param name="key">
462           <xsl:choose>
463             <xsl:when test="local-name(.)='note'">Note</xsl:when>
464             <xsl:when test="local-name(.)='important'">Important</xsl:when>
465             <xsl:when test="local-name(.)='caution'">Caution</xsl:when>
466             <xsl:when test="local-name(.)='warning'">Warning</xsl:when>
467             <xsl:when test="local-name(.)='tip'">Tip</xsl:when>
468           </xsl:choose>
469         </xsl:with-param>
470       </xsl:call-template>
471     </xsl:otherwise>
472   </xsl:choose>
473 </xsl:template>
474
475 <xsl:template match="question" mode="title.markup">
476   <!-- questions don't have titles -->
477   <xsl:text>Question</xsl:text>
478 </xsl:template>
479
480 <xsl:template match="answer" mode="title.markup">
481   <!-- answers don't have titles -->
482   <xsl:text>Answer</xsl:text>
483 </xsl:template>
484
485 <xsl:template match="qandaentry" mode="title.markup">
486   <!-- qandaentrys are represented by the first question in them -->
487   <xsl:text>Question</xsl:text>
488 </xsl:template>
489
490 <xsl:template match="qandaset" mode="title.markup">
491   <xsl:param name="allow-anchors" select="0"/>
492   <xsl:variable name="title" select="(info/title|
493                                       blockinfo/title|
494                                       title)[1]"/>
495   <xsl:choose>
496     <xsl:when test="$title">
497       <xsl:apply-templates select="$title" mode="title.markup">
498         <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
499       </xsl:apply-templates>
500     </xsl:when>
501     <xsl:otherwise>
502       <xsl:call-template name="gentext">
503         <xsl:with-param name="key" select="'QandASet'"/>
504       </xsl:call-template>
505     </xsl:otherwise>
506   </xsl:choose>
507 </xsl:template>
508
509 <xsl:template match="legalnotice" mode="title.markup">
510   <xsl:param name="allow-anchors" select="0"/>
511   <xsl:choose>
512     <xsl:when test="title|info/title">
513       <xsl:apply-templates select="(title|info/title)[1]" mode="title.markup">
514         <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
515       </xsl:apply-templates>
516     </xsl:when>
517     <xsl:otherwise>
518       <xsl:call-template name="gentext">
519         <xsl:with-param name="key" select="'LegalNotice'"/>
520       </xsl:call-template>
521     </xsl:otherwise>
522   </xsl:choose>
523 </xsl:template>
524
525 <!-- ============================================================ -->
526
527 <xsl:template match="*" mode="titleabbrev.markup">
528   <xsl:param name="allow-anchors" select="0"/>
529   <xsl:param name="verbose" select="1"/>
530
531   <xsl:choose>
532     <xsl:when test="titleabbrev">
533       <xsl:apply-templates select="titleabbrev[1]" mode="title.markup">
534         <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
535       </xsl:apply-templates>
536     </xsl:when>
537     <xsl:when test="info/titleabbrev">
538       <xsl:apply-templates select="info/titleabbrev[1]" mode="title.markup">
539         <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
540       </xsl:apply-templates>
541     </xsl:when>
542     <xsl:otherwise>
543       <xsl:apply-templates select="." mode="title.markup">
544         <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
545         <xsl:with-param name="verbose" select="$verbose"/>
546       </xsl:apply-templates>
547     </xsl:otherwise>
548   </xsl:choose>
549 </xsl:template>
550
551 <xsl:template match="book|preface|chapter|appendix" mode="titleabbrev.markup">
552   <xsl:param name="allow-anchors" select="0"/>
553   <xsl:param name="verbose" select="1"/>
554
555   <xsl:variable name="titleabbrev" select="(docinfo/titleabbrev
556                                            |bookinfo/titleabbrev
557                                            |info/titleabbrev
558                                            |prefaceinfo/titleabbrev
559                                            |chapterinfo/titleabbrev
560                                            |appendixinfo/titleabbrev
561                                            |titleabbrev)[1]"/>
562
563   <xsl:choose>
564     <xsl:when test="$titleabbrev">
565       <xsl:apply-templates select="$titleabbrev" mode="title.markup">
566         <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
567       </xsl:apply-templates>
568     </xsl:when>
569     <xsl:otherwise>
570       <xsl:apply-templates select="." mode="title.markup">
571         <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
572         <xsl:with-param name="verbose" select="$verbose"/>
573       </xsl:apply-templates>
574     </xsl:otherwise>
575   </xsl:choose>
576 </xsl:template>
577
578 <xsl:template match="article" mode="titleabbrev.markup">
579   <xsl:param name="allow-anchors" select="0"/>
580   <xsl:param name="verbose" select="1"/>
581
582   <xsl:variable name="titleabbrev" select="(artheader/titleabbrev
583                                            |articleinfo/titleabbrev
584                                            |info/titleabbrev
585                                            |titleabbrev)[1]"/>
586
587   <xsl:choose>
588     <xsl:when test="$titleabbrev">
589       <xsl:apply-templates select="$titleabbrev" mode="title.markup">
590         <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
591       </xsl:apply-templates>
592     </xsl:when>
593     <xsl:otherwise>
594       <xsl:apply-templates select="." mode="title.markup">
595         <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
596         <xsl:with-param name="verbose" select="$verbose"/>
597       </xsl:apply-templates>
598     </xsl:otherwise>
599   </xsl:choose>
600 </xsl:template>
601
602 <xsl:template match="section
603                      |sect1|sect2|sect3|sect4|sect5
604                      |refsect1|refsect2|refsect3
605                      |simplesect"
606               mode="titleabbrev.markup">
607   <xsl:param name="allow-anchors" select="0"/>
608   <xsl:param name="verbose" select="1"/>
609
610   <xsl:variable name="titleabbrev" select="(info/titleabbrev
611                                             |sectioninfo/titleabbrev
612                                             |sect1info/titleabbrev
613                                             |sect2info/titleabbrev
614                                             |sect3info/titleabbrev
615                                             |sect4info/titleabbrev
616                                             |sect5info/titleabbrev
617                                             |refsect1info/titleabbrev
618                                             |refsect2info/titleabbrev
619                                             |refsect3info/titleabbrev
620                                             |titleabbrev)[1]"/>
621
622   <xsl:choose>
623     <xsl:when test="$titleabbrev">
624       <xsl:apply-templates select="$titleabbrev" mode="title.markup">
625         <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
626       </xsl:apply-templates>
627     </xsl:when>
628     <xsl:otherwise>
629       <xsl:apply-templates select="." mode="title.markup">
630         <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
631         <xsl:with-param name="verbose" select="$verbose"/>
632       </xsl:apply-templates>
633     </xsl:otherwise>
634   </xsl:choose>
635 </xsl:template>
636
637 <xsl:template match="titleabbrev" mode="title.markup">
638   <xsl:param name="allow-anchors" select="0"/>
639
640   <xsl:choose>
641     <xsl:when test="$allow-anchors != 0">
642       <xsl:apply-templates/>
643     </xsl:when>
644     <xsl:otherwise>
645       <xsl:apply-templates mode="no.anchor.mode"/>
646     </xsl:otherwise>
647   </xsl:choose>
648 </xsl:template>
649
650 <!-- ============================================================ -->
651
652 <xsl:template match="*" mode="no.anchor.mode">
653   <!-- Switch to normal mode if no links -->
654   <xsl:choose>
655     <xsl:when test="descendant-or-self::footnote or
656                     descendant-or-self::anchor or
657                     descendant-or-self::ulink or
658                     descendant-or-self::link or
659                     descendant-or-self::olink or
660                     descendant-or-self::xref or
661                     descendant-or-self::indexterm or
662                     (ancestor::title and (@id or @xml:id))">
663
664       <xsl:apply-templates mode="no.anchor.mode"/>
665     </xsl:when>
666     <xsl:otherwise>
667       <xsl:apply-templates select="."/>
668     </xsl:otherwise>
669   </xsl:choose>
670 </xsl:template>
671
672 <xsl:template match="footnote" mode="no.anchor.mode">
673   <!-- nop, suppressed -->
674 </xsl:template>
675
676 <xsl:template match="anchor" mode="no.anchor.mode">
677   <!-- nop, suppressed -->
678 </xsl:template>
679
680 <xsl:template match="ulink" mode="no.anchor.mode">
681   <xsl:apply-templates/>
682 </xsl:template>
683
684 <xsl:template match="link" mode="no.anchor.mode">
685   <xsl:choose>
686     <xsl:when test="count(child::node()) &gt; 0">
687       <!-- If it has content, use it -->
688       <xsl:apply-templates/>
689     </xsl:when>
690         <!-- look for an endterm -->
691     <xsl:when test="@endterm">
692       <xsl:variable name="etargets" select="key('id',@endterm)"/>
693       <xsl:variable name="etarget" select="$etargets[1]"/>
694       <xsl:choose>
695         <xsl:when test="count($etarget) = 0">
696           <xsl:message>
697             <xsl:value-of select="count($etargets)"/>
698             <xsl:text>Endterm points to nonexistent ID: </xsl:text>
699             <xsl:value-of select="@endterm"/>
700           </xsl:message>
701           <xsl:text>???</xsl:text>
702         </xsl:when>
703         <xsl:otherwise>
704           <xsl:apply-templates select="$etarget" mode="endterm"/>
705         </xsl:otherwise>
706       </xsl:choose>
707     </xsl:when>
708     <xsl:otherwise>
709       <xsl:apply-templates/>
710     </xsl:otherwise>
711   </xsl:choose>
712 </xsl:template>
713
714 <xsl:template match="olink" mode="no.anchor.mode">
715   <xsl:apply-templates/>
716 </xsl:template>
717
718 <xsl:template match="indexterm" mode="no.anchor.mode">
719   <!-- nop, suppressed -->
720 </xsl:template>
721
722 <xsl:template match="xref" mode="no.anchor.mode">
723   <xsl:variable name="targets" select="key('id',@linkend)|key('id',substring-after(@xlink:href,'#'))"/>
724   <xsl:variable name="target" select="$targets[1]"/>
725   <xsl:variable name="refelem" select="local-name($target)"/>
726   
727   <xsl:call-template name="check.id.unique">
728     <xsl:with-param name="linkend" select="@linkend"/>
729   </xsl:call-template>
730
731   <xsl:choose>
732     <xsl:when test="count($target) = 0">
733       <xsl:message>
734         <xsl:text>XRef to nonexistent id: </xsl:text>
735         <xsl:value-of select="@linkend"/> 
736         <xsl:value-of select="@xlink:href"/>
737       </xsl:message>
738       <xsl:text>???</xsl:text>
739     </xsl:when>
740
741     <xsl:when test="@endterm">
742       <xsl:variable name="etargets" select="key('id',@endterm)"/>
743       <xsl:variable name="etarget" select="$etargets[1]"/>
744       <xsl:choose>
745         <xsl:when test="count($etarget) = 0">
746           <xsl:message>
747             <xsl:value-of select="count($etargets)"/>
748             <xsl:text>Endterm points to nonexistent ID: </xsl:text>
749             <xsl:value-of select="@endterm"/>
750           </xsl:message>
751           <xsl:text>???</xsl:text>
752         </xsl:when>
753         <xsl:otherwise>
754           <xsl:apply-templates select="$etarget" mode="endterm"/>
755         </xsl:otherwise>
756       </xsl:choose>
757     </xsl:when>
758
759     <xsl:when test="$target/@xreflabel">
760       <xsl:call-template name="xref.xreflabel">
761         <xsl:with-param name="target" select="$target"/>
762       </xsl:call-template>
763     </xsl:when>
764
765     <xsl:otherwise>
766    
767       <xsl:choose>
768         <!-- Watch out for the case when there is a xref or link inside 
769              a title. See bugs #1811721 and #1838136. -->
770         <xsl:when test="not(ancestor::*[@id = $target/@id] or ancestor::*[@xml:id = $target/@xml:id])">
771
772           <xsl:apply-templates select="$target" mode="xref-to-prefix"/>
773           
774           <xsl:apply-templates select="$target" mode="xref-to">
775             
776             <xsl:with-param name="referrer" select="."/>
777             <xsl:with-param name="xrefstyle">
778               <xsl:choose>
779                 <xsl:when test="@role and not(@xrefstyle) and $use.role.as.xrefstyle != 0">
780                   <xsl:value-of select="@role"/>
781                 </xsl:when>
782                 <xsl:otherwise>
783                   <xsl:value-of select="@xrefstyle"/>
784                 </xsl:otherwise>
785               </xsl:choose>
786             </xsl:with-param>
787           </xsl:apply-templates>
788           
789           <xsl:apply-templates select="$target" mode="xref-to-suffix"/>
790         </xsl:when>
791         
792         <xsl:otherwise>
793           <xsl:apply-templates/>
794         </xsl:otherwise>
795       
796       </xsl:choose>
797     </xsl:otherwise>
798   </xsl:choose>
799
800 </xsl:template>
801
802 <!-- ============================================================ -->
803
804 </xsl:stylesheet>
805