Rocco Rutte:
[apps/madmutt.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                 exclude-result-prefixes="doc"
5                 version='1.0'>
6
7 <!-- ********************************************************************
8      $Id$
9      ********************************************************************
10
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.
14
15      ******************************************************************** -->
16
17 <!-- ==================================================================== -->
18
19 <!-- title markup -->
20
21 <doc:mode mode="title.markup" xmlns="">
22 <refpurpose>Provides access to element titles</refpurpose>
23 <refdescription>
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.
27 </para>
28 </refdescription>
29 </doc:mode>
30
31 <xsl:template match="*" mode="title.markup">
32   <xsl:param name="allow-anchors" select="0"/>
33   <xsl:param name="verbose" select="1"/>
34
35   <xsl:choose>
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>
40     </xsl:when>
41     <xsl:when test="local-name(.) = 'partintro'">
42       <!-- partintro's don't have titles, use the parent (part or reference)
43            title instead. -->
44       <xsl:apply-templates select="parent::*" mode="title.markup"/>
45     </xsl:when>
46     <xsl:otherwise>
47       <xsl:if test="$verbose != 0">
48         <xsl:message>
49           <xsl:text>Request for title of element with no title: </xsl:text>
50           <xsl:value-of select="name(.)"/>
51           <xsl:if test="@id">
52             <xsl:text> (id="</xsl:text>
53             <xsl:value-of select="@id"/>
54             <xsl:text>")</xsl:text>
55           </xsl:if>
56         </xsl:message>
57       </xsl:if>
58       <xsl:text>???TITLE???</xsl:text>
59     </xsl:otherwise>
60   </xsl:choose>
61 </xsl:template>
62
63 <xsl:template match="title" mode="title.markup">
64   <xsl:param name="allow-anchors" select="0"/>
65
66   <xsl:choose>
67     <xsl:when test="$allow-anchors != 0">
68       <xsl:apply-templates/>
69     </xsl:when>
70     <xsl:otherwise>
71       <xsl:apply-templates mode="no.anchor.mode"/>
72     </xsl:otherwise>
73   </xsl:choose>
74 </xsl:template>
75
76 <!-- only occurs in HTML Tables! -->
77 <xsl:template match="caption" mode="title.markup">
78   <xsl:param name="allow-anchors" select="0"/>
79
80   <xsl:choose>
81     <xsl:when test="$allow-anchors != 0">
82       <xsl:apply-templates/>
83     </xsl:when>
84     <xsl:otherwise>
85       <xsl:apply-templates mode="no.anchor.mode"/>
86     </xsl:otherwise>
87   </xsl:choose>
88 </xsl:template>
89
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]"
93                        mode="title.markup">
94     <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
95   </xsl:apply-templates>
96 </xsl:template>
97
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]"
101                        mode="title.markup">
102     <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
103   </xsl:apply-templates>
104 </xsl:template>
105
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]"
109                        mode="title.markup">
110     <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
111   </xsl:apply-templates>
112 </xsl:template>
113
114 <xsl:template match="preface|chapter|appendix" mode="title.markup">
115   <xsl:param name="allow-anchors" select="0"/>
116
117 <!--
118   <xsl:message>
119     <xsl:value-of select="name(.)"/>
120     <xsl:text> </xsl:text>
121     <xsl:value-of select="$allow-anchors"/>
122   </xsl:message>
123 -->
124
125   <xsl:variable name="title" select="(docinfo/title
126                                       |info/title
127                                       |prefaceinfo/title
128                                       |chapterinfo/title
129                                       |appendixinfo/title
130                                       |title)[1]"/>
131   <xsl:apply-templates select="$title" mode="title.markup">
132     <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
133   </xsl:apply-templates>
134 </xsl:template>
135
136 <xsl:template match="dedication" mode="title.markup">
137   <xsl:param name="allow-anchors" select="0"/>
138   <xsl:choose>
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>
143     </xsl:when>
144     <xsl:otherwise>
145       <xsl:call-template name="gentext">
146         <xsl:with-param name="key" select="'Dedication'"/>
147       </xsl:call-template>
148     </xsl:otherwise>
149   </xsl:choose>
150 </xsl:template>
151
152 <xsl:template match="colophon" mode="title.markup">
153   <xsl:param name="allow-anchors" select="0"/>
154   <xsl:choose>
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>
159     </xsl:when>
160     <xsl:otherwise>
161       <xsl:call-template name="gentext">
162         <xsl:with-param name="key" select="'Colophon'"/>
163       </xsl:call-template>
164     </xsl:otherwise>
165   </xsl:choose>
166 </xsl:template>
167
168 <xsl:template match="article" mode="title.markup">
169   <xsl:param name="allow-anchors" select="0"/>
170   <xsl:variable name="title" select="(artheader/title
171                                       |articleinfo/title
172                                       |info/title
173                                       |title)[1]"/>
174
175   <xsl:apply-templates select="$title" mode="title.markup">
176     <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
177   </xsl:apply-templates>
178 </xsl:template>
179
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]"
183                        mode="title.markup">
184     <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
185   </xsl:apply-templates>
186 </xsl:template>
187
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"/>
195
196   <xsl:variable name="title">
197     <xsl:choose>
198       <xsl:when test="$refentrytitle">
199         <xsl:apply-templates select="$refentrytitle[1]" mode="title.markup"/>
200       </xsl:when>
201       <xsl:when test="$refdesc">
202         <xsl:apply-templates select="$refdesc" mode="title.markup"/>
203       </xsl:when>
204       <xsl:when test="$refname">
205         <xsl:apply-templates select="$refname[1]" mode="title.markup"/>
206       </xsl:when>
207       <xsl:otherwise>REFENTRY WITHOUT TITLE???</xsl:otherwise>
208     </xsl:choose>
209   </xsl:variable>
210
211   <xsl:copy-of select="$title"/>
212 </xsl:template>
213
214 <xsl:template match="refentrytitle|refname|refdescriptor" mode="title.markup">
215   <xsl:param name="allow-anchors" select="0"/>
216   <xsl:choose>
217     <xsl:when test="$allow-anchors != 0">
218       <xsl:apply-templates/>
219     </xsl:when>
220     <xsl:otherwise>
221       <xsl:apply-templates mode="no.anchor.mode"/>
222     </xsl:otherwise>
223   </xsl:choose>
224 </xsl:template>
225
226 <xsl:template match="section
227                      |sect1|sect2|sect3|sect4|sect5
228                      |refsect1|refsect2|refsect3
229                      |simplesect"
230               mode="title.markup">
231   <xsl:param name="allow-anchors" select="0"/>
232   <xsl:variable name="title" select="(info/title
233                                       |sectioninfo/title
234                                       |sect1info/title
235                                       |sect2info/title
236                                       |sect3info/title
237                                       |sect4info/title
238                                       |sect5info/title
239                                       |refsect1info/title
240                                       |refsect2info/title
241                                       |refsect3info/title
242                                       |title)[1]"/>
243
244   <xsl:apply-templates select="$title" mode="title.markup">
245     <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
246   </xsl:apply-templates>
247 </xsl:template>
248
249 <xsl:template match="bridgehead" mode="title.markup">
250   <xsl:apply-templates mode="title.markup"/>
251 </xsl:template>
252
253 <xsl:template match="refsynopsisdiv" mode="title.markup">
254   <xsl:param name="allow-anchors" select="0"/>
255   <xsl:choose>
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>
260     </xsl:when>
261     <xsl:otherwise>
262       <xsl:call-template name="gentext">
263         <xsl:with-param name="key" select="'RefSynopsisDiv'"/>
264       </xsl:call-template>
265     </xsl:otherwise>
266   </xsl:choose>
267 </xsl:template>
268
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]"/>
272   <xsl:choose>
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>
277     </xsl:when>
278     <xsl:otherwise>
279       <xsl:call-template name="gentext">
280         <xsl:with-param name="key" select="'Bibliography'"/>
281       </xsl:call-template>
282     </xsl:otherwise>
283   </xsl:choose>
284 </xsl:template>
285
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]"/>
289   <xsl:choose>
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>
294     </xsl:when>
295     <xsl:otherwise>
296       <xsl:call-template name="gentext.element.name">
297         <xsl:with-param name="element.name" select="name(.)"/>
298       </xsl:call-template>
299     </xsl:otherwise>
300   </xsl:choose>
301 </xsl:template>
302
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>
308 </xsl:template>
309
310 <xsl:template match="glossterm" mode="title.markup">
311   <xsl:param name="allow-anchors" select="0"/>
312
313   <xsl:choose>
314     <xsl:when test="$allow-anchors != 0">
315       <xsl:apply-templates/>
316     </xsl:when>
317     <xsl:otherwise>
318       <xsl:apply-templates mode="no.anchor.mode"/>
319     </xsl:otherwise>
320   </xsl:choose>
321 </xsl:template>
322
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]"/>
326   <xsl:choose>
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>
331     </xsl:when>
332     <xsl:otherwise>
333       <xsl:call-template name="gentext">
334         <xsl:with-param name="key" select="'Index'"/>
335       </xsl:call-template>
336     </xsl:otherwise>
337   </xsl:choose>
338 </xsl:template>
339
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]"/>
343   <xsl:choose>
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>
348     </xsl:when>
349     <xsl:otherwise>
350       <xsl:call-template name="gentext">
351         <xsl:with-param name="key" select="'SetIndex'"/>
352       </xsl:call-template>
353     </xsl:otherwise>
354   </xsl:choose>
355 </xsl:template>
356
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>
362 </xsl:template>
363
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>
369 </xsl:template>
370
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>
376 </xsl:template>
377
378 <xsl:template match="abstract" mode="title.markup">
379   <xsl:param name="allow-anchors" select="0"/>
380   <xsl:choose>
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>
385     </xsl:when>
386     <xsl:otherwise>
387       <xsl:call-template name="gentext">
388         <xsl:with-param name="key" select="'Abstract'"/>
389       </xsl:call-template>
390     </xsl:otherwise>
391   </xsl:choose>
392 </xsl:template>
393
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]"/>
397   <xsl:choose>
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>
402     </xsl:when>
403     <xsl:otherwise>
404       <xsl:call-template name="gentext">
405         <xsl:with-param name="key">
406           <xsl:choose>
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>
412           </xsl:choose>
413         </xsl:with-param>
414       </xsl:call-template>
415     </xsl:otherwise>
416   </xsl:choose>
417 </xsl:template>
418
419 <xsl:template match="question" mode="title.markup">
420   <!-- questions don't have titles -->
421   <xsl:text>Question</xsl:text>
422 </xsl:template>
423
424 <xsl:template match="answer" mode="title.markup">
425   <!-- answers don't have titles -->
426   <xsl:text>Answer</xsl:text>
427 </xsl:template>
428
429 <xsl:template match="qandaentry" mode="title.markup">
430   <!-- qandaentrys are represented by the first question in them -->
431   <xsl:text>Question</xsl:text>
432 </xsl:template>
433
434 <xsl:template match="legalnotice" mode="title.markup">
435   <xsl:param name="allow-anchors" select="0"/>
436   <xsl:choose>
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>
441     </xsl:when>
442     <xsl:otherwise>
443       <xsl:call-template name="gentext">
444         <xsl:with-param name="key" select="'LegalNotice'"/>
445       </xsl:call-template>
446     </xsl:otherwise>
447   </xsl:choose>
448 </xsl:template>
449
450 <!-- ============================================================ -->
451
452 <xsl:template match="*" mode="titleabbrev.markup">
453   <xsl:param name="allow-anchors" select="0"/>
454   <xsl:param name="verbose" select="1"/>
455
456   <xsl:choose>
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>
461     </xsl:when>
462     <xsl:otherwise>
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>
467     </xsl:otherwise>
468   </xsl:choose>
469 </xsl:template>
470
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"/>
474
475   <xsl:variable name="titleabbrev" select="(docinfo/titleabbrev
476                                            |bookinfo/titleabbrev
477                                            |info/titleabbrev
478                                            |prefaceinfo/titleabbrev
479                                            |chapterinfo/titleabbrev
480                                            |appendixinfo/titleabbrev
481                                            |titleabbrev)[1]"/>
482
483   <xsl:choose>
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>
488     </xsl:when>
489     <xsl:otherwise>
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>
494     </xsl:otherwise>
495   </xsl:choose>
496 </xsl:template>
497
498 <xsl:template match="article" mode="titleabbrev.markup">
499   <xsl:param name="allow-anchors" select="0"/>
500   <xsl:param name="verbose" select="1"/>
501
502   <xsl:variable name="titleabbrev" select="(artheader/titleabbrev
503                                            |articleinfo/titleabbrev
504                                            |info/titleabbrev
505                                            |titleabbrev)[1]"/>
506
507   <xsl:choose>
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>
512     </xsl:when>
513     <xsl:otherwise>
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>
518     </xsl:otherwise>
519   </xsl:choose>
520 </xsl:template>
521
522 <xsl:template match="section
523                      |sect1|sect2|sect3|sect4|sect5
524                      |refsect1|refsect2|refsect3
525                      |simplesect"
526               mode="titleabbrev.markup">
527   <xsl:param name="allow-anchors" select="0"/>
528   <xsl:param name="verbose" select="1"/>
529
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
540                                             |titleabbrev)[1]"/>
541
542   <xsl:choose>
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>
547     </xsl:when>
548     <xsl:otherwise>
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>
553     </xsl:otherwise>
554   </xsl:choose>
555 </xsl:template>
556
557 <xsl:template match="titleabbrev" mode="title.markup">
558   <xsl:param name="allow-anchors" select="0"/>
559
560   <xsl:choose>
561     <xsl:when test="$allow-anchors != 0">
562       <xsl:apply-templates/>
563     </xsl:when>
564     <xsl:otherwise>
565       <xsl:apply-templates mode="no.anchor.mode"/>
566     </xsl:otherwise>
567   </xsl:choose>
568 </xsl:template>
569
570 <!-- ============================================================ -->
571
572 <xsl:template match="*" mode="no.anchor.mode">
573   <!-- Switch to normal mode if no links -->
574   <xsl:choose>
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">
582
583       <xsl:apply-templates mode="no.anchor.mode"/>
584     </xsl:when>
585     <xsl:otherwise>
586       <xsl:apply-templates select="."/>
587     </xsl:otherwise>
588   </xsl:choose>
589 </xsl:template>
590
591 <xsl:template match="footnote" mode="no.anchor.mode">
592   <!-- nop, suppressed -->
593 </xsl:template>
594
595 <xsl:template match="anchor" mode="no.anchor.mode">
596   <!-- nop, suppressed -->
597 </xsl:template>
598
599 <xsl:template match="ulink" mode="no.anchor.mode">
600   <xsl:apply-templates/>
601 </xsl:template>
602
603 <xsl:template match="link" mode="no.anchor.mode">
604   <xsl:apply-templates/>
605 </xsl:template>
606
607 <xsl:template match="olink" mode="no.anchor.mode">
608   <xsl:apply-templates/>
609 </xsl:template>
610
611 <xsl:template match="indexterm" mode="no.anchor.mode">
612   <!-- nop, suppressed -->
613 </xsl:template>
614
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)"/>
619   
620   <xsl:call-template name="check.id.unique">
621     <xsl:with-param name="linkend" select="@linkend"/>
622   </xsl:call-template>
623
624   <xsl:choose>
625     <xsl:when test="count($target) = 0">
626       <xsl:message>
627         <xsl:text>XRef to nonexistent id: </xsl:text>
628         <xsl:value-of select="@linkend"/>
629       </xsl:message>
630       <xsl:text>???</xsl:text>
631     </xsl:when>
632
633     <xsl:when test="@endterm">
634       <xsl:variable name="etargets" select="key('id',@endterm)"/>
635       <xsl:variable name="etarget" select="$etargets[1]"/>
636       <xsl:choose>
637         <xsl:when test="count($etarget) = 0">
638           <xsl:message>
639             <xsl:value-of select="count($etargets)"/>
640             <xsl:text>Endterm points to nonexistent ID: </xsl:text>
641             <xsl:value-of select="@endterm"/>
642           </xsl:message>
643           <xsl:text>???</xsl:text>
644         </xsl:when>
645         <xsl:otherwise>
646           <xsl:apply-templates select="$etarget" mode="endterm"/>
647         </xsl:otherwise>
648       </xsl:choose>
649     </xsl:when>
650
651     <xsl:when test="$target/@xreflabel">
652       <xsl:call-template name="xref.xreflabel">
653         <xsl:with-param name="target" select="$target"/>
654       </xsl:call-template>
655     </xsl:when>
656
657     <xsl:otherwise>
658       <xsl:apply-templates select="$target" mode="xref-to-prefix"/>
659
660       <xsl:apply-templates select="$target" mode="xref-to">
661         <xsl:with-param name="referrer" select="."/>
662         <xsl:with-param name="xrefstyle">
663           <xsl:choose>
664             <xsl:when test="@role and not(@xrefstyle) and $use.role.as.xrefstyle != 0">
665               <xsl:value-of select="@role"/>
666             </xsl:when>
667             <xsl:otherwise>
668               <xsl:value-of select="@xrefstyle"/>
669             </xsl:otherwise>
670           </xsl:choose>
671         </xsl:with-param>
672       </xsl:apply-templates>
673
674       <xsl:apply-templates select="$target" mode="xref-to-suffix"/>
675     </xsl:otherwise>
676   </xsl:choose>
677 </xsl:template>
678
679 <!-- ============================================================ -->
680
681 </xsl:stylesheet>
682