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