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