Rocco Rutte:
[apps/madmutt.git] / doc / xslt / xhtml / xref.xsl
1 <?xml version="1.0" encoding="US-ASCII"?>
2 <!--This file was created automatically by html2xhtml-->
3 <!--from the HTML stylesheets. Do not edit this file.-->
4 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:suwl="http://nwalsh.com/xslt/ext/com.nwalsh.saxon.UnwrapLinks" xmlns:exsl="http://exslt.org/common" xmlns="http://www.w3.org/1999/xhtml" exclude-result-prefixes="suwl exsl" version="1.0">
5
6 <!-- ********************************************************************
7      $Id$
8      ********************************************************************
9
10      This file is part of the XSL DocBook Stylesheet distribution.
11      See ../README or http://nwalsh.com/docbook/xsl/ for copyright
12      and other information.
13
14      ******************************************************************** -->
15
16 <!-- ==================================================================== -->
17
18 <xsl:template match="anchor">
19   <xsl:call-template name="anchor"/>
20 </xsl:template>
21
22 <!-- ==================================================================== -->
23
24 <xsl:template match="xref" name="xref">
25   <xsl:variable name="targets" select="key('id',@linkend)"/>
26   <xsl:variable name="target" select="$targets[1]"/>
27   <xsl:variable name="refelem" select="local-name($target)"/>
28
29   <xsl:call-template name="check.id.unique">
30     <xsl:with-param name="linkend" select="@linkend"/>
31   </xsl:call-template>
32
33   <xsl:call-template name="anchor"/>
34
35   <xsl:choose>
36     <xsl:when test="count($target) = 0">
37       <xsl:message>
38         <xsl:text>XRef to nonexistent id: </xsl:text>
39         <xsl:value-of select="@linkend"/>
40       </xsl:message>
41       <xsl:text>???</xsl:text>
42     </xsl:when>
43
44     <xsl:when test="@endterm">
45       <xsl:variable name="href">
46         <xsl:call-template name="href.target">
47           <xsl:with-param name="object" select="$target"/>
48         </xsl:call-template>
49       </xsl:variable>
50
51       <xsl:variable name="etargets" select="key('id',@endterm)"/>
52       <xsl:variable name="etarget" select="$etargets[1]"/>
53       <xsl:choose>
54         <xsl:when test="count($etarget) = 0">
55           <xsl:message>
56             <xsl:value-of select="count($etargets)"/>
57             <xsl:text>Endterm points to nonexistent ID: </xsl:text>
58             <xsl:value-of select="@endterm"/>
59           </xsl:message>
60           <a href="{$href}">
61             <xsl:text>???</xsl:text>
62           </a>
63         </xsl:when>
64         <xsl:otherwise>
65           <a href="{$href}">
66             <xsl:apply-templates select="$etarget" mode="endterm"/>
67           </a>
68         </xsl:otherwise>
69       </xsl:choose>
70     </xsl:when>
71
72     <xsl:when test="$target/@xreflabel">
73       <a>
74         <xsl:attribute name="href">
75           <xsl:call-template name="href.target">
76             <xsl:with-param name="object" select="$target"/>
77           </xsl:call-template>
78         </xsl:attribute>
79         <xsl:call-template name="xref.xreflabel">
80           <xsl:with-param name="target" select="$target"/>
81         </xsl:call-template>
82       </a>
83     </xsl:when>
84
85     <xsl:otherwise>
86       <xsl:variable name="href">
87         <xsl:call-template name="href.target">
88           <xsl:with-param name="object" select="$target"/>
89         </xsl:call-template>
90       </xsl:variable>
91
92       <xsl:if test="not(parent::citation)">
93         <xsl:apply-templates select="$target" mode="xref-to-prefix"/>
94       </xsl:if>
95
96       <a href="{$href}">
97         <xsl:if test="$target/title or $target/*/title">
98           <xsl:attribute name="title">
99             <xsl:apply-templates select="$target" mode="xref-title"/>
100           </xsl:attribute>
101         </xsl:if>
102         <xsl:apply-templates select="$target" mode="xref-to">
103           <xsl:with-param name="referrer" select="."/>
104           <xsl:with-param name="xrefstyle">
105             <xsl:choose>
106               <xsl:when test="@role and not(@xrefstyle) and $use.role.as.xrefstyle != 0">
107                 <xsl:value-of select="@role"/>
108               </xsl:when>
109               <xsl:otherwise>
110                 <xsl:value-of select="@xrefstyle"/>
111               </xsl:otherwise>
112             </xsl:choose>
113           </xsl:with-param>
114         </xsl:apply-templates>
115       </a>
116
117       <xsl:if test="not(parent::citation)">
118         <xsl:apply-templates select="$target" mode="xref-to-suffix"/>
119       </xsl:if>
120     </xsl:otherwise>
121   </xsl:choose>
122 </xsl:template>
123
124 <!-- ==================================================================== -->
125
126 <!-- biblioref handled largely like an xref -->
127 <!-- To be done: add support for begin, end, and units attributes -->
128 <xsl:template match="biblioref">
129   <xsl:variable name="targets" select="key('id',@linkend)"/>
130   <xsl:variable name="target" select="$targets[1]"/>
131   <xsl:variable name="refelem" select="local-name($target)"/>
132
133   <xsl:call-template name="check.id.unique">
134     <xsl:with-param name="linkend" select="@linkend"/>
135   </xsl:call-template>
136
137   <xsl:call-template name="anchor"/>
138
139   <xsl:choose>
140     <xsl:when test="count($target) = 0">
141       <xsl:message>
142         <xsl:text>XRef to nonexistent id: </xsl:text>
143         <xsl:value-of select="@linkend"/>
144       </xsl:message>
145       <xsl:text>???</xsl:text>
146     </xsl:when>
147
148     <xsl:when test="@endterm">
149       <xsl:variable name="href">
150         <xsl:call-template name="href.target">
151           <xsl:with-param name="object" select="$target"/>
152         </xsl:call-template>
153       </xsl:variable>
154
155       <xsl:variable name="etargets" select="key('id',@endterm)"/>
156       <xsl:variable name="etarget" select="$etargets[1]"/>
157       <xsl:choose>
158         <xsl:when test="count($etarget) = 0">
159           <xsl:message>
160             <xsl:value-of select="count($etargets)"/>
161             <xsl:text>Endterm points to nonexistent ID: </xsl:text>
162             <xsl:value-of select="@endterm"/>
163           </xsl:message>
164           <a href="{$href}">
165             <xsl:text>???</xsl:text>
166           </a>
167         </xsl:when>
168         <xsl:otherwise>
169           <a href="{$href}">
170             <xsl:apply-templates select="$etarget" mode="endterm"/>
171           </a>
172         </xsl:otherwise>
173       </xsl:choose>
174     </xsl:when>
175
176     <xsl:when test="$target/@xreflabel">
177       <a>
178         <xsl:attribute name="href">
179           <xsl:call-template name="href.target">
180             <xsl:with-param name="object" select="$target"/>
181           </xsl:call-template>
182         </xsl:attribute>
183         <xsl:call-template name="xref.xreflabel">
184           <xsl:with-param name="target" select="$target"/>
185         </xsl:call-template>
186       </a>
187     </xsl:when>
188
189     <xsl:otherwise>
190       <xsl:variable name="href">
191         <xsl:call-template name="href.target">
192           <xsl:with-param name="object" select="$target"/>
193         </xsl:call-template>
194       </xsl:variable>
195
196       <xsl:if test="not(parent::citation)">
197         <xsl:apply-templates select="$target" mode="xref-to-prefix"/>
198       </xsl:if>
199
200       <a href="{$href}">
201         <xsl:if test="$target/title or $target/*/title">
202           <xsl:attribute name="title">
203             <xsl:apply-templates select="$target" mode="xref-title"/>
204           </xsl:attribute>
205         </xsl:if>
206         <xsl:apply-templates select="$target" mode="xref-to">
207           <xsl:with-param name="referrer" select="."/>
208           <xsl:with-param name="xrefstyle">
209             <xsl:choose>
210               <xsl:when test="@role and not(@xrefstyle) and $use.role.as.xrefstyle != 0">
211                 <xsl:value-of select="@role"/>
212               </xsl:when>
213               <xsl:otherwise>
214                 <xsl:value-of select="@xrefstyle"/>
215               </xsl:otherwise>
216             </xsl:choose>
217           </xsl:with-param>
218         </xsl:apply-templates>
219       </a>
220
221       <xsl:if test="not(parent::citation)">
222         <xsl:apply-templates select="$target" mode="xref-to-suffix"/>
223       </xsl:if>
224     </xsl:otherwise>
225   </xsl:choose>
226 </xsl:template>
227
228 <!-- ==================================================================== -->
229
230 <xsl:template match="*" mode="endterm">
231   <!-- Process the children of the endterm element -->
232   <xsl:variable name="endterm">
233     <xsl:apply-templates select="child::node()"/>
234   </xsl:variable>
235
236   <xsl:choose>
237     <xsl:when test="function-available('exsl:node-set')">
238       <xsl:apply-templates select="exsl:node-set($endterm)" mode="remove-ids"/>
239     </xsl:when>
240     <xsl:otherwise>
241       <xsl:copy-of select="$endterm"/>
242     </xsl:otherwise>
243   </xsl:choose>
244 </xsl:template>
245
246 <xsl:template match="*" mode="remove-ids">
247   <xsl:choose>
248     <!-- handle html or xhtml -->
249     <xsl:when test="local-name(.) = 'a'                     and (namespace-uri(.) = ''                          or namespace-uri(.) = 'http://www.w3.org/1999/xhtml')">
250       <xsl:choose>
251         <xsl:when test="(@name and count(@*) = 1)                         or (@id and count(@*) = 1)                         or (@id and @name and count(@*) = 2)">
252           <xsl:message>suppress anchor</xsl:message>
253           <!-- suppress the whole thing -->
254         </xsl:when>
255         <xsl:otherwise>
256           <xsl:copy>
257             <xsl:for-each select="@*">
258               <xsl:choose>
259                 <xsl:when test="name(.) != 'name' and name(.) != 'id'">
260                   <xsl:copy/>
261                 </xsl:when>
262                 <xsl:otherwise>
263                   <xsl:message>removing <xsl:value-of select="name(.)"/></xsl:message>
264                 </xsl:otherwise>
265               </xsl:choose>
266             </xsl:for-each>
267           </xsl:copy>
268           <xsl:apply-templates mode="remove-ids"/>
269         </xsl:otherwise>
270       </xsl:choose>
271     </xsl:when>
272     <xsl:otherwise>
273       <xsl:copy>
274         <xsl:for-each select="@*">
275           <xsl:choose>
276             <xsl:when test="name(.) != 'id'">
277               <xsl:copy/>
278             </xsl:when>
279             <xsl:otherwise>
280               <xsl:message>removing <xsl:value-of select="name(.)"/></xsl:message>
281             </xsl:otherwise>
282           </xsl:choose>
283         </xsl:for-each>
284         <xsl:apply-templates mode="remove-ids"/>
285       </xsl:copy>
286     </xsl:otherwise>
287   </xsl:choose>
288 </xsl:template>
289
290 <!-- ==================================================================== -->
291
292 <xsl:template match="*" mode="xref-to-prefix"/>
293 <xsl:template match="*" mode="xref-to-suffix"/>
294
295 <xsl:template match="*" mode="xref-to">
296   <xsl:param name="referrer"/>
297   <xsl:param name="xrefstyle"/>
298   <xsl:param name="verbose" select="1"/>
299
300   <xsl:if test="$verbose">
301     <xsl:message>
302       <xsl:text>Don't know what gentext to create for xref to: "</xsl:text>
303       <xsl:value-of select="name(.)"/>
304       <xsl:text>", ("</xsl:text>
305       <xsl:value-of select="@id"/>
306       <xsl:text>")</xsl:text>
307     </xsl:message>
308   </xsl:if>
309   <xsl:text>???</xsl:text>
310 </xsl:template>
311
312 <xsl:template match="title" mode="xref-to">
313   <xsl:param name="referrer"/>
314   <xsl:param name="xrefstyle"/>
315   <xsl:param name="verbose" select="1"/>
316
317   <!-- if you xref to a title, xref to the parent... -->
318   <xsl:choose>
319     <!-- FIXME: how reliable is this? -->
320     <xsl:when test="contains(local-name(parent::*), 'info')">
321       <xsl:apply-templates select="parent::*[2]" mode="xref-to">
322         <xsl:with-param name="referrer" select="$referrer"/>
323         <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
324         <xsl:with-param name="verbose" select="$verbose"/>
325       </xsl:apply-templates>
326     </xsl:when>
327     <xsl:otherwise>
328       <xsl:apply-templates select="parent::*" mode="xref-to">
329         <xsl:with-param name="referrer" select="$referrer"/>
330         <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
331         <xsl:with-param name="verbose" select="$verbose"/>
332       </xsl:apply-templates>
333     </xsl:otherwise>
334   </xsl:choose>
335 </xsl:template>
336
337 <xsl:template match="abstract|authorblurb|personblurb|bibliodiv|bibliomset                      |biblioset|blockquote|calloutlist|caution|colophon                      |constraintdef|formalpara|glossdiv|important|indexdiv                      |itemizedlist|legalnotice|lot|msg|msgexplan|msgmain                      |msgrel|msgset|msgsub|note|orderedlist|partintro                      |productionset|qandadiv|refsynopsisdiv|segmentedlist                      |set|setindex|sidebar|tip|toc|variablelist|warning" mode="xref-to">
338   <xsl:param name="referrer"/>
339   <xsl:param name="xrefstyle"/>
340   <xsl:param name="verbose" select="1"/>
341
342   <!-- catch-all for things with (possibly optional) titles -->
343   <xsl:apply-templates select="." mode="object.xref.markup">
344     <xsl:with-param name="purpose" select="'xref'"/>
345     <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
346     <xsl:with-param name="referrer" select="$referrer"/>
347     <xsl:with-param name="verbose" select="$verbose"/>
348   </xsl:apply-templates>
349 </xsl:template>
350
351 <xsl:template match="author|editor|othercredit|personname" mode="xref-to">
352   <xsl:param name="referrer"/>
353   <xsl:param name="xrefstyle"/>
354
355   <xsl:call-template name="person.name"/>
356 </xsl:template>
357
358 <xsl:template match="authorgroup" mode="xref-to">
359   <xsl:param name="referrer"/>
360   <xsl:param name="xrefstyle"/>
361
362   <xsl:call-template name="person.name.list"/>
363 </xsl:template>
364
365 <xsl:template match="figure|example|table|equation" mode="xref-to">
366   <xsl:param name="referrer"/>
367   <xsl:param name="xrefstyle"/>
368   <xsl:param name="verbose" select="1"/>
369
370   <xsl:apply-templates select="." mode="object.xref.markup">
371     <xsl:with-param name="purpose" select="'xref'"/>
372     <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
373     <xsl:with-param name="referrer" select="$referrer"/>
374     <xsl:with-param name="verbose" select="$verbose"/>
375   </xsl:apply-templates>
376 </xsl:template>
377
378 <xsl:template match="procedure" mode="xref-to">
379   <xsl:param name="referrer"/>
380   <xsl:param name="xrefstyle"/>
381   <xsl:param name="verbose"/>
382
383   <xsl:apply-templates select="." mode="object.xref.markup">
384     <xsl:with-param name="purpose" select="'xref'"/>
385     <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
386     <xsl:with-param name="referrer" select="$referrer"/>
387     <xsl:with-param name="verbose" select="$verbose"/>
388   </xsl:apply-templates>
389 </xsl:template>
390
391 <xsl:template match="cmdsynopsis" mode="xref-to">
392   <xsl:apply-templates select="(.//command)[1]" mode="xref"/>
393 </xsl:template>
394
395 <xsl:template match="funcsynopsis" mode="xref-to">
396   <xsl:apply-templates select="(.//function)[1]" mode="xref"/>
397 </xsl:template>
398
399 <xsl:template match="dedication|preface|chapter|appendix|article" mode="xref-to">
400   <xsl:param name="referrer"/>
401   <xsl:param name="xrefstyle"/>
402   <xsl:param name="verbose" select="1"/>
403
404   <xsl:apply-templates select="." mode="object.xref.markup">
405     <xsl:with-param name="purpose" select="'xref'"/>
406     <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
407     <xsl:with-param name="referrer" select="$referrer"/>
408     <xsl:with-param name="verbose" select="$verbose"/>
409   </xsl:apply-templates>
410 </xsl:template>
411
412 <xsl:template match="bibliography" mode="xref-to">
413   <xsl:param name="referrer"/>
414   <xsl:param name="xrefstyle"/>
415   <xsl:param name="verbose" select="1"/>
416
417   <xsl:apply-templates select="." mode="object.xref.markup">
418     <xsl:with-param name="purpose" select="'xref'"/>
419     <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
420     <xsl:with-param name="referrer" select="$referrer"/>
421     <xsl:with-param name="verbose" select="$verbose"/>
422   </xsl:apply-templates>
423 </xsl:template>
424
425 <xsl:template match="biblioentry|bibliomixed" mode="xref-to-prefix">
426   <xsl:text>[</xsl:text>
427 </xsl:template>
428
429 <xsl:template match="biblioentry|bibliomixed" mode="xref-to-suffix">
430   <xsl:text>]</xsl:text>
431 </xsl:template>
432
433 <xsl:template match="biblioentry|bibliomixed" mode="xref-to">
434   <xsl:param name="referrer"/>
435   <xsl:param name="xrefstyle"/>
436   <xsl:param name="verbose" select="1"/>
437
438   <!-- handles both biblioentry and bibliomixed -->
439   <xsl:choose>
440     <xsl:when test="string(.) = ''">
441       <xsl:variable name="bib" select="document($bibliography.collection,.)"/>
442       <xsl:variable name="id" select="@id"/>
443       <xsl:variable name="entry" select="$bib/bibliography/*[@id=$id][1]"/>
444       <xsl:choose>
445         <xsl:when test="$entry">
446           <xsl:choose>
447             <xsl:when test="$bibliography.numbered != 0">
448               <xsl:number from="bibliography" count="biblioentry|bibliomixed" level="any" format="1"/>
449             </xsl:when>
450             <xsl:when test="local-name($entry/*[1]) = 'abbrev'">
451               <xsl:apply-templates select="$entry/*[1]"/>
452             </xsl:when>
453             <xsl:otherwise>
454               <xsl:value-of select="@id"/>
455             </xsl:otherwise>
456           </xsl:choose>
457         </xsl:when>
458         <xsl:otherwise>
459           <xsl:message>
460             <xsl:text>No bibliography entry: </xsl:text>
461             <xsl:value-of select="$id"/>
462             <xsl:text> found in </xsl:text>
463             <xsl:value-of select="$bibliography.collection"/>
464           </xsl:message>
465           <xsl:value-of select="@id"/>
466         </xsl:otherwise>
467       </xsl:choose>
468     </xsl:when>
469     <xsl:otherwise>
470       <xsl:choose>
471         <xsl:when test="$bibliography.numbered != 0">
472           <xsl:number from="bibliography" count="biblioentry|bibliomixed" level="any" format="1"/>
473         </xsl:when>
474         <xsl:when test="local-name(*[1]) = 'abbrev'">
475           <xsl:apply-templates select="*[1]"/>
476         </xsl:when>
477         <xsl:otherwise>
478           <xsl:value-of select="@id"/>
479         </xsl:otherwise>
480       </xsl:choose>
481     </xsl:otherwise>
482   </xsl:choose>
483 </xsl:template>
484
485 <xsl:template match="glossary" mode="xref-to">
486   <xsl:param name="referrer"/>
487   <xsl:param name="xrefstyle"/>
488   <xsl:param name="verbose" select="1"/>
489
490   <xsl:apply-templates select="." mode="object.xref.markup">
491     <xsl:with-param name="purpose" select="'xref'"/>
492     <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
493     <xsl:with-param name="referrer" select="$referrer"/>
494     <xsl:with-param name="verbose" select="$verbose"/>
495   </xsl:apply-templates>
496 </xsl:template>
497
498 <xsl:template match="glossentry" mode="xref-to">
499   <xsl:param name="referrer"/>
500   <xsl:param name="xrefstyle"/>
501   <xsl:param name="verbose" select="1"/>
502   <xsl:choose>
503     <xsl:when test="$glossentry.show.acronym = 'primary'">
504       <xsl:choose>
505         <xsl:when test="acronym|abbrev">
506           <xsl:apply-templates select="(acronym|abbrev)[1]"/>
507         </xsl:when>
508         <xsl:otherwise>
509           <xsl:apply-templates select="glossterm[1]" mode="xref-to">
510             <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
511             <xsl:with-param name="referrer" select="$referrer"/>
512             <xsl:with-param name="verbose" select="$verbose"/>
513           </xsl:apply-templates>
514         </xsl:otherwise>
515       </xsl:choose>
516     </xsl:when>
517     <xsl:otherwise>
518       <xsl:apply-templates select="glossterm[1]" mode="xref-to">
519         <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
520         <xsl:with-param name="referrer" select="$referrer"/>
521         <xsl:with-param name="verbose" select="$verbose"/>
522       </xsl:apply-templates>
523     </xsl:otherwise>
524   </xsl:choose>
525 </xsl:template>
526
527 <xsl:template match="glossterm" mode="xref-to">
528   <xsl:apply-templates/>
529 </xsl:template>
530
531 <xsl:template match="index" mode="xref-to">
532   <xsl:param name="referrer"/>
533   <xsl:param name="xrefstyle"/>
534   <xsl:param name="verbose" select="1"/>
535
536   <xsl:apply-templates select="." mode="object.xref.markup">
537     <xsl:with-param name="purpose" select="'xref'"/>
538     <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
539     <xsl:with-param name="referrer" select="$referrer"/>
540     <xsl:with-param name="verbose" select="$verbose"/>
541   </xsl:apply-templates>
542 </xsl:template>
543
544 <xsl:template match="listitem" mode="xref-to">
545   <xsl:param name="referrer"/>
546   <xsl:param name="xrefstyle"/>
547   <xsl:param name="verbose"/>
548
549   <xsl:apply-templates select="." mode="object.xref.markup">
550     <xsl:with-param name="purpose" select="'xref'"/>
551     <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
552     <xsl:with-param name="referrer" select="$referrer"/>
553     <xsl:with-param name="verbose" select="$verbose"/>
554   </xsl:apply-templates>
555 </xsl:template>
556
557 <xsl:template match="section|simplesect                      |sect1|sect2|sect3|sect4|sect5                      |refsect1|refsect2|refsect3|refsection" mode="xref-to">
558   <xsl:param name="referrer"/>
559   <xsl:param name="xrefstyle"/>
560   <xsl:param name="verbose" select="1"/>
561
562   <xsl:apply-templates select="." mode="object.xref.markup">
563     <xsl:with-param name="purpose" select="'xref'"/>
564     <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
565     <xsl:with-param name="referrer" select="$referrer"/>
566     <xsl:with-param name="verbose" select="$verbose"/>
567   </xsl:apply-templates>
568   <!-- FIXME: What about "in Chapter X"? -->
569 </xsl:template>
570
571 <xsl:template match="bridgehead" mode="xref-to">
572   <xsl:param name="referrer"/>
573   <xsl:param name="xrefstyle"/>
574   <xsl:param name="verbose" select="1"/>
575
576   <xsl:apply-templates select="." mode="object.xref.markup">
577     <xsl:with-param name="purpose" select="'xref'"/>
578     <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
579     <xsl:with-param name="referrer" select="$referrer"/>
580     <xsl:with-param name="verbose" select="$verbose"/>
581   </xsl:apply-templates>
582   <!-- FIXME: What about "in Chapter X"? -->
583 </xsl:template>
584
585 <xsl:template match="qandaset" mode="xref-to">
586   <xsl:param name="referrer"/>
587   <xsl:param name="xrefstyle"/>
588   <xsl:param name="verbose" select="1"/>
589
590   <xsl:apply-templates select="." mode="object.xref.markup">
591     <xsl:with-param name="purpose" select="'xref'"/>
592     <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
593     <xsl:with-param name="referrer" select="$referrer"/>
594     <xsl:with-param name="verbose" select="$verbose"/>
595   </xsl:apply-templates>
596 </xsl:template>
597
598 <xsl:template match="qandadiv" mode="xref-to">
599   <xsl:param name="referrer"/>
600   <xsl:param name="xrefstyle"/>
601   <xsl:param name="verbose" select="1"/>
602
603   <xsl:apply-templates select="." mode="object.xref.markup">
604     <xsl:with-param name="purpose" select="'xref'"/>
605     <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
606     <xsl:with-param name="referrer" select="$referrer"/>
607     <xsl:with-param name="verbose" select="$verbose"/>
608   </xsl:apply-templates>
609 </xsl:template>
610
611 <xsl:template match="qandaentry" mode="xref-to">
612   <xsl:param name="referrer"/>
613   <xsl:param name="xrefstyle"/>
614   <xsl:param name="verbose" select="1"/>
615
616   <xsl:apply-templates select="question[1]" mode="object.xref.markup">
617     <xsl:with-param name="purpose" select="'xref'"/>
618     <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
619     <xsl:with-param name="referrer" select="$referrer"/>
620     <xsl:with-param name="verbose" select="$verbose"/>
621   </xsl:apply-templates>
622 </xsl:template>
623
624 <xsl:template match="question|answer" mode="xref-to">
625   <xsl:param name="referrer"/>
626   <xsl:param name="xrefstyle"/>
627   <xsl:param name="verbose" select="1"/>
628
629   <xsl:apply-templates select="." mode="object.xref.markup">
630     <xsl:with-param name="purpose" select="'xref'"/>
631     <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
632     <xsl:with-param name="referrer" select="$referrer"/>
633     <xsl:with-param name="verbose" select="$verbose"/>
634   </xsl:apply-templates>
635 </xsl:template>
636
637 <xsl:template match="part|reference" mode="xref-to">
638   <xsl:param name="referrer"/>
639   <xsl:param name="xrefstyle"/>
640   <xsl:param name="verbose" select="1"/>
641
642   <xsl:apply-templates select="." mode="object.xref.markup">
643     <xsl:with-param name="purpose" select="'xref'"/>
644     <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
645     <xsl:with-param name="referrer" select="$referrer"/>
646     <xsl:with-param name="verbose" select="$verbose"/>
647   </xsl:apply-templates>
648 </xsl:template>
649
650 <xsl:template match="refentry" mode="xref-to">
651   <xsl:param name="referrer"/>
652   <xsl:param name="xrefstyle"/>
653
654   <xsl:choose>
655     <xsl:when test="refmeta/refentrytitle">
656       <xsl:apply-templates select="refmeta/refentrytitle"/>
657     </xsl:when>
658     <xsl:otherwise>
659       <xsl:apply-templates select="refnamediv/refname[1]"/>
660     </xsl:otherwise>
661   </xsl:choose>
662   <xsl:apply-templates select="refmeta/manvolnum"/>
663 </xsl:template>
664
665 <xsl:template match="refnamediv" mode="xref-to">
666   <xsl:param name="referrer"/>
667   <xsl:param name="xrefstyle"/>
668   <xsl:param name="verbose" select="1"/>
669
670   <xsl:apply-templates select="refname[1]" mode="xref-to">
671     <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
672     <xsl:with-param name="referrer" select="$referrer"/>
673     <xsl:with-param name="verbose" select="$verbose"/>
674   </xsl:apply-templates>
675 </xsl:template>
676
677 <xsl:template match="refname" mode="xref-to">
678   <xsl:param name="referrer"/>
679   <xsl:param name="xrefstyle"/>
680   <xsl:param name="verbose" select="1"/>
681
682   <xsl:apply-templates mode="xref-to"/>
683 </xsl:template>
684
685 <xsl:template match="step" mode="xref-to">
686   <xsl:param name="referrer"/>
687   <xsl:param name="xrefstyle"/>
688
689   <xsl:call-template name="gentext">
690     <xsl:with-param name="key" select="'Step'"/>
691   </xsl:call-template>
692   <xsl:text> </xsl:text>
693   <xsl:apply-templates select="." mode="number"/>
694 </xsl:template>
695
696 <xsl:template match="varlistentry" mode="xref-to">
697   <xsl:param name="referrer"/>
698   <xsl:param name="xrefstyle"/>
699   <xsl:param name="verbose" select="1"/>
700
701   <xsl:apply-templates select="term[1]" mode="xref-to">
702     <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
703     <xsl:with-param name="referrer" select="$referrer"/>
704     <xsl:with-param name="verbose" select="$verbose"/>
705   </xsl:apply-templates>
706 </xsl:template>
707
708 <xsl:template match="varlistentry/term" mode="xref-to">
709   <xsl:param name="referrer"/>
710   <xsl:param name="xrefstyle"/>
711
712   <!-- to avoid the comma that will be generated if there are several terms -->
713   <xsl:apply-templates/>
714 </xsl:template>
715
716 <xsl:template match="co" mode="xref-to">
717   <xsl:param name="referrer"/>
718   <xsl:param name="xrefstyle"/>
719
720   <xsl:apply-templates select="." mode="callout-bug"/>
721 </xsl:template>
722
723 <xsl:template match="book" mode="xref-to">
724   <xsl:param name="referrer"/>
725   <xsl:param name="xrefstyle"/>
726   <xsl:param name="verbose" select="1"/>
727
728   <xsl:apply-templates select="." mode="object.xref.markup">
729     <xsl:with-param name="purpose" select="'xref'"/>
730     <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
731     <xsl:with-param name="referrer" select="$referrer"/>
732     <xsl:with-param name="verbose" select="$verbose"/>
733   </xsl:apply-templates>
734 </xsl:template>
735
736 <xsl:template match="para" mode="xref-to">
737   <xsl:param name="referrer"/>
738   <xsl:param name="xrefstyle"/>
739   <xsl:param name="verbose" select="1"/>
740
741   <xsl:variable name="context" select="(ancestor::simplesect                                        |ancestor::section                                        |ancestor::sect1                                        |ancestor::sect2                                        |ancestor::sect3                                        |ancestor::sect4                                        |ancestor::sect5                                        |ancestor::refsection                                        |ancestor::refsect1                                        |ancestor::refsect2                                        |ancestor::refsect3                                        |ancestor::chapter                                        |ancestor::appendix                                        |ancestor::preface                                        |ancestor::partintro                                        |ancestor::dedication                                        |ancestor::colophon                                        |ancestor::bibliography                                        |ancestor::index                                        |ancestor::glossary                                        |ancestor::glossentry                                        |ancestor::listitem                                        |ancestor::varlistentry)[last()]"/>
742
743   <xsl:apply-templates select="$context" mode="xref-to">
744     <xsl:with-param name="purpose" select="'xref'"/>
745     <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
746     <xsl:with-param name="referrer" select="$referrer"/>
747     <xsl:with-param name="verbose" select="$verbose"/>
748   </xsl:apply-templates>
749 </xsl:template>
750
751 <!-- ==================================================================== -->
752
753 <xsl:template match="*" mode="xref-title">
754   <xsl:variable name="title">
755     <xsl:apply-templates select="." mode="object.title.markup"/>
756   </xsl:variable>
757
758   <xsl:value-of select="$title"/>
759 </xsl:template>
760
761 <xsl:template match="author" mode="xref-title">
762   <xsl:variable name="title">
763     <xsl:call-template name="person.name"/>
764   </xsl:variable>
765
766   <xsl:value-of select="$title"/>
767 </xsl:template>
768
769 <xsl:template match="authorgroup" mode="xref-title">
770   <xsl:variable name="title">
771     <xsl:call-template name="person.name.list"/>
772   </xsl:variable>
773
774   <xsl:value-of select="$title"/>
775 </xsl:template>
776
777 <xsl:template match="cmdsynopsis" mode="xref-title">
778   <xsl:variable name="title">
779     <xsl:apply-templates select="(.//command)[1]" mode="xref"/>
780   </xsl:variable>
781
782   <xsl:value-of select="$title"/>
783 </xsl:template>
784
785 <xsl:template match="funcsynopsis" mode="xref-title">
786   <xsl:variable name="title">
787     <xsl:apply-templates select="(.//function)[1]" mode="xref"/>
788   </xsl:variable>
789
790   <xsl:value-of select="$title"/>
791 </xsl:template>
792
793 <xsl:template match="biblioentry|bibliomixed" mode="xref-title">
794   <!-- handles both biblioentry and bibliomixed -->
795   <xsl:variable name="title">
796     <xsl:text>[</xsl:text>
797     <xsl:choose>
798       <xsl:when test="local-name(*[1]) = 'abbrev'">
799         <xsl:apply-templates select="*[1]"/>
800       </xsl:when>
801       <xsl:otherwise>
802         <xsl:value-of select="@id"/>
803       </xsl:otherwise>
804     </xsl:choose>
805     <xsl:text>]</xsl:text>
806   </xsl:variable>
807
808   <xsl:value-of select="$title"/>
809 </xsl:template>
810
811 <xsl:template match="step" mode="xref-title">
812   <xsl:call-template name="gentext">
813     <xsl:with-param name="key" select="'Step'"/>
814   </xsl:call-template>
815   <xsl:text> </xsl:text>
816   <xsl:apply-templates select="." mode="number"/>
817 </xsl:template>
818
819 <xsl:template match="co" mode="xref-title">
820   <xsl:variable name="title">
821     <xsl:apply-templates select="." mode="callout-bug"/>
822   </xsl:variable>
823
824   <xsl:value-of select="$title"/>
825 </xsl:template>
826
827 <!-- ==================================================================== -->
828
829 <xsl:template match="link" name="link">
830   <xsl:param name="a.target"/>
831
832   <xsl:variable name="targets" select="key('id',@linkend)"/>
833   <xsl:variable name="target" select="$targets[1]"/>
834
835   <xsl:call-template name="check.id.unique">
836     <xsl:with-param name="linkend" select="@linkend"/>
837   </xsl:call-template>
838
839   <a>
840     <xsl:if test="@id">
841       <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
842     </xsl:if>
843
844     <xsl:if test="$a.target">
845       <xsl:attribute name="target"><xsl:value-of select="$a.target"/></xsl:attribute>
846     </xsl:if>
847
848     <xsl:attribute name="href">
849       <xsl:call-template name="href.target">
850         <xsl:with-param name="object" select="$target"/>
851       </xsl:call-template>
852     </xsl:attribute>
853
854     <!-- FIXME: is there a better way to tell what elements have a title? -->
855     <xsl:if test="local-name($target) = 'book'                   or local-name($target) = 'set'                   or local-name($target) = 'chapter'                   or local-name($target) = 'preface'                   or local-name($target) = 'appendix'                   or local-name($target) = 'bibliography'                   or local-name($target) = 'glossary'                   or local-name($target) = 'index'                   or local-name($target) = 'part'                   or local-name($target) = 'refentry'                   or local-name($target) = 'reference'                   or local-name($target) = 'example'                   or local-name($target) = 'equation'                   or local-name($target) = 'table'                   or local-name($target) = 'figure'                   or local-name($target) = 'simplesect'                   or starts-with(local-name($target),'sect')                   or starts-with(local-name($target),'refsect')">
856       <xsl:attribute name="title">
857         <xsl:apply-templates select="$target" mode="object.title.markup.textonly"/>
858       </xsl:attribute>
859     </xsl:if>
860
861     <xsl:choose>
862       <xsl:when test="count(child::node()) &gt; 0">
863         <!-- If it has content, use it -->
864         <xsl:apply-templates/>
865       </xsl:when>
866       <xsl:otherwise>
867         <!-- else look for an endterm -->
868         <xsl:choose>
869           <xsl:when test="@endterm">
870             <xsl:variable name="etargets" select="key('id',@endterm)"/>
871             <xsl:variable name="etarget" select="$etargets[1]"/>
872             <xsl:choose>
873               <xsl:when test="count($etarget) = 0">
874                 <xsl:message>
875                   <xsl:value-of select="count($etargets)"/>
876                   <xsl:text>Endterm points to nonexistent ID: </xsl:text>
877                   <xsl:value-of select="@endterm"/>
878                 </xsl:message>
879                 <xsl:text>???</xsl:text>
880               </xsl:when>
881               <xsl:otherwise>
882                   <xsl:apply-templates select="$etarget" mode="endterm"/>
883               </xsl:otherwise>
884             </xsl:choose>
885           </xsl:when>
886
887           <xsl:otherwise>
888             <xsl:message>
889               <xsl:text>Link element has no content and no Endterm. </xsl:text>
890               <xsl:text>Nothing to show in the link to </xsl:text>
891               <xsl:value-of select="$target"/>
892             </xsl:message>
893             <xsl:text>???</xsl:text>
894           </xsl:otherwise>
895         </xsl:choose>
896       </xsl:otherwise>
897     </xsl:choose>
898   </a>
899 </xsl:template>
900
901 <xsl:template match="ulink" name="ulink">
902   <xsl:variable name="link">
903     <a>
904       <xsl:if test="@id">
905         <xsl:attribute name="id">
906           <xsl:value-of select="@id"/>
907         </xsl:attribute>
908       </xsl:if>
909       <xsl:attribute name="href"><xsl:value-of select="@url"/></xsl:attribute>
910       <xsl:if test="$ulink.target != ''">
911         <xsl:attribute name="target">
912           <xsl:value-of select="$ulink.target"/>
913         </xsl:attribute>
914       </xsl:if>
915       <xsl:choose>
916         <xsl:when test="count(child::node())=0">
917           <xsl:value-of select="@url"/>
918         </xsl:when>
919         <xsl:otherwise>
920           <xsl:apply-templates/>
921         </xsl:otherwise>
922       </xsl:choose>
923     </a>
924   </xsl:variable>
925
926   <xsl:choose>
927     <xsl:when test="function-available('suwl:unwrapLinks')">
928       <xsl:copy-of select="suwl:unwrapLinks($link)"/>
929     </xsl:when>
930     <xsl:otherwise>
931       <xsl:copy-of select="$link"/>
932     </xsl:otherwise>
933   </xsl:choose>
934 </xsl:template>
935
936 <xsl:template match="olink" name="olink">
937
938   <xsl:call-template name="anchor"/>
939
940   <xsl:variable name="localinfo" select="@localinfo"/>
941
942   <xsl:choose>
943     <!-- olinks resolved by stylesheet and target database -->
944     <xsl:when test="@targetdoc or @targetptr">
945       <xsl:variable name="targetdoc.att" select="@targetdoc"/>
946       <xsl:variable name="targetptr.att" select="@targetptr"/>
947
948       <xsl:variable name="olink.lang">
949         <xsl:call-template name="l10n.language">
950           <xsl:with-param name="xref-context" select="true()"/>
951         </xsl:call-template>
952       </xsl:variable>
953     
954       <xsl:variable name="target.database.filename">
955         <xsl:call-template name="select.target.database">
956           <xsl:with-param name="targetdoc.att" select="$targetdoc.att"/>
957           <xsl:with-param name="targetptr.att" select="$targetptr.att"/>
958           <xsl:with-param name="olink.lang" select="$olink.lang"/>
959         </xsl:call-template>
960       </xsl:variable>
961     
962       <xsl:variable name="target.database" select="document($target.database.filename,/)"/>
963     
964       <xsl:if test="$olink.debug != 0">
965         <xsl:message>
966           <xsl:text>Olink debug: root element of target.database '</xsl:text>
967           <xsl:value-of select="$target.database.filename"/>
968           <xsl:text>' is '</xsl:text>
969           <xsl:value-of select="local-name($target.database/*[1])"/>
970           <xsl:text>'.</xsl:text>
971         </xsl:message>
972       </xsl:if>
973     
974       <xsl:variable name="olink.key">
975         <xsl:call-template name="select.olink.key">
976           <xsl:with-param name="targetdoc.att" select="$targetdoc.att"/>
977           <xsl:with-param name="targetptr.att" select="$targetptr.att"/>
978           <xsl:with-param name="olink.lang" select="$olink.lang"/>
979           <xsl:with-param name="target.database" select="$target.database"/>
980         </xsl:call-template>
981       </xsl:variable>
982     
983       <xsl:if test="string-length($olink.key) = 0">
984         <xsl:message>
985           <xsl:text>Error: unresolved olink: </xsl:text>
986           <xsl:text>targetdoc/targetptr = '</xsl:text>
987           <xsl:value-of select="$targetdoc.att"/>
988           <xsl:text>/</xsl:text>
989           <xsl:value-of select="$targetptr.att"/>
990           <xsl:text>'.</xsl:text>
991         </xsl:message>
992       </xsl:if>
993
994       <xsl:variable name="href">
995         <xsl:call-template name="make.olink.href">
996           <xsl:with-param name="olink.key" select="$olink.key"/>
997           <xsl:with-param name="target.database" select="$target.database"/>
998         </xsl:call-template>
999       </xsl:variable>
1000
1001       <xsl:variable name="hottext">
1002         <xsl:call-template name="olink.hottext">
1003           <xsl:with-param name="target.database" select="$target.database"/>
1004           <xsl:with-param name="olink.key" select="$olink.key"/>
1005           <xsl:with-param name="olink.lang" select="$olink.lang"/>
1006         </xsl:call-template>
1007       </xsl:variable>
1008
1009       <xsl:variable name="olink.docname.citation">
1010         <xsl:call-template name="olink.document.citation">
1011           <xsl:with-param name="olink.key" select="$olink.key"/>
1012           <xsl:with-param name="target.database" select="$target.database"/>
1013           <xsl:with-param name="olink.lang" select="$olink.lang"/>
1014         </xsl:call-template>
1015       </xsl:variable>
1016
1017       <xsl:variable name="olink.page.citation">
1018         <xsl:call-template name="olink.page.citation">
1019           <xsl:with-param name="olink.key" select="$olink.key"/>
1020           <xsl:with-param name="target.database" select="$target.database"/>
1021           <xsl:with-param name="olink.lang" select="$olink.lang"/>
1022         </xsl:call-template>
1023       </xsl:variable>
1024
1025       <xsl:choose>
1026         <xsl:when test="$href != ''">
1027           <a href="{$href}" class="olink">
1028             <xsl:copy-of select="$hottext"/>
1029           </a>
1030           <xsl:copy-of select="$olink.page.citation"/>
1031           <xsl:copy-of select="$olink.docname.citation"/>
1032         </xsl:when>
1033         <xsl:otherwise>
1034           <span class="olink"><xsl:copy-of select="$hottext"/></span>
1035           <xsl:copy-of select="$olink.page.citation"/>
1036           <xsl:copy-of select="$olink.docname.citation"/>
1037         </xsl:otherwise>
1038       </xsl:choose>
1039
1040     </xsl:when>
1041
1042     <!-- Or use old olink mechanism -->
1043     <xsl:otherwise>
1044       <xsl:variable name="href">
1045         <xsl:choose>
1046           <xsl:when test="@linkmode">
1047             <!-- use the linkmode to get the base URI, use localinfo as fragid -->
1048             <xsl:variable name="modespec" select="key('id',@linkmode)"/>
1049             <xsl:if test="count($modespec) != 1                           or local-name($modespec) != 'modespec'">
1050               <xsl:message>Warning: olink linkmode pointer is wrong.</xsl:message>
1051             </xsl:if>
1052             <xsl:value-of select="$modespec"/>
1053             <xsl:if test="@localinfo">
1054               <xsl:text>#</xsl:text>
1055               <xsl:value-of select="@localinfo"/>
1056             </xsl:if>
1057           </xsl:when>
1058           <xsl:when test="@type = 'href'">
1059             <xsl:call-template name="olink.outline">
1060               <xsl:with-param name="outline.base.uri" select="unparsed-entity-uri(@targetdocent)"/>
1061               <xsl:with-param name="localinfo" select="@localinfo"/>
1062               <xsl:with-param name="return" select="'href'"/>
1063             </xsl:call-template>
1064           </xsl:when>
1065           <xsl:otherwise>
1066             <xsl:value-of select="$olink.resolver"/>
1067             <xsl:text>?</xsl:text>
1068             <xsl:value-of select="$olink.sysid"/>
1069             <xsl:value-of select="unparsed-entity-uri(@targetdocent)"/>
1070             <!-- XSL gives no access to the public identifier (grumble...) -->
1071             <xsl:if test="@localinfo">
1072               <xsl:text>&amp;</xsl:text>
1073               <xsl:value-of select="$olink.fragid"/>
1074               <xsl:value-of select="@localinfo"/>
1075             </xsl:if>
1076           </xsl:otherwise>
1077         </xsl:choose>
1078       </xsl:variable>
1079     
1080       <xsl:choose>
1081         <xsl:when test="$href != ''">
1082           <a href="{$href}" class="olink">
1083             <xsl:call-template name="olink.hottext"/>
1084           </a>
1085         </xsl:when>
1086         <xsl:otherwise>
1087           <xsl:call-template name="olink.hottext"/>
1088         </xsl:otherwise>
1089       </xsl:choose>
1090     </xsl:otherwise>
1091   </xsl:choose>
1092 </xsl:template>
1093
1094 <xsl:template match="*" mode="pagenumber.markup">
1095   <!-- no-op in HTML -->
1096 </xsl:template>
1097
1098
1099 <xsl:template name="olink.outline">
1100   <xsl:param name="outline.base.uri"/>
1101   <xsl:param name="localinfo"/>
1102   <xsl:param name="return" select="href"/>
1103
1104   <xsl:variable name="outline-file" select="concat($outline.base.uri,                                $olink.outline.ext)"/>
1105
1106   <xsl:variable name="outline" select="document($outline-file,.)/div"/>
1107
1108   <xsl:variable name="node-href">
1109     <xsl:choose>
1110       <xsl:when test="$localinfo != ''">
1111         <xsl:variable name="node" select="$outline//*[@id=$localinfo]"/>
1112         <xsl:value-of select="$node/@href"/>
1113       </xsl:when>
1114       <xsl:otherwise>
1115         <xsl:value-of select="$outline/@href"/>
1116       </xsl:otherwise>
1117     </xsl:choose>
1118   </xsl:variable>
1119
1120   <xsl:variable name="node-xref">
1121     <xsl:choose>
1122       <xsl:when test="$localinfo != ''">
1123         <xsl:variable name="node" select="$outline//*[@id=$localinfo]"/>
1124         <xsl:copy-of select="$node/xref"/>
1125       </xsl:when>
1126       <xsl:otherwise>
1127         <xsl:value-of select="$outline/xref"/>
1128       </xsl:otherwise>
1129     </xsl:choose>
1130   </xsl:variable>
1131
1132   <xsl:choose>
1133     <xsl:when test="$return = 'href'">
1134       <xsl:value-of select="$node-href"/>
1135     </xsl:when>
1136     <xsl:when test="$return = 'xref'">
1137       <xsl:value-of select="$node-xref"/>
1138     </xsl:when>
1139     <xsl:otherwise>
1140       <xsl:copy-of select="$node-xref"/>
1141     </xsl:otherwise>
1142   </xsl:choose>
1143 </xsl:template>
1144
1145 <!-- ==================================================================== -->
1146
1147 <xsl:template name="xref.xreflabel">
1148   <!-- called to process an xreflabel...you might use this to make  -->
1149   <!-- xreflabels come out in the right font for different targets, -->
1150   <!-- for example. -->
1151   <xsl:param name="target" select="."/>
1152   <xsl:value-of select="$target/@xreflabel"/>
1153 </xsl:template>
1154
1155 <!-- ==================================================================== -->
1156
1157 <xsl:template match="title" mode="xref">
1158   <xsl:apply-templates/>
1159 </xsl:template>
1160
1161 <xsl:template match="command" mode="xref">
1162   <xsl:call-template name="inline.boldseq"/>
1163 </xsl:template>
1164
1165 <xsl:template match="function" mode="xref">
1166   <xsl:call-template name="inline.monoseq"/>
1167 </xsl:template>
1168
1169 <!-- ==================================================================== -->
1170
1171 <xsl:template match="*" mode="insert.title.markup">
1172   <xsl:param name="purpose"/>
1173   <xsl:param name="xrefstyle"/>
1174   <xsl:param name="title"/>
1175
1176   <xsl:choose>
1177     <!-- FIXME: what about the case where titleabbrev is inside the info? -->
1178     <xsl:when test="$purpose = 'xref' and titleabbrev">
1179       <xsl:apply-templates select="." mode="titleabbrev.markup"/>
1180     </xsl:when>
1181     <xsl:otherwise>
1182       <xsl:copy-of select="$title"/>
1183     </xsl:otherwise>
1184   </xsl:choose>
1185 </xsl:template>
1186
1187 <xsl:template match="chapter|appendix" mode="insert.title.markup">
1188   <xsl:param name="purpose"/>
1189   <xsl:param name="xrefstyle"/>
1190   <xsl:param name="title"/>
1191
1192   <xsl:choose>
1193     <xsl:when test="$purpose = 'xref'">
1194       <i>
1195         <xsl:copy-of select="$title"/>
1196       </i>
1197     </xsl:when>
1198     <xsl:otherwise>
1199       <xsl:copy-of select="$title"/>
1200     </xsl:otherwise>
1201   </xsl:choose>
1202 </xsl:template>
1203
1204 <xsl:template match="*" mode="insert.subtitle.markup">
1205   <xsl:param name="purpose"/>
1206   <xsl:param name="xrefstyle"/>
1207   <xsl:param name="subtitle"/>
1208
1209   <xsl:copy-of select="$subtitle"/>
1210 </xsl:template>
1211
1212 <xsl:template match="*" mode="insert.label.markup">
1213   <xsl:param name="purpose"/>
1214   <xsl:param name="xrefstyle"/>
1215   <xsl:param name="label"/>
1216
1217   <xsl:copy-of select="$label"/>
1218 </xsl:template>
1219
1220 <xsl:template match="*" mode="insert.pagenumber.markup">
1221   <xsl:param name="purpose"/>
1222   <xsl:param name="xrefstyle"/>
1223   <xsl:param name="pagenumber"/>
1224
1225   <xsl:copy-of select="$pagenumber"/>
1226 </xsl:template>
1227
1228 <xsl:template match="*" mode="insert.direction.markup">
1229   <xsl:param name="purpose"/>
1230   <xsl:param name="xrefstyle"/>
1231   <xsl:param name="direction"/>
1232
1233   <xsl:copy-of select="$direction"/>
1234 </xsl:template>
1235
1236 <xsl:template match="*" mode="insert.olink.docname.markup">
1237   <xsl:param name="purpose"/>
1238   <xsl:param name="xrefstyle"/>
1239   <xsl:param name="docname"/>
1240
1241   <span class="olinkdocname">
1242     <xsl:copy-of select="$docname"/>
1243   </span>
1244
1245 </xsl:template>
1246
1247 </xsl:stylesheet>