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