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 xmlns:xlink='http://www.w3.org/
1999/xlink'
6 exclude-result-prefixes=
"suwl exsl"
9 <!-- ********************************************************************
10 $Id: xref.xsl,v 1.1 2007/03/10 05:15:13 scott Exp $
11 ********************************************************************
13 This file is part of the XSL DocBook Stylesheet distribution.
14 See ../README or http://nwalsh.com/docbook/xsl/ for copyright
15 and other information.
17 ******************************************************************** -->
19 <!-- ==================================================================== -->
21 <xsl:template match=
"anchor">
22 <xsl:call-template name=
"anchor"/>
25 <!-- ==================================================================== -->
27 <xsl:template match=
"xref" name=
"xref">
28 <xsl:param name=
"xhref" select=
"@xlink:href"/>
29 <!-- is the @xlink:href a local idref link? -->
30 <xsl:param name=
"xlink.idref">
31 <xsl:if test=
"starts-with($xhref,'#')
32 and (not(contains($xhref,'('))
33 or starts-with($xhref, '#xpointer(id('))">
34 <xsl:call-template name=
"xpointer.idref">
35 <xsl:with-param name=
"xpointer" select=
"$xhref"/>
39 <xsl:param name=
"xlink.targets" select=
"key('id',$xlink.idref)"/>
40 <xsl:param name=
"linkend.targets" select=
"key('id',@linkend)"/>
41 <xsl:param name=
"target" select=
"($xlink.targets | $linkend.targets)[1]"/>
43 <xsl:variable name=
"xrefstyle">
45 <xsl:when test=
"@role and not(@xrefstyle)
46 and $use.role.as.xrefstyle != 0">
47 <xsl:value-of select=
"@role"/>
50 <xsl:value-of select=
"@xrefstyle"/>
55 <xsl:call-template name=
"anchor"/>
57 <xsl:variable name=
"content">
60 <xsl:when test=
"@endterm">
61 <xsl:variable name=
"etargets" select=
"key('id',@endterm)"/>
62 <xsl:variable name=
"etarget" select=
"$etargets[1]"/>
64 <xsl:when test=
"count($etarget) = 0">
66 <xsl:value-of select=
"count($etargets)"/>
67 <xsl:text>Endterm points to nonexistent ID:
</xsl:text>
68 <xsl:value-of select=
"@endterm"/>
70 <xsl:text>???
</xsl:text>
73 <xsl:apply-templates select=
"$etarget" mode=
"endterm"/>
78 <xsl:when test=
"$target/@xreflabel">
79 <xsl:call-template name=
"xref.xreflabel">
80 <xsl:with-param name=
"target" select=
"$target"/>
84 <xsl:when test=
"$target">
85 <xsl:if test=
"not(parent::citation)">
86 <xsl:apply-templates select=
"$target" mode=
"xref-to-prefix"/>
89 <xsl:apply-templates select=
"$target" mode=
"xref-to">
90 <xsl:with-param name=
"referrer" select=
"."/>
91 <xsl:with-param name=
"xrefstyle" select=
"$xrefstyle"/>
92 </xsl:apply-templates>
94 <xsl:if test=
"not(parent::citation)">
95 <xsl:apply-templates select=
"$target" mode=
"xref-to-suffix"/>
101 <xsl:text>ERROR: xref linking to
</xsl:text>
102 <xsl:value-of select=
"@linkend|@xlink:href"/>
103 <xsl:text> has no generated link text.
</xsl:text>
105 <xsl:text>???
</xsl:text>
110 <xsl:call-template name=
"simple.xlink">
111 <xsl:with-param name=
"content" select=
"$content"/>
116 <!-- ==================================================================== -->
118 <!-- biblioref handled largely like an xref -->
119 <!-- To be done: add support for begin, end, and units attributes -->
120 <xsl:template match=
"biblioref">
121 <xsl:variable name=
"targets" select=
"key('id',@linkend)"/>
122 <xsl:variable name=
"target" select=
"$targets[1]"/>
123 <xsl:variable name=
"refelem" select=
"local-name($target)"/>
125 <xsl:call-template name=
"check.id.unique">
126 <xsl:with-param name=
"linkend" select=
"@linkend"/>
129 <xsl:call-template name=
"anchor"/>
132 <xsl:when test=
"count($target) = 0">
134 <xsl:text>XRef to nonexistent id:
</xsl:text>
135 <xsl:value-of select=
"@linkend"/>
137 <xsl:text>???
</xsl:text>
140 <xsl:when test=
"@endterm">
141 <xsl:variable name=
"href">
142 <xsl:call-template name=
"href.target">
143 <xsl:with-param name=
"object" select=
"$target"/>
147 <xsl:variable name=
"etargets" select=
"key('id',@endterm)"/>
148 <xsl:variable name=
"etarget" select=
"$etargets[1]"/>
150 <xsl:when test=
"count($etarget) = 0">
152 <xsl:value-of select=
"count($etargets)"/>
153 <xsl:text>Endterm points to nonexistent ID:
</xsl:text>
154 <xsl:value-of select=
"@endterm"/>
157 <xsl:apply-templates select=
"." mode=
"class.attribute"/>
158 <xsl:text>???
</xsl:text>
163 <xsl:apply-templates select=
"." mode=
"class.attribute"/>
164 <xsl:apply-templates select=
"$etarget" mode=
"endterm"/>
170 <xsl:when test=
"$target/@xreflabel">
172 <xsl:apply-templates select=
"." mode=
"class.attribute"/>
173 <xsl:attribute name=
"href">
174 <xsl:call-template name=
"href.target">
175 <xsl:with-param name=
"object" select=
"$target"/>
178 <xsl:call-template name=
"xref.xreflabel">
179 <xsl:with-param name=
"target" select=
"$target"/>
185 <xsl:variable name=
"href">
186 <xsl:call-template name=
"href.target">
187 <xsl:with-param name=
"object" select=
"$target"/>
191 <xsl:if test=
"not(parent::citation)">
192 <xsl:apply-templates select=
"$target" mode=
"xref-to-prefix"/>
196 <xsl:apply-templates select=
"." mode=
"class.attribute"/>
197 <xsl:if test=
"$target/title or $target/*/title">
198 <xsl:attribute name=
"title">
199 <xsl:apply-templates select=
"$target" mode=
"xref-title"/>
202 <xsl:apply-templates select=
"$target" mode=
"xref-to">
203 <xsl:with-param name=
"referrer" select=
"."/>
204 <xsl:with-param name=
"xrefstyle">
206 <xsl:when test=
"@role and not(@xrefstyle) and $use.role.as.xrefstyle != 0">
207 <xsl:value-of select=
"@role"/>
210 <xsl:value-of select=
"@xrefstyle"/>
214 </xsl:apply-templates>
217 <xsl:if test=
"not(parent::citation)">
218 <xsl:apply-templates select=
"$target" mode=
"xref-to-suffix"/>
224 <!-- ==================================================================== -->
226 <xsl:template match=
"*" mode=
"endterm">
227 <!-- Process the children of the endterm element -->
228 <xsl:variable name=
"endterm">
229 <xsl:apply-templates select=
"child::node()"/>
233 <xsl:when test=
"function-available('exsl:node-set')">
234 <xsl:apply-templates select=
"exsl:node-set($endterm)" mode=
"remove-ids"/>
237 <xsl:copy-of select=
"$endterm"/>
242 <xsl:template match=
"*" mode=
"remove-ids">
244 <!-- handle html or xhtml -->
245 <xsl:when test=
"local-name(.) = 'a'
246 and (namespace-uri(.) = ''
247 or namespace-uri(.) = 'http://www.w3.org/1999/xhtml')">
249 <xsl:when test=
"(@name and count(@*) = 1)
250 or (@id and count(@*) = 1)
251 or (@xml:id and count(@*) = 1)
252 or (@xml:id and @name and count(@*) = 2)
253 or (@id and @name and count(@*) = 2)">
254 <xsl:message>suppress anchor
</xsl:message>
255 <!-- suppress the whole thing -->
259 <xsl:for-each select=
"@*">
261 <xsl:when test=
"local-name(.) != 'name' and local-name(.) != 'id'">
265 <xsl:message>removing
<xsl:value-of
266 select=
"local-name(.)"/></xsl:message>
271 <xsl:apply-templates mode=
"remove-ids"/>
277 <xsl:for-each select=
"@*">
279 <xsl:when test=
"local-name(.) != 'id'">
283 <xsl:message>removing
<xsl:value-of
284 select=
"local-name(.)"/></xsl:message>
288 <xsl:apply-templates mode=
"remove-ids"/>
294 <!-- ==================================================================== -->
296 <xsl:template match=
"*" mode=
"xref-to-prefix"/>
297 <xsl:template match=
"*" mode=
"xref-to-suffix"/>
299 <xsl:template match=
"*" mode=
"xref-to">
300 <xsl:param name=
"referrer"/>
301 <xsl:param name=
"xrefstyle"/>
302 <xsl:param name=
"verbose" select=
"1"/>
304 <xsl:if test=
"$verbose">
306 <xsl:text>Don't know what gentext to create for xref to:
"</xsl:text>
307 <xsl:value-of select="name(.)
"/>
308 <xsl:text>", (
"</xsl:text>
309 <xsl:value-of select="(@id|@xml:id)[
1]
"/>
310 <xsl:text>")
</xsl:text>
313 <xsl:text>???
</xsl:text>
316 <xsl:template match=
"title" mode=
"xref-to">
317 <xsl:param name=
"referrer"/>
318 <xsl:param name=
"xrefstyle"/>
319 <xsl:param name=
"verbose" select=
"1"/>
321 <!-- if you xref to a title, xref to the parent... -->
323 <!-- FIXME: how reliable is this? -->
324 <xsl:when test=
"contains(local-name(parent::*), 'info')">
325 <xsl:apply-templates select=
"parent::*[2]" mode=
"xref-to">
326 <xsl:with-param name=
"referrer" select=
"$referrer"/>
327 <xsl:with-param name=
"xrefstyle" select=
"$xrefstyle"/>
328 <xsl:with-param name=
"verbose" select=
"$verbose"/>
329 </xsl:apply-templates>
332 <xsl:apply-templates select=
"parent::*" mode=
"xref-to">
333 <xsl:with-param name=
"referrer" select=
"$referrer"/>
334 <xsl:with-param name=
"xrefstyle" select=
"$xrefstyle"/>
335 <xsl:with-param name=
"verbose" select=
"$verbose"/>
336 </xsl:apply-templates>
341 <xsl:template match=
"abstract|authorblurb|personblurb|bibliodiv|bibliomset
342 |biblioset|blockquote|calloutlist|caution|colophon
343 |constraintdef|formalpara|glossdiv|important|indexdiv
344 |itemizedlist|legalnotice|lot|msg|msgexplan|msgmain
345 |msgrel|msgset|msgsub|note|orderedlist|partintro
346 |productionset|qandadiv|refsynopsisdiv|segmentedlist
347 |set|setindex|sidebar|tip|toc|variablelist|warning"
349 <xsl:param name=
"referrer"/>
350 <xsl:param name=
"xrefstyle"/>
351 <xsl:param name=
"verbose" select=
"1"/>
353 <!-- catch-all for things with (possibly optional) titles -->
354 <xsl:apply-templates select=
"." mode=
"object.xref.markup">
355 <xsl:with-param name=
"purpose" select=
"'xref'"/>
356 <xsl:with-param name=
"xrefstyle" select=
"$xrefstyle"/>
357 <xsl:with-param name=
"referrer" select=
"$referrer"/>
358 <xsl:with-param name=
"verbose" select=
"$verbose"/>
359 </xsl:apply-templates>
362 <xsl:template match=
"author|editor|othercredit|personname" mode=
"xref-to">
363 <xsl:param name=
"referrer"/>
364 <xsl:param name=
"xrefstyle"/>
366 <xsl:call-template name=
"person.name"/>
369 <xsl:template match=
"authorgroup" mode=
"xref-to">
370 <xsl:param name=
"referrer"/>
371 <xsl:param name=
"xrefstyle"/>
373 <xsl:call-template name=
"person.name.list"/>
376 <xsl:template match=
"figure|example|table|equation" mode=
"xref-to">
377 <xsl:param name=
"referrer"/>
378 <xsl:param name=
"xrefstyle"/>
379 <xsl:param name=
"verbose" select=
"1"/>
381 <xsl:apply-templates select=
"." mode=
"object.xref.markup">
382 <xsl:with-param name=
"purpose" select=
"'xref'"/>
383 <xsl:with-param name=
"xrefstyle" select=
"$xrefstyle"/>
384 <xsl:with-param name=
"referrer" select=
"$referrer"/>
385 <xsl:with-param name=
"verbose" select=
"$verbose"/>
386 </xsl:apply-templates>
389 <xsl:template match=
"procedure" mode=
"xref-to">
390 <xsl:param name=
"referrer"/>
391 <xsl:param name=
"xrefstyle"/>
392 <xsl:param name=
"verbose"/>
394 <xsl:apply-templates select=
"." mode=
"object.xref.markup">
395 <xsl:with-param name=
"purpose" select=
"'xref'"/>
396 <xsl:with-param name=
"xrefstyle" select=
"$xrefstyle"/>
397 <xsl:with-param name=
"referrer" select=
"$referrer"/>
398 <xsl:with-param name=
"verbose" select=
"$verbose"/>
399 </xsl:apply-templates>
402 <xsl:template match=
"task" mode=
"xref-to">
403 <xsl:param name=
"referrer"/>
404 <xsl:param name=
"xrefstyle"/>
405 <xsl:param name=
"verbose"/>
407 <xsl:apply-templates select=
"." mode=
"object.xref.markup">
408 <xsl:with-param name=
"purpose" select=
"'xref'"/>
409 <xsl:with-param name=
"xrefstyle" select=
"$xrefstyle"/>
410 <xsl:with-param name=
"referrer" select=
"$referrer"/>
411 <xsl:with-param name=
"verbose" select=
"$verbose"/>
412 </xsl:apply-templates>
415 <xsl:template match=
"cmdsynopsis" mode=
"xref-to">
416 <xsl:apply-templates select=
"(.//command)[1]" mode=
"xref"/>
419 <xsl:template match=
"funcsynopsis" mode=
"xref-to">
420 <xsl:apply-templates select=
"(.//function)[1]" mode=
"xref"/>
423 <xsl:template match=
"dedication|preface|chapter|appendix|article" mode=
"xref-to">
424 <xsl:param name=
"referrer"/>
425 <xsl:param name=
"xrefstyle"/>
426 <xsl:param name=
"verbose" select=
"1"/>
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>
436 <xsl:template match=
"bibliography" mode=
"xref-to">
437 <xsl:param name=
"referrer"/>
438 <xsl:param name=
"xrefstyle"/>
439 <xsl:param name=
"verbose" select=
"1"/>
441 <xsl:apply-templates select=
"." mode=
"object.xref.markup">
442 <xsl:with-param name=
"purpose" select=
"'xref'"/>
443 <xsl:with-param name=
"xrefstyle" select=
"$xrefstyle"/>
444 <xsl:with-param name=
"referrer" select=
"$referrer"/>
445 <xsl:with-param name=
"verbose" select=
"$verbose"/>
446 </xsl:apply-templates>
449 <xsl:template match=
"biblioentry|bibliomixed" mode=
"xref-to-prefix">
450 <xsl:text>[
</xsl:text>
453 <xsl:template match=
"biblioentry|bibliomixed" mode=
"xref-to-suffix">
454 <xsl:text>]
</xsl:text>
457 <xsl:template match=
"biblioentry|bibliomixed" mode=
"xref-to">
458 <xsl:param name=
"referrer"/>
459 <xsl:param name=
"xrefstyle"/>
460 <xsl:param name=
"verbose" select=
"1"/>
462 <!-- handles both biblioentry and bibliomixed -->
464 <xsl:when test=
"string(.) = ''">
465 <xsl:variable name=
"bib" select=
"document($bibliography.collection,.)"/>
466 <xsl:variable name=
"id" select=
"(@id|@xml:id)[1]"/>
467 <xsl:variable name=
"entry" select=
"$bib/bibliography/
468 *[@id=$id or @xml:id=$id][1]"/>
470 <xsl:when test=
"$entry">
472 <xsl:when test=
"$bibliography.numbered != 0">
473 <xsl:number from=
"bibliography" count=
"biblioentry|bibliomixed"
474 level=
"any" format=
"1"/>
476 <xsl:when test=
"local-name($entry/*[1]) = 'abbrev'">
477 <xsl:apply-templates select=
"$entry/*[1]"/>
480 <xsl:value-of select=
"(@id|@xml:id)[1]"/>
486 <xsl:text>No bibliography entry:
</xsl:text>
487 <xsl:value-of select=
"$id"/>
488 <xsl:text> found in
</xsl:text>
489 <xsl:value-of select=
"$bibliography.collection"/>
491 <xsl:value-of select=
"(@id|@xml:id)[1]"/>
497 <xsl:when test=
"$bibliography.numbered != 0">
498 <xsl:number from=
"bibliography" count=
"biblioentry|bibliomixed"
499 level=
"any" format=
"1"/>
501 <xsl:when test=
"local-name(*[1]) = 'abbrev'">
502 <xsl:apply-templates select=
"*[1]"/>
505 <xsl:value-of select=
"(@id|@xml:id)[1]"/>
512 <xsl:template match=
"glossary" mode=
"xref-to">
513 <xsl:param name=
"referrer"/>
514 <xsl:param name=
"xrefstyle"/>
515 <xsl:param name=
"verbose" select=
"1"/>
517 <xsl:apply-templates select=
"." mode=
"object.xref.markup">
518 <xsl:with-param name=
"purpose" select=
"'xref'"/>
519 <xsl:with-param name=
"xrefstyle" select=
"$xrefstyle"/>
520 <xsl:with-param name=
"referrer" select=
"$referrer"/>
521 <xsl:with-param name=
"verbose" select=
"$verbose"/>
522 </xsl:apply-templates>
525 <xsl:template match=
"glossentry" mode=
"xref-to">
526 <xsl:param name=
"referrer"/>
527 <xsl:param name=
"xrefstyle"/>
528 <xsl:param name=
"verbose" select=
"1"/>
530 <xsl:when test=
"$glossentry.show.acronym = 'primary'">
532 <xsl:when test=
"acronym|abbrev">
533 <xsl:apply-templates select=
"(acronym|abbrev)[1]"/>
536 <xsl:apply-templates select=
"glossterm[1]" mode=
"xref-to">
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>
545 <xsl:apply-templates select=
"glossterm[1]" mode=
"xref-to">
546 <xsl:with-param name=
"xrefstyle" select=
"$xrefstyle"/>
547 <xsl:with-param name=
"referrer" select=
"$referrer"/>
548 <xsl:with-param name=
"verbose" select=
"$verbose"/>
549 </xsl:apply-templates>
554 <xsl:template match=
"glossterm" mode=
"xref-to">
555 <xsl:apply-templates/>
558 <xsl:template match=
"index" mode=
"xref-to">
559 <xsl:param name=
"referrer"/>
560 <xsl:param name=
"xrefstyle"/>
561 <xsl:param name=
"verbose" select=
"1"/>
563 <xsl:apply-templates select=
"." mode=
"object.xref.markup">
564 <xsl:with-param name=
"purpose" select=
"'xref'"/>
565 <xsl:with-param name=
"xrefstyle" select=
"$xrefstyle"/>
566 <xsl:with-param name=
"referrer" select=
"$referrer"/>
567 <xsl:with-param name=
"verbose" select=
"$verbose"/>
568 </xsl:apply-templates>
571 <xsl:template match=
"listitem" mode=
"xref-to">
572 <xsl:param name=
"referrer"/>
573 <xsl:param name=
"xrefstyle"/>
574 <xsl:param name=
"verbose"/>
576 <xsl:apply-templates select=
"." mode=
"object.xref.markup">
577 <xsl:with-param name=
"purpose" select=
"'xref'"/>
578 <xsl:with-param name=
"xrefstyle" select=
"$xrefstyle"/>
579 <xsl:with-param name=
"referrer" select=
"$referrer"/>
580 <xsl:with-param name=
"verbose" select=
"$verbose"/>
581 </xsl:apply-templates>
584 <xsl:template match=
"section|simplesect
585 |sect1|sect2|sect3|sect4|sect5
586 |refsect1|refsect2|refsect3|refsection" mode=
"xref-to">
587 <xsl:param name=
"referrer"/>
588 <xsl:param name=
"xrefstyle"/>
589 <xsl:param name=
"verbose" select=
"1"/>
591 <xsl:apply-templates select=
"." mode=
"object.xref.markup">
592 <xsl:with-param name=
"purpose" select=
"'xref'"/>
593 <xsl:with-param name=
"xrefstyle" select=
"$xrefstyle"/>
594 <xsl:with-param name=
"referrer" select=
"$referrer"/>
595 <xsl:with-param name=
"verbose" select=
"$verbose"/>
596 </xsl:apply-templates>
597 <!-- FIXME: What about "in Chapter X"? -->
600 <xsl:template match=
"bridgehead" mode=
"xref-to">
601 <xsl:param name=
"referrer"/>
602 <xsl:param name=
"xrefstyle"/>
603 <xsl:param name=
"verbose" select=
"1"/>
605 <xsl:apply-templates select=
"." mode=
"object.xref.markup">
606 <xsl:with-param name=
"purpose" select=
"'xref'"/>
607 <xsl:with-param name=
"xrefstyle" select=
"$xrefstyle"/>
608 <xsl:with-param name=
"referrer" select=
"$referrer"/>
609 <xsl:with-param name=
"verbose" select=
"$verbose"/>
610 </xsl:apply-templates>
611 <!-- FIXME: What about "in Chapter X"? -->
614 <xsl:template match=
"qandaset" mode=
"xref-to">
615 <xsl:param name=
"referrer"/>
616 <xsl:param name=
"xrefstyle"/>
617 <xsl:param name=
"verbose" select=
"1"/>
619 <xsl:apply-templates select=
"." mode=
"object.xref.markup">
620 <xsl:with-param name=
"purpose" select=
"'xref'"/>
621 <xsl:with-param name=
"xrefstyle" select=
"$xrefstyle"/>
622 <xsl:with-param name=
"referrer" select=
"$referrer"/>
623 <xsl:with-param name=
"verbose" select=
"$verbose"/>
624 </xsl:apply-templates>
627 <xsl:template match=
"qandadiv" mode=
"xref-to">
628 <xsl:param name=
"referrer"/>
629 <xsl:param name=
"xrefstyle"/>
630 <xsl:param name=
"verbose" select=
"1"/>
632 <xsl:apply-templates select=
"." mode=
"object.xref.markup">
633 <xsl:with-param name=
"purpose" select=
"'xref'"/>
634 <xsl:with-param name=
"xrefstyle" select=
"$xrefstyle"/>
635 <xsl:with-param name=
"referrer" select=
"$referrer"/>
636 <xsl:with-param name=
"verbose" select=
"$verbose"/>
637 </xsl:apply-templates>
640 <xsl:template match=
"qandaentry" mode=
"xref-to">
641 <xsl:param name=
"referrer"/>
642 <xsl:param name=
"xrefstyle"/>
643 <xsl:param name=
"verbose" select=
"1"/>
645 <xsl:apply-templates select=
"question[1]" mode=
"object.xref.markup">
646 <xsl:with-param name=
"purpose" select=
"'xref'"/>
647 <xsl:with-param name=
"xrefstyle" select=
"$xrefstyle"/>
648 <xsl:with-param name=
"referrer" select=
"$referrer"/>
649 <xsl:with-param name=
"verbose" select=
"$verbose"/>
650 </xsl:apply-templates>
653 <xsl:template match=
"question|answer" mode=
"xref-to">
654 <xsl:param name=
"referrer"/>
655 <xsl:param name=
"xrefstyle"/>
656 <xsl:param name=
"verbose" select=
"1"/>
658 <xsl:apply-templates select=
"." mode=
"object.xref.markup">
659 <xsl:with-param name=
"purpose" select=
"'xref'"/>
660 <xsl:with-param name=
"xrefstyle" select=
"$xrefstyle"/>
661 <xsl:with-param name=
"referrer" select=
"$referrer"/>
662 <xsl:with-param name=
"verbose" select=
"$verbose"/>
663 </xsl:apply-templates>
666 <xsl:template match=
"part|reference" mode=
"xref-to">
667 <xsl:param name=
"referrer"/>
668 <xsl:param name=
"xrefstyle"/>
669 <xsl:param name=
"verbose" select=
"1"/>
671 <xsl:apply-templates select=
"." mode=
"object.xref.markup">
672 <xsl:with-param name=
"purpose" select=
"'xref'"/>
673 <xsl:with-param name=
"xrefstyle" select=
"$xrefstyle"/>
674 <xsl:with-param name=
"referrer" select=
"$referrer"/>
675 <xsl:with-param name=
"verbose" select=
"$verbose"/>
676 </xsl:apply-templates>
679 <xsl:template match=
"refentry" mode=
"xref-to">
680 <xsl:param name=
"referrer"/>
681 <xsl:param name=
"xrefstyle"/>
684 <xsl:when test=
"refmeta/refentrytitle">
685 <xsl:apply-templates select=
"refmeta/refentrytitle"/>
688 <xsl:apply-templates select=
"refnamediv/refname[1]"/>
691 <xsl:apply-templates select=
"refmeta/manvolnum"/>
694 <xsl:template match=
"refnamediv" mode=
"xref-to">
695 <xsl:param name=
"referrer"/>
696 <xsl:param name=
"xrefstyle"/>
697 <xsl:param name=
"verbose" select=
"1"/>
699 <xsl:apply-templates select=
"refname[1]" mode=
"xref-to">
700 <xsl:with-param name=
"xrefstyle" select=
"$xrefstyle"/>
701 <xsl:with-param name=
"referrer" select=
"$referrer"/>
702 <xsl:with-param name=
"verbose" select=
"$verbose"/>
703 </xsl:apply-templates>
706 <xsl:template match=
"refname" mode=
"xref-to">
707 <xsl:param name=
"referrer"/>
708 <xsl:param name=
"xrefstyle"/>
709 <xsl:param name=
"verbose" select=
"1"/>
711 <xsl:apply-templates mode=
"xref-to"/>
714 <xsl:template match=
"step" mode=
"xref-to">
715 <xsl:param name=
"referrer"/>
716 <xsl:param name=
"xrefstyle"/>
718 <xsl:call-template name=
"gentext">
719 <xsl:with-param name=
"key" select=
"'Step'"/>
721 <xsl:text> </xsl:text>
722 <xsl:apply-templates select=
"." mode=
"number"/>
725 <xsl:template match=
"varlistentry" mode=
"xref-to">
726 <xsl:param name=
"referrer"/>
727 <xsl:param name=
"xrefstyle"/>
728 <xsl:param name=
"verbose" select=
"1"/>
730 <xsl:apply-templates select=
"term[1]" mode=
"xref-to">
731 <xsl:with-param name=
"xrefstyle" select=
"$xrefstyle"/>
732 <xsl:with-param name=
"referrer" select=
"$referrer"/>
733 <xsl:with-param name=
"verbose" select=
"$verbose"/>
734 </xsl:apply-templates>
737 <xsl:template match=
"varlistentry/term" mode=
"xref-to">
738 <xsl:param name=
"referrer"/>
739 <xsl:param name=
"xrefstyle"/>
741 <!-- to avoid the comma that will be generated if there are several terms -->
742 <xsl:apply-templates/>
745 <xsl:template match=
"co" mode=
"xref-to">
746 <xsl:param name=
"referrer"/>
747 <xsl:param name=
"xrefstyle"/>
749 <xsl:apply-templates select=
"." mode=
"callout-bug"/>
752 <!-- This is currently not working, because there is no corresponding ID generated by Java extensions for processing callouts
753 <xsl:template match="area|areaset" mode="xref-to">
754 <xsl:param name="referrer"/>
755 <xsl:param name="xrefstyle"/>
757 <xsl:call-template name="callout-bug">
758 <xsl:with-param name="conum">
759 <xsl:apply-templates select="." mode="conumber"/>
765 <xsl:template match=
"book" mode=
"xref-to">
766 <xsl:param name=
"referrer"/>
767 <xsl:param name=
"xrefstyle"/>
768 <xsl:param name=
"verbose" select=
"1"/>
770 <xsl:apply-templates select=
"." mode=
"object.xref.markup">
771 <xsl:with-param name=
"purpose" select=
"'xref'"/>
772 <xsl:with-param name=
"xrefstyle" select=
"$xrefstyle"/>
773 <xsl:with-param name=
"referrer" select=
"$referrer"/>
774 <xsl:with-param name=
"verbose" select=
"$verbose"/>
775 </xsl:apply-templates>
778 <xsl:template match=
"para" mode=
"xref-to">
779 <xsl:param name=
"referrer"/>
780 <xsl:param name=
"xrefstyle"/>
781 <xsl:param name=
"verbose" select=
"1"/>
783 <xsl:variable name=
"context" select=
"(ancestor::simplesect
790 |ancestor::refsection
798 |ancestor::dedication
800 |ancestor::bibliography
803 |ancestor::glossentry
805 |ancestor::varlistentry)[last()]"/>
807 <xsl:apply-templates select=
"$context" mode=
"xref-to">
808 <xsl:with-param name=
"purpose" select=
"'xref'"/>
809 <xsl:with-param name=
"xrefstyle" select=
"$xrefstyle"/>
810 <xsl:with-param name=
"referrer" select=
"$referrer"/>
811 <xsl:with-param name=
"verbose" select=
"$verbose"/>
812 </xsl:apply-templates>
815 <!-- ==================================================================== -->
817 <xsl:template match=
"*" mode=
"xref-title">
818 <xsl:variable name=
"title">
819 <xsl:apply-templates select=
"." mode=
"object.title.markup"/>
822 <xsl:value-of select=
"$title"/>
825 <xsl:template match=
"author" mode=
"xref-title">
826 <xsl:variable name=
"title">
827 <xsl:call-template name=
"person.name"/>
830 <xsl:value-of select=
"$title"/>
833 <xsl:template match=
"authorgroup" mode=
"xref-title">
834 <xsl:variable name=
"title">
835 <xsl:call-template name=
"person.name.list"/>
838 <xsl:value-of select=
"$title"/>
841 <xsl:template match=
"cmdsynopsis" mode=
"xref-title">
842 <xsl:variable name=
"title">
843 <xsl:apply-templates select=
"(.//command)[1]" mode=
"xref"/>
846 <xsl:value-of select=
"$title"/>
849 <xsl:template match=
"funcsynopsis" mode=
"xref-title">
850 <xsl:variable name=
"title">
851 <xsl:apply-templates select=
"(.//function)[1]" mode=
"xref"/>
854 <xsl:value-of select=
"$title"/>
857 <xsl:template match=
"biblioentry|bibliomixed" mode=
"xref-title">
858 <!-- handles both biblioentry and bibliomixed -->
859 <xsl:variable name=
"title">
860 <xsl:text>[
</xsl:text>
862 <xsl:when test=
"local-name(*[1]) = 'abbrev'">
863 <xsl:apply-templates select=
"*[1]"/>
866 <xsl:value-of select=
"(@id|@xml:id)[1]"/>
869 <xsl:text>]
</xsl:text>
872 <xsl:value-of select=
"$title"/>
875 <xsl:template match=
"step" mode=
"xref-title">
876 <xsl:call-template name=
"gentext">
877 <xsl:with-param name=
"key" select=
"'Step'"/>
879 <xsl:text> </xsl:text>
880 <xsl:apply-templates select=
"." mode=
"number"/>
883 <xsl:template match=
"co" mode=
"xref-title">
884 <xsl:variable name=
"title">
885 <xsl:apply-templates select=
"." mode=
"callout-bug"/>
888 <xsl:value-of select=
"$title"/>
891 <!-- ==================================================================== -->
893 <xsl:template match=
"link" name=
"link">
894 <xsl:param name=
"linkend" select=
"@linkend"/>
895 <xsl:param name=
"a.target"/>
897 <xsl:variable name=
"content">
898 <xsl:call-template name=
"anchor"/>
900 <xsl:when test=
"count(child::node()) > 0">
901 <!-- If it has content, use it -->
902 <xsl:apply-templates/>
904 <!-- else look for an endterm -->
905 <xsl:when test=
"@endterm">
906 <xsl:variable name=
"etargets" select=
"key('id',@endterm)"/>
907 <xsl:variable name=
"etarget" select=
"$etargets[1]"/>
909 <xsl:when test=
"count($etarget) = 0">
911 <xsl:value-of select=
"count($etargets)"/>
912 <xsl:text>Endterm points to nonexistent ID:
</xsl:text>
913 <xsl:value-of select=
"@endterm"/>
915 <xsl:text>???
</xsl:text>
918 <xsl:apply-templates select=
"$etarget" mode=
"endterm"/>
922 <!-- Use the xlink:href if no other text -->
923 <xsl:when test=
"@xlink:href">
924 <xsl:value-of select=
"@xlink:href"/>
928 <xsl:text>Link element has no content and no Endterm.
</xsl:text>
929 <xsl:text>Nothing to show in the link to
</xsl:text>
930 <xsl:value-of select=
"(@xlink:href|@linkend)[1]"/>
932 <xsl:text>???
</xsl:text>
937 <xsl:call-template name=
"simple.xlink">
938 <xsl:with-param name=
"node" select=
"."/>
939 <xsl:with-param name=
"linkend" select=
"$linkend"/>
940 <xsl:with-param name=
"content" select=
"$content"/>
941 <xsl:with-param name=
"a.target" select=
"$a.target"/>
946 <xsl:template match=
"ulink" name=
"ulink">
947 <xsl:param name=
"url" select=
"@url"/>
948 <xsl:variable name=
"link">
950 <xsl:apply-templates select=
"." mode=
"class.attribute"/>
951 <xsl:if test=
"@id or @xml:id">
952 <xsl:attribute name=
"name">
953 <xsl:value-of select=
"(@id|@xml:id)[1]"/>
956 <xsl:attribute name=
"href"><xsl:value-of select=
"$url"/></xsl:attribute>
957 <xsl:if test=
"$ulink.target != ''">
958 <xsl:attribute name=
"target">
959 <xsl:value-of select=
"$ulink.target"/>
963 <xsl:when test=
"count(child::node())=0">
964 <xsl:value-of select=
"$url"/>
967 <xsl:apply-templates/>
974 <xsl:when test=
"function-available('suwl:unwrapLinks')">
975 <xsl:copy-of select=
"suwl:unwrapLinks($link)"/>
978 <xsl:copy-of select=
"$link"/>
983 <xsl:template match=
"olink" name=
"olink">
985 <xsl:call-template name=
"anchor"/>
987 <xsl:variable name=
"localinfo" select=
"@localinfo"/>
990 <!-- olinks resolved by stylesheet and target database -->
991 <xsl:when test=
"@targetdoc or @targetptr" >
992 <xsl:variable name=
"targetdoc.att" select=
"@targetdoc"/>
993 <xsl:variable name=
"targetptr.att" select=
"@targetptr"/>
995 <xsl:variable name=
"olink.lang">
996 <xsl:call-template name=
"l10n.language">
997 <xsl:with-param name=
"xref-context" select=
"true()"/>
1001 <xsl:variable name=
"target.database.filename">
1002 <xsl:call-template name=
"select.target.database">
1003 <xsl:with-param name=
"targetdoc.att" select=
"$targetdoc.att"/>
1004 <xsl:with-param name=
"targetptr.att" select=
"$targetptr.att"/>
1005 <xsl:with-param name=
"olink.lang" select=
"$olink.lang"/>
1006 </xsl:call-template>
1009 <xsl:variable name=
"target.database"
1010 select=
"document($target.database.filename,/)"/>
1012 <xsl:if test=
"$olink.debug != 0">
1014 <xsl:text>Olink debug: root element of target.database '
</xsl:text>
1015 <xsl:value-of select=
"$target.database.filename"/>
1016 <xsl:text>' is '
</xsl:text>
1017 <xsl:value-of select=
"local-name($target.database/*[1])"/>
1018 <xsl:text>'.
</xsl:text>
1022 <xsl:variable name=
"olink.key">
1023 <xsl:call-template name=
"select.olink.key">
1024 <xsl:with-param name=
"targetdoc.att" select=
"$targetdoc.att"/>
1025 <xsl:with-param name=
"targetptr.att" select=
"$targetptr.att"/>
1026 <xsl:with-param name=
"olink.lang" select=
"$olink.lang"/>
1027 <xsl:with-param name=
"target.database" select=
"$target.database"/>
1028 </xsl:call-template>
1031 <xsl:if test=
"string-length($olink.key) = 0">
1033 <xsl:text>Error: unresolved olink:
</xsl:text>
1034 <xsl:text>targetdoc/targetptr = '
</xsl:text>
1035 <xsl:value-of select=
"$targetdoc.att"/>
1036 <xsl:text>/
</xsl:text>
1037 <xsl:value-of select=
"$targetptr.att"/>
1038 <xsl:text>'.
</xsl:text>
1042 <xsl:variable name=
"href">
1043 <xsl:call-template name=
"make.olink.href">
1044 <xsl:with-param name=
"olink.key" select=
"$olink.key"/>
1045 <xsl:with-param name=
"target.database" select=
"$target.database"/>
1046 </xsl:call-template>
1049 <xsl:variable name=
"hottext">
1050 <xsl:call-template name=
"olink.hottext">
1051 <xsl:with-param name=
"target.database" select=
"$target.database"/>
1052 <xsl:with-param name=
"olink.key" select=
"$olink.key"/>
1053 <xsl:with-param name=
"olink.lang" select=
"$olink.lang"/>
1054 </xsl:call-template>
1057 <xsl:variable name=
"olink.docname.citation">
1058 <xsl:call-template name=
"olink.document.citation">
1059 <xsl:with-param name=
"olink.key" select=
"$olink.key"/>
1060 <xsl:with-param name=
"target.database" select=
"$target.database"/>
1061 <xsl:with-param name=
"olink.lang" select=
"$olink.lang"/>
1062 </xsl:call-template>
1065 <xsl:variable name=
"olink.page.citation">
1066 <xsl:call-template name=
"olink.page.citation">
1067 <xsl:with-param name=
"olink.key" select=
"$olink.key"/>
1068 <xsl:with-param name=
"target.database" select=
"$target.database"/>
1069 <xsl:with-param name=
"olink.lang" select=
"$olink.lang"/>
1070 </xsl:call-template>
1074 <xsl:when test=
"$href != ''">
1076 <xsl:apply-templates select=
"." mode=
"class.attribute"/>
1077 <xsl:copy-of select=
"$hottext"/>
1079 <xsl:copy-of select=
"$olink.page.citation"/>
1080 <xsl:copy-of select=
"$olink.docname.citation"/>
1083 <span class=
"olink"><xsl:copy-of select=
"$hottext"/></span>
1084 <xsl:copy-of select=
"$olink.page.citation"/>
1085 <xsl:copy-of select=
"$olink.docname.citation"/>
1091 <!-- Or use old olink mechanism -->
1093 <xsl:variable name=
"href">
1095 <xsl:when test=
"@linkmode">
1096 <!-- use the linkmode to get the base URI, use localinfo as fragid -->
1097 <xsl:variable name=
"modespec" select=
"key('id',@linkmode)"/>
1098 <xsl:if test=
"count($modespec) != 1
1099 or local-name($modespec) != 'modespec'">
1100 <xsl:message>Warning: olink linkmode pointer is wrong.
</xsl:message>
1102 <xsl:value-of select=
"$modespec"/>
1103 <xsl:if test=
"@localinfo">
1104 <xsl:text>#
</xsl:text>
1105 <xsl:value-of select=
"@localinfo"/>
1108 <xsl:when test=
"@type = 'href'">
1109 <xsl:call-template name=
"olink.outline">
1110 <xsl:with-param name=
"outline.base.uri"
1111 select=
"unparsed-entity-uri(@targetdocent)"/>
1112 <xsl:with-param name=
"localinfo" select=
"@localinfo"/>
1113 <xsl:with-param name=
"return" select=
"'href'"/>
1114 </xsl:call-template>
1117 <xsl:value-of select=
"$olink.resolver"/>
1118 <xsl:text>?
</xsl:text>
1119 <xsl:value-of select=
"$olink.sysid"/>
1120 <xsl:value-of select=
"unparsed-entity-uri(@targetdocent)"/>
1121 <!-- XSL gives no access to the public identifier (grumble...) -->
1122 <xsl:if test=
"@localinfo">
1123 <xsl:text>&</xsl:text>
1124 <xsl:value-of select=
"$olink.fragid"/>
1125 <xsl:value-of select=
"@localinfo"/>
1132 <xsl:when test=
"$href != ''">
1134 <xsl:apply-templates select=
"." mode=
"class.attribute"/>
1135 <xsl:call-template name=
"olink.hottext"/>
1139 <xsl:call-template name=
"olink.hottext"/>
1146 <xsl:template match=
"*" mode=
"pagenumber.markup">
1147 <!-- no-op in HTML -->
1151 <xsl:template name=
"olink.outline">
1152 <xsl:param name=
"outline.base.uri"/>
1153 <xsl:param name=
"localinfo"/>
1154 <xsl:param name=
"return" select=
"href"/>
1156 <xsl:variable name=
"outline-file"
1157 select=
"concat($outline.base.uri,
1158 $olink.outline.ext)"/>
1160 <xsl:variable name=
"outline" select=
"document($outline-file,.)/div"/>
1162 <xsl:variable name=
"node-href">
1164 <xsl:when test=
"$localinfo != ''">
1165 <xsl:variable name=
"node" select=
"$outline//
1166 *[@id=$localinfo or @xml:id=$localinfo]"/>
1167 <xsl:value-of select=
"$node/@href"/>
1170 <xsl:value-of select=
"$outline/@href"/>
1175 <xsl:variable name=
"node-xref">
1177 <xsl:when test=
"$localinfo != ''">
1178 <xsl:variable name=
"node" select=
"$outline//
1179 *[@id=$localinfo or @xml:id=$localinfo]"/>
1180 <xsl:copy-of select=
"$node/xref"/>
1183 <xsl:value-of select=
"$outline/xref"/>
1189 <xsl:when test=
"$return = 'href'">
1190 <xsl:value-of select=
"$node-href"/>
1192 <xsl:when test=
"$return = 'xref'">
1193 <xsl:value-of select=
"$node-xref"/>
1196 <xsl:copy-of select=
"$node-xref"/>
1201 <!-- ==================================================================== -->
1203 <xsl:template name=
"xref.xreflabel">
1204 <!-- called to process an xreflabel...you might use this to make -->
1205 <!-- xreflabels come out in the right font for different targets, -->
1206 <!-- for example. -->
1207 <xsl:param name=
"target" select=
"."/>
1208 <xsl:value-of select=
"$target/@xreflabel"/>
1211 <!-- ==================================================================== -->
1213 <xsl:template match=
"title" mode=
"xref">
1214 <xsl:apply-templates/>
1217 <xsl:template match=
"command" mode=
"xref">
1218 <xsl:call-template name=
"inline.boldseq"/>
1221 <xsl:template match=
"function" mode=
"xref">
1222 <xsl:call-template name=
"inline.monoseq"/>
1225 <!-- ==================================================================== -->
1227 <xsl:template match=
"*" mode=
"insert.title.markup">
1228 <xsl:param name=
"purpose"/>
1229 <xsl:param name=
"xrefstyle"/>
1230 <xsl:param name=
"title"/>
1233 <!-- FIXME: what about the case where titleabbrev is inside the info? -->
1234 <xsl:when test=
"$purpose = 'xref' and titleabbrev">
1235 <xsl:apply-templates select=
"." mode=
"titleabbrev.markup"/>
1238 <xsl:copy-of select=
"$title"/>
1243 <xsl:template match=
"chapter|appendix" mode=
"insert.title.markup">
1244 <xsl:param name=
"purpose"/>
1245 <xsl:param name=
"xrefstyle"/>
1246 <xsl:param name=
"title"/>
1249 <xsl:when test=
"$purpose = 'xref'">
1251 <xsl:copy-of select=
"$title"/>
1255 <xsl:copy-of select=
"$title"/>
1260 <xsl:template match=
"*" mode=
"insert.subtitle.markup">
1261 <xsl:param name=
"purpose"/>
1262 <xsl:param name=
"xrefstyle"/>
1263 <xsl:param name=
"subtitle"/>
1265 <xsl:copy-of select=
"$subtitle"/>
1268 <xsl:template match=
"*" mode=
"insert.label.markup">
1269 <xsl:param name=
"purpose"/>
1270 <xsl:param name=
"xrefstyle"/>
1271 <xsl:param name=
"label"/>
1273 <xsl:copy-of select=
"$label"/>
1276 <xsl:template match=
"*" mode=
"insert.pagenumber.markup">
1277 <xsl:param name=
"purpose"/>
1278 <xsl:param name=
"xrefstyle"/>
1279 <xsl:param name=
"pagenumber"/>
1281 <xsl:copy-of select=
"$pagenumber"/>
1284 <xsl:template match=
"*" mode=
"insert.direction.markup">
1285 <xsl:param name=
"purpose"/>
1286 <xsl:param name=
"xrefstyle"/>
1287 <xsl:param name=
"direction"/>
1289 <xsl:copy-of select=
"$direction"/>
1292 <xsl:template match=
"*" mode=
"insert.olink.docname.markup">
1293 <xsl:param name=
"purpose"/>
1294 <xsl:param name=
"xrefstyle"/>
1295 <xsl:param name=
"docname"/>
1297 <span class=
"olinkdocname">
1298 <xsl:copy-of select=
"$docname"/>