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 xlink"
9 <!-- ********************************************************************
10 $Id: xref.xsl 8421 2009-05-04 07:49:49Z bobstayton $
11 ********************************************************************
13 This file is part of the XSL DocBook Stylesheet distribution.
14 See ../README or http://docbook.sf.net/release/xsl/current/ for
15 copyright and other information.
17 ******************************************************************** -->
19 <!-- Use internal variable for olink xlink role for consistency -->
21 name="xolink.role">http://docbook.org/xlink/role/olink</xsl:variable>
23 <!-- ==================================================================== -->
25 <xsl:template match="anchor">
26 <xsl:call-template name="anchor"/>
29 <!-- ==================================================================== -->
31 <xsl:template match="xref" name="xref">
32 <xsl:param name="xhref" select="@xlink:href"/>
33 <!-- is the @xlink:href a local idref link? -->
34 <xsl:param name="xlink.idref">
35 <xsl:if test="starts-with($xhref,'#')
36 and (not(contains($xhref,'('))
37 or starts-with($xhref, '#xpointer(id('))">
38 <xsl:call-template name="xpointer.idref">
39 <xsl:with-param name="xpointer" select="$xhref"/>
43 <xsl:param name="xlink.targets" select="key('id',$xlink.idref)"/>
44 <xsl:param name="linkend.targets" select="key('id',@linkend)"/>
45 <xsl:param name="target" select="($xlink.targets | $linkend.targets)[1]"/>
47 <xsl:variable name="xrefstyle">
49 <xsl:when test="@role and not(@xrefstyle)
50 and $use.role.as.xrefstyle != 0">
51 <xsl:value-of select="@role"/>
54 <xsl:value-of select="@xrefstyle"/>
59 <xsl:call-template name="anchor"/>
61 <xsl:variable name="content">
64 <xsl:when test="@endterm">
65 <xsl:variable name="etargets" select="key('id',@endterm)"/>
66 <xsl:variable name="etarget" select="$etargets[1]"/>
68 <xsl:when test="count($etarget) = 0">
70 <xsl:value-of select="count($etargets)"/>
71 <xsl:text>Endterm points to nonexistent ID: </xsl:text>
72 <xsl:value-of select="@endterm"/>
74 <xsl:text>???</xsl:text>
77 <xsl:apply-templates select="$etarget" mode="endterm"/>
82 <xsl:when test="$target/@xreflabel">
83 <xsl:call-template name="xref.xreflabel">
84 <xsl:with-param name="target" select="$target"/>
88 <xsl:when test="$target">
89 <xsl:if test="not(parent::citation)">
90 <xsl:apply-templates select="$target" mode="xref-to-prefix"/>
93 <xsl:apply-templates select="$target" mode="xref-to">
94 <xsl:with-param name="referrer" select="."/>
95 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
96 </xsl:apply-templates>
98 <xsl:if test="not(parent::citation)">
99 <xsl:apply-templates select="$target" mode="xref-to-suffix"/>
105 <xsl:text>ERROR: xref linking to </xsl:text>
106 <xsl:value-of select="@linkend|@xlink:href"/>
107 <xsl:text> has no generated link text.</xsl:text>
109 <xsl:text>???</xsl:text>
114 <xsl:call-template name="simple.xlink">
115 <xsl:with-param name="content" select="$content"/>
120 <!-- ==================================================================== -->
122 <!-- biblioref handled largely like an xref -->
123 <!-- To be done: add support for begin, end, and units attributes -->
124 <xsl:template match="biblioref">
125 <xsl:variable name="targets" select="key('id',@linkend)"/>
126 <xsl:variable name="target" select="$targets[1]"/>
127 <xsl:variable name="refelem" select="local-name($target)"/>
129 <xsl:call-template name="check.id.unique">
130 <xsl:with-param name="linkend" select="@linkend"/>
133 <xsl:call-template name="anchor"/>
136 <xsl:when test="count($target) = 0">
138 <xsl:text>XRef to nonexistent id: </xsl:text>
139 <xsl:value-of select="@linkend"/>
141 <xsl:text>???</xsl:text>
144 <xsl:when test="@endterm">
145 <xsl:variable name="href">
146 <xsl:call-template name="href.target">
147 <xsl:with-param name="object" select="$target"/>
151 <xsl:variable name="etargets" select="key('id',@endterm)"/>
152 <xsl:variable name="etarget" select="$etargets[1]"/>
154 <xsl:when test="count($etarget) = 0">
156 <xsl:value-of select="count($etargets)"/>
157 <xsl:text>Endterm points to nonexistent ID: </xsl:text>
158 <xsl:value-of select="@endterm"/>
161 <xsl:apply-templates select="." mode="common.html.attributes"/>
162 <xsl:text>???</xsl:text>
167 <xsl:apply-templates select="." mode="common.html.attributes"/>
168 <xsl:apply-templates select="$etarget" mode="endterm"/>
174 <xsl:when test="$target/@xreflabel">
176 <xsl:apply-templates select="." mode="common.html.attributes"/>
177 <xsl:attribute name="href">
178 <xsl:call-template name="href.target">
179 <xsl:with-param name="object" select="$target"/>
182 <xsl:call-template name="xref.xreflabel">
183 <xsl:with-param name="target" select="$target"/>
189 <xsl:variable name="href">
190 <xsl:call-template name="href.target">
191 <xsl:with-param name="object" select="$target"/>
195 <xsl:if test="not(parent::citation)">
196 <xsl:apply-templates select="$target" mode="xref-to-prefix"/>
200 <xsl:apply-templates select="." mode="class.attribute"/>
201 <xsl:if test="$target/title or $target/*/title">
202 <xsl:attribute name="title">
203 <xsl:apply-templates select="$target" mode="xref-title"/>
206 <xsl:apply-templates select="$target" mode="xref-to">
207 <xsl:with-param name="referrer" select="."/>
208 <xsl:with-param name="xrefstyle">
210 <xsl:when test="@role and not(@xrefstyle) and $use.role.as.xrefstyle != 0">
211 <xsl:value-of select="@role"/>
214 <xsl:value-of select="@xrefstyle"/>
218 </xsl:apply-templates>
221 <xsl:if test="not(parent::citation)">
222 <xsl:apply-templates select="$target" mode="xref-to-suffix"/>
228 <!-- ==================================================================== -->
230 <xsl:template match="*" mode="endterm">
231 <!-- Process the children of the endterm element -->
232 <xsl:variable name="endterm">
233 <xsl:apply-templates select="child::node()"/>
237 <xsl:when test="$exsl.node.set.available != 0">
238 <xsl:apply-templates select="exsl:node-set($endterm)" mode="remove-ids"/>
241 <xsl:copy-of select="$endterm"/>
246 <xsl:template match="*" mode="remove-ids">
248 <!-- handle html or xhtml -->
249 <xsl:when test="local-name(.) = 'a'
250 and (namespace-uri(.) = ''
251 or namespace-uri(.) = 'http://www.w3.org/1999/xhtml')">
253 <xsl:when test="(@name and count(@*) = 1)
254 or (@id and count(@*) = 1)
255 or (@xml:id and count(@*) = 1)
256 or (@xml:id and @name and count(@*) = 2)
257 or (@id and @name and count(@*) = 2)">
258 <xsl:message>suppress anchor</xsl:message>
259 <!-- suppress the whole thing -->
263 <xsl:for-each select="@*">
265 <xsl:when test="local-name(.) != 'name' and local-name(.) != 'id'">
269 <xsl:message>removing <xsl:value-of
270 select="local-name(.)"/></xsl:message>
275 <xsl:apply-templates mode="remove-ids"/>
281 <xsl:for-each select="@*">
283 <xsl:when test="local-name(.) != 'id'">
287 <xsl:message>removing <xsl:value-of
288 select="local-name(.)"/></xsl:message>
292 <xsl:apply-templates mode="remove-ids"/>
298 <!-- ==================================================================== -->
300 <xsl:template match="*" mode="xref-to-prefix"/>
301 <xsl:template match="*" mode="xref-to-suffix"/>
303 <xsl:template match="*" mode="xref-to">
304 <xsl:param name="referrer"/>
305 <xsl:param name="xrefstyle"/>
306 <xsl:param name="verbose" select="1"/>
308 <xsl:if test="$verbose">
310 <xsl:text>Don't know what gentext to create for xref to: "</xsl:text>
311 <xsl:value-of select="name(.)"/>
312 <xsl:text>", ("</xsl:text>
313 <xsl:value-of select="(@id|@xml:id)[1]"/>
314 <xsl:text>")</xsl:text>
317 <xsl:text>???</xsl:text>
320 <xsl:template match="title" mode="xref-to">
321 <xsl:param name="referrer"/>
322 <xsl:param name="xrefstyle"/>
323 <xsl:param name="verbose" select="1"/>
325 <!-- if you xref to a title, xref to the parent... -->
327 <!-- FIXME: how reliable is this? -->
328 <xsl:when test="contains(local-name(parent::*), 'info')">
329 <xsl:apply-templates select="parent::*[2]" mode="xref-to">
330 <xsl:with-param name="referrer" select="$referrer"/>
331 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
332 <xsl:with-param name="verbose" select="$verbose"/>
333 </xsl:apply-templates>
336 <xsl:apply-templates select="parent::*" mode="xref-to">
337 <xsl:with-param name="referrer" select="$referrer"/>
338 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
339 <xsl:with-param name="verbose" select="$verbose"/>
340 </xsl:apply-templates>
345 <xsl:template match="abstract|authorblurb|personblurb|bibliodiv|bibliomset
346 |biblioset|blockquote|calloutlist|caution|colophon
347 |constraintdef|formalpara|glossdiv|important|indexdiv
348 |itemizedlist|legalnotice|lot|msg|msgexplan|msgmain
349 |msgrel|msgset|msgsub|note|orderedlist|partintro
350 |productionset|qandadiv|refsynopsisdiv|segmentedlist
351 |set|setindex|sidebar|tip|toc|variablelist|warning"
353 <xsl:param name="referrer"/>
354 <xsl:param name="xrefstyle"/>
355 <xsl:param name="verbose" select="1"/>
357 <!-- catch-all for things with (possibly optional) titles -->
358 <xsl:apply-templates select="." mode="object.xref.markup">
359 <xsl:with-param name="purpose" select="'xref'"/>
360 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
361 <xsl:with-param name="referrer" select="$referrer"/>
362 <xsl:with-param name="verbose" select="$verbose"/>
363 </xsl:apply-templates>
366 <xsl:template match="author|editor|othercredit|personname" mode="xref-to">
367 <xsl:param name="referrer"/>
368 <xsl:param name="xrefstyle"/>
370 <xsl:call-template name="person.name"/>
373 <xsl:template match="authorgroup" mode="xref-to">
374 <xsl:param name="referrer"/>
375 <xsl:param name="xrefstyle"/>
377 <xsl:call-template name="person.name.list"/>
380 <xsl:template match="figure|example|table|equation" mode="xref-to">
381 <xsl:param name="referrer"/>
382 <xsl:param name="xrefstyle"/>
383 <xsl:param name="verbose" select="1"/>
385 <xsl:apply-templates select="." mode="object.xref.markup">
386 <xsl:with-param name="purpose" select="'xref'"/>
387 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
388 <xsl:with-param name="referrer" select="$referrer"/>
389 <xsl:with-param name="verbose" select="$verbose"/>
390 </xsl:apply-templates>
393 <xsl:template match="procedure" mode="xref-to">
394 <xsl:param name="referrer"/>
395 <xsl:param name="xrefstyle"/>
396 <xsl:param name="verbose"/>
398 <xsl:apply-templates select="." mode="object.xref.markup">
399 <xsl:with-param name="purpose" select="'xref'"/>
400 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
401 <xsl:with-param name="referrer" select="$referrer"/>
402 <xsl:with-param name="verbose" select="$verbose"/>
403 </xsl:apply-templates>
406 <xsl:template match="task" mode="xref-to">
407 <xsl:param name="referrer"/>
408 <xsl:param name="xrefstyle"/>
409 <xsl:param name="verbose"/>
411 <xsl:apply-templates select="." mode="object.xref.markup">
412 <xsl:with-param name="purpose" select="'xref'"/>
413 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
414 <xsl:with-param name="referrer" select="$referrer"/>
415 <xsl:with-param name="verbose" select="$verbose"/>
416 </xsl:apply-templates>
419 <xsl:template match="cmdsynopsis" mode="xref-to">
420 <xsl:apply-templates select="(.//command)[1]" mode="xref"/>
423 <xsl:template match="funcsynopsis" mode="xref-to">
424 <xsl:apply-templates select="(.//function)[1]" mode="xref"/>
427 <xsl:template match="dedication|acknowledgements|preface|chapter|appendix|article" mode="xref-to">
428 <xsl:param name="referrer"/>
429 <xsl:param name="xrefstyle"/>
430 <xsl:param name="verbose" select="1"/>
432 <xsl:apply-templates select="." mode="object.xref.markup">
433 <xsl:with-param name="purpose" select="'xref'"/>
434 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
435 <xsl:with-param name="referrer" select="$referrer"/>
436 <xsl:with-param name="verbose" select="$verbose"/>
437 </xsl:apply-templates>
440 <xsl:template match="bibliography" mode="xref-to">
441 <xsl:param name="referrer"/>
442 <xsl:param name="xrefstyle"/>
443 <xsl:param name="verbose" select="1"/>
445 <xsl:apply-templates select="." mode="object.xref.markup">
446 <xsl:with-param name="purpose" select="'xref'"/>
447 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
448 <xsl:with-param name="referrer" select="$referrer"/>
449 <xsl:with-param name="verbose" select="$verbose"/>
450 </xsl:apply-templates>
453 <xsl:template match="biblioentry|bibliomixed" mode="xref-to-prefix">
454 <xsl:text>[</xsl:text>
457 <xsl:template match="biblioentry|bibliomixed" mode="xref-to-suffix">
458 <xsl:text>]</xsl:text>
461 <xsl:template match="biblioentry|bibliomixed" mode="xref-to">
462 <xsl:param name="referrer"/>
463 <xsl:param name="xrefstyle"/>
464 <xsl:param name="verbose" select="1"/>
466 <!-- handles both biblioentry and bibliomixed -->
468 <xsl:when test="string(.) = ''">
469 <xsl:variable name="bib" select="document($bibliography.collection,.)"/>
470 <xsl:variable name="id" select="(@id|@xml:id)[1]"/>
471 <xsl:variable name="entry" select="$bib/bibliography/
472 *[@id=$id or @xml:id=$id][1]"/>
474 <xsl:when test="$entry">
476 <xsl:when test="$bibliography.numbered != 0">
477 <xsl:number from="bibliography" count="biblioentry|bibliomixed"
478 level="any" format="1"/>
480 <xsl:when test="local-name($entry/*[1]) = 'abbrev'">
481 <xsl:apply-templates select="$entry/*[1]"/>
484 <xsl:value-of select="(@id|@xml:id)[1]"/>
490 <xsl:text>No bibliography entry: </xsl:text>
491 <xsl:value-of select="$id"/>
492 <xsl:text> found in </xsl:text>
493 <xsl:value-of select="$bibliography.collection"/>
495 <xsl:value-of select="(@id|@xml:id)[1]"/>
501 <xsl:when test="$bibliography.numbered != 0">
502 <xsl:number from="bibliography" count="biblioentry|bibliomixed"
503 level="any" format="1"/>
505 <xsl:when test="local-name(*[1]) = 'abbrev'">
506 <xsl:apply-templates select="*[1]"/>
509 <xsl:value-of select="(@id|@xml:id)[1]"/>
516 <xsl:template match="glossary" mode="xref-to">
517 <xsl:param name="referrer"/>
518 <xsl:param name="xrefstyle"/>
519 <xsl:param name="verbose" select="1"/>
521 <xsl:apply-templates select="." mode="object.xref.markup">
522 <xsl:with-param name="purpose" select="'xref'"/>
523 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
524 <xsl:with-param name="referrer" select="$referrer"/>
525 <xsl:with-param name="verbose" select="$verbose"/>
526 </xsl:apply-templates>
529 <xsl:template match="glossentry" mode="xref-to">
530 <xsl:param name="referrer"/>
531 <xsl:param name="xrefstyle"/>
532 <xsl:param name="verbose" select="1"/>
534 <xsl:when test="$glossentry.show.acronym = 'primary'">
536 <xsl:when test="acronym|abbrev">
537 <xsl:apply-templates select="(acronym|abbrev)[1]"/>
540 <xsl:apply-templates select="glossterm[1]" mode="xref-to">
541 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
542 <xsl:with-param name="referrer" select="$referrer"/>
543 <xsl:with-param name="verbose" select="$verbose"/>
544 </xsl:apply-templates>
549 <xsl:apply-templates select="glossterm[1]" mode="xref-to">
550 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
551 <xsl:with-param name="referrer" select="$referrer"/>
552 <xsl:with-param name="verbose" select="$verbose"/>
553 </xsl:apply-templates>
558 <xsl:template match="glossterm|firstterm" mode="xref-to">
559 <xsl:apply-templates/>
562 <xsl:template match="index" mode="xref-to">
563 <xsl:param name="referrer"/>
564 <xsl:param name="xrefstyle"/>
565 <xsl:param name="verbose" select="1"/>
567 <xsl:apply-templates select="." mode="object.xref.markup">
568 <xsl:with-param name="purpose" select="'xref'"/>
569 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
570 <xsl:with-param name="referrer" select="$referrer"/>
571 <xsl:with-param name="verbose" select="$verbose"/>
572 </xsl:apply-templates>
575 <xsl:template match="listitem" mode="xref-to">
576 <xsl:param name="referrer"/>
577 <xsl:param name="xrefstyle"/>
578 <xsl:param name="verbose"/>
580 <xsl:apply-templates select="." mode="object.xref.markup">
581 <xsl:with-param name="purpose" select="'xref'"/>
582 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
583 <xsl:with-param name="referrer" select="$referrer"/>
584 <xsl:with-param name="verbose" select="$verbose"/>
585 </xsl:apply-templates>
588 <xsl:template match="section|simplesect
589 |sect1|sect2|sect3|sect4|sect5
590 |refsect1|refsect2|refsect3|refsection" mode="xref-to">
591 <xsl:param name="referrer"/>
592 <xsl:param name="xrefstyle"/>
593 <xsl:param name="verbose" select="1"/>
595 <xsl:apply-templates select="." mode="object.xref.markup">
596 <xsl:with-param name="purpose" select="'xref'"/>
597 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
598 <xsl:with-param name="referrer" select="$referrer"/>
599 <xsl:with-param name="verbose" select="$verbose"/>
600 </xsl:apply-templates>
601 <!-- FIXME: What about "in Chapter X"? -->
604 <xsl:template match="bridgehead" mode="xref-to">
605 <xsl:param name="referrer"/>
606 <xsl:param name="xrefstyle"/>
607 <xsl:param name="verbose" select="1"/>
609 <xsl:apply-templates select="." mode="object.xref.markup">
610 <xsl:with-param name="purpose" select="'xref'"/>
611 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
612 <xsl:with-param name="referrer" select="$referrer"/>
613 <xsl:with-param name="verbose" select="$verbose"/>
614 </xsl:apply-templates>
615 <!-- FIXME: What about "in Chapter X"? -->
618 <xsl:template match="qandaset" mode="xref-to">
619 <xsl:param name="referrer"/>
620 <xsl:param name="xrefstyle"/>
621 <xsl:param name="verbose" select="1"/>
623 <xsl:apply-templates select="." mode="object.xref.markup">
624 <xsl:with-param name="purpose" select="'xref'"/>
625 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
626 <xsl:with-param name="referrer" select="$referrer"/>
627 <xsl:with-param name="verbose" select="$verbose"/>
628 </xsl:apply-templates>
631 <xsl:template match="qandadiv" mode="xref-to">
632 <xsl:param name="referrer"/>
633 <xsl:param name="xrefstyle"/>
634 <xsl:param name="verbose" select="1"/>
636 <xsl:apply-templates select="." mode="object.xref.markup">
637 <xsl:with-param name="purpose" select="'xref'"/>
638 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
639 <xsl:with-param name="referrer" select="$referrer"/>
640 <xsl:with-param name="verbose" select="$verbose"/>
641 </xsl:apply-templates>
644 <xsl:template match="qandaentry" mode="xref-to">
645 <xsl:param name="referrer"/>
646 <xsl:param name="xrefstyle"/>
647 <xsl:param name="verbose" select="1"/>
649 <xsl:apply-templates select="question[1]" mode="xref-to">
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>
656 <xsl:template match="question|answer" mode="xref-to">
657 <xsl:param name="referrer"/>
658 <xsl:param name="xrefstyle"/>
659 <xsl:param name="verbose" select="1"/>
662 <xsl:when test="string-length(label) != 0">
663 <xsl:apply-templates select="." mode="label.markup"/>
666 <xsl:apply-templates select="." mode="object.xref.markup">
667 <xsl:with-param name="purpose" select="'xref'"/>
668 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
669 <xsl:with-param name="referrer" select="$referrer"/>
670 <xsl:with-param name="verbose" select="$verbose"/>
671 </xsl:apply-templates>
676 <xsl:template match="part|reference" mode="xref-to">
677 <xsl:param name="referrer"/>
678 <xsl:param name="xrefstyle"/>
679 <xsl:param name="verbose" select="1"/>
681 <xsl:apply-templates select="." mode="object.xref.markup">
682 <xsl:with-param name="purpose" select="'xref'"/>
683 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
684 <xsl:with-param name="referrer" select="$referrer"/>
685 <xsl:with-param name="verbose" select="$verbose"/>
686 </xsl:apply-templates>
689 <xsl:template match="refentry" mode="xref-to">
690 <xsl:param name="referrer"/>
691 <xsl:param name="xrefstyle"/>
694 <xsl:when test="refmeta/refentrytitle">
695 <xsl:apply-templates select="refmeta/refentrytitle"/>
698 <xsl:apply-templates select="refnamediv/refname[1]"/>
701 <xsl:apply-templates select="refmeta/manvolnum"/>
704 <xsl:template match="refnamediv" mode="xref-to">
705 <xsl:param name="referrer"/>
706 <xsl:param name="xrefstyle"/>
707 <xsl:param name="verbose" select="1"/>
709 <xsl:apply-templates select="refname[1]" mode="xref-to">
710 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
711 <xsl:with-param name="referrer" select="$referrer"/>
712 <xsl:with-param name="verbose" select="$verbose"/>
713 </xsl:apply-templates>
716 <xsl:template match="refname" mode="xref-to">
717 <xsl:param name="referrer"/>
718 <xsl:param name="xrefstyle"/>
719 <xsl:param name="verbose" select="1"/>
721 <xsl:apply-templates mode="xref-to"/>
724 <xsl:template match="step" mode="xref-to">
725 <xsl:param name="referrer"/>
726 <xsl:param name="xrefstyle"/>
728 <xsl:call-template name="gentext">
729 <xsl:with-param name="key" select="'Step'"/>
731 <xsl:text> </xsl:text>
732 <xsl:apply-templates select="." mode="number"/>
735 <xsl:template match="varlistentry" mode="xref-to">
736 <xsl:param name="referrer"/>
737 <xsl:param name="xrefstyle"/>
738 <xsl:param name="verbose" select="1"/>
740 <xsl:apply-templates select="term[1]" mode="xref-to">
741 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
742 <xsl:with-param name="referrer" select="$referrer"/>
743 <xsl:with-param name="verbose" select="$verbose"/>
744 </xsl:apply-templates>
747 <xsl:template match="primary|secondary|tertiary" mode="xref-to">
748 <xsl:value-of select="."/>
751 <xsl:template match="indexterm" mode="xref-to">
752 <xsl:value-of select="primary"/>
755 <xsl:template match="varlistentry/term" mode="xref-to">
756 <xsl:param name="referrer"/>
757 <xsl:param name="xrefstyle"/>
759 <!-- to avoid the comma that will be generated if there are several terms -->
760 <xsl:apply-templates/>
763 <xsl:template match="co" mode="xref-to">
764 <xsl:param name="referrer"/>
765 <xsl:param name="xrefstyle"/>
767 <xsl:apply-templates select="." mode="callout-bug"/>
770 <xsl:template match="area|areaset" mode="xref-to">
771 <xsl:param name="referrer"/>
772 <xsl:param name="xrefstyle"/>
774 <xsl:call-template name="callout-bug">
775 <xsl:with-param name="conum">
776 <xsl:apply-templates select="." mode="conumber"/>
781 <xsl:template match="book" mode="xref-to">
782 <xsl:param name="referrer"/>
783 <xsl:param name="xrefstyle"/>
784 <xsl:param name="verbose" select="1"/>
786 <xsl:apply-templates select="." mode="object.xref.markup">
787 <xsl:with-param name="purpose" select="'xref'"/>
788 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
789 <xsl:with-param name="referrer" select="$referrer"/>
790 <xsl:with-param name="verbose" select="$verbose"/>
791 </xsl:apply-templates>
794 <!-- These are elements for which no link text exists, so an xref to one
795 uses the xrefstyle attribute if specified, or if not it falls back
796 to the container element's link text -->
797 <xsl:template match="para|phrase|simpara|anchor|quote" mode="xref-to">
798 <xsl:param name="referrer"/>
799 <xsl:param name="xrefstyle"/>
800 <xsl:param name="verbose" select="1"/>
802 <xsl:variable name="context" select="(ancestor::simplesect
809 |ancestor::refsection
817 |ancestor::dedication
818 |ancestor::acknowledgements
820 |ancestor::bibliography
823 |ancestor::glossentry
825 |ancestor::varlistentry)[last()]"/>
828 <xsl:when test="$xrefstyle != ''">
829 <xsl:apply-templates select="." mode="object.xref.markup">
830 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
831 <xsl:with-param name="referrer" select="$referrer"/>
832 <xsl:with-param name="verbose" select="$verbose"/>
833 </xsl:apply-templates>
836 <xsl:apply-templates select="$context" mode="xref-to">
837 <xsl:with-param name="purpose" select="'xref'"/>
838 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
839 <xsl:with-param name="referrer" select="$referrer"/>
840 <xsl:with-param name="verbose" select="$verbose"/>
841 </xsl:apply-templates>
846 <!-- ==================================================================== -->
848 <xsl:template match="*" mode="xref-title">
849 <xsl:variable name="title">
850 <xsl:apply-templates select="." mode="object.title.markup"/>
853 <xsl:value-of select="$title"/>
856 <xsl:template match="author" mode="xref-title">
857 <xsl:variable name="title">
858 <xsl:call-template name="person.name"/>
861 <xsl:value-of select="$title"/>
864 <xsl:template match="authorgroup" mode="xref-title">
865 <xsl:variable name="title">
866 <xsl:call-template name="person.name.list"/>
869 <xsl:value-of select="$title"/>
872 <xsl:template match="cmdsynopsis" mode="xref-title">
873 <xsl:variable name="title">
874 <xsl:apply-templates select="(.//command)[1]" mode="xref"/>
877 <xsl:value-of select="$title"/>
880 <xsl:template match="funcsynopsis" mode="xref-title">
881 <xsl:variable name="title">
882 <xsl:apply-templates select="(.//function)[1]" mode="xref"/>
885 <xsl:value-of select="$title"/>
888 <xsl:template match="biblioentry|bibliomixed" mode="xref-title">
889 <!-- handles both biblioentry and bibliomixed -->
890 <xsl:variable name="title">
891 <xsl:text>[</xsl:text>
893 <xsl:when test="local-name(*[1]) = 'abbrev'">
894 <xsl:apply-templates select="*[1]"/>
897 <xsl:value-of select="(@id|@xml:id)[1]"/>
900 <xsl:text>]</xsl:text>
903 <xsl:value-of select="$title"/>
906 <xsl:template match="step" mode="xref-title">
907 <xsl:call-template name="gentext">
908 <xsl:with-param name="key" select="'Step'"/>
910 <xsl:text> </xsl:text>
911 <xsl:apply-templates select="." mode="number"/>
914 <xsl:template match="step[not(./title)]" mode="title.markup">
915 <xsl:call-template name="gentext">
916 <xsl:with-param name="key" select="'Step'"/>
918 <xsl:text> </xsl:text>
919 <xsl:apply-templates select="." mode="number"/>
922 <xsl:template match="co" mode="xref-title">
923 <xsl:variable name="title">
924 <xsl:apply-templates select="." mode="callout-bug"/>
927 <xsl:value-of select="$title"/>
930 <!-- ==================================================================== -->
932 <xsl:template match="link" name="link">
933 <xsl:param name="linkend" select="@linkend"/>
934 <xsl:param name="a.target"/>
935 <xsl:param name="xhref" select="@xlink:href"/>
937 <xsl:variable name="content">
938 <xsl:call-template name="anchor"/>
940 <xsl:when test="count(child::node()) > 0">
941 <!-- If it has content, use it -->
942 <xsl:apply-templates/>
944 <!-- else look for an endterm -->
945 <xsl:when test="@endterm">
946 <xsl:variable name="etargets" select="key('id',@endterm)"/>
947 <xsl:variable name="etarget" select="$etargets[1]"/>
949 <xsl:when test="count($etarget) = 0">
951 <xsl:value-of select="count($etargets)"/>
952 <xsl:text>Endterm points to nonexistent ID: </xsl:text>
953 <xsl:value-of select="@endterm"/>
955 <xsl:text>???</xsl:text>
958 <xsl:apply-templates select="$etarget" mode="endterm"/>
962 <!-- Use the xlink:href if no other text -->
963 <xsl:when test="@xlink:href">
964 <xsl:value-of select="@xlink:href"/>
968 <xsl:text>Link element has no content and no Endterm. </xsl:text>
969 <xsl:text>Nothing to show in the link to </xsl:text>
970 <xsl:value-of select="(@xlink:href|@linkend)[1]"/>
972 <xsl:text>???</xsl:text>
977 <xsl:call-template name="simple.xlink">
978 <xsl:with-param name="node" select="."/>
979 <xsl:with-param name="linkend" select="$linkend"/>
980 <xsl:with-param name="content" select="$content"/>
981 <xsl:with-param name="a.target" select="$a.target"/>
982 <xsl:with-param name="xhref" select="$xhref"/>
987 <xsl:template match="ulink" name="ulink">
988 <xsl:param name="url" select="@url"/>
989 <xsl:variable name="link">
991 <xsl:apply-templates select="." mode="common.html.attributes"/>
992 <xsl:if test="@id or @xml:id">
993 <xsl:attribute name="name">
994 <xsl:value-of select="(@id|@xml:id)[1]"/>
997 <xsl:attribute name="href"><xsl:value-of select="$url"/></xsl:attribute>
998 <xsl:if test="$ulink.target != ''">
999 <xsl:attribute name="target">
1000 <xsl:value-of select="$ulink.target"/>
1004 <xsl:when test="count(child::node())=0">
1005 <xsl:value-of select="$url"/>
1008 <xsl:apply-templates/>
1015 <xsl:when test="function-available('suwl:unwrapLinks')">
1016 <xsl:copy-of select="suwl:unwrapLinks($link)"/>
1019 <xsl:copy-of select="$link"/>
1024 <xsl:template match="olink" name="olink">
1025 <!-- olink content may be passed in from xlink olink -->
1026 <xsl:param name="content" select="NOTANELEMENT"/>
1028 <xsl:call-template name="anchor"/>
1030 <xsl:variable name="localinfo" select="@localinfo"/>
1033 <!-- olinks resolved by stylesheet and target database -->
1034 <xsl:when test="@targetdoc or @targetptr or
1035 (@xlink:role=$xolink.role and
1036 contains(@xlink:href, '#') )" >
1038 <xsl:variable name="targetdoc.att">
1040 <xsl:when test="@targetdoc != ''">
1041 <xsl:value-of select="@targetdoc"/>
1043 <xsl:when test="@xlink:role=$xolink.role and
1044 contains(@xlink:href, '#')" >
1045 <xsl:value-of select="substring-before(@xlink:href, '#')"/>
1050 <xsl:variable name="targetptr.att">
1052 <xsl:when test="@targetptr != ''">
1053 <xsl:value-of select="@targetptr"/>
1055 <xsl:when test="@xlink:role=$xolink.role and
1056 contains(@xlink:href, '#')" >
1057 <xsl:value-of select="substring-after(@xlink:href, '#')"/>
1062 <xsl:variable name="olink.lang">
1063 <xsl:call-template name="l10n.language">
1064 <xsl:with-param name="xref-context" select="true()"/>
1065 </xsl:call-template>
1068 <xsl:variable name="target.database.filename">
1069 <xsl:call-template name="select.target.database">
1070 <xsl:with-param name="targetdoc.att" select="$targetdoc.att"/>
1071 <xsl:with-param name="targetptr.att" select="$targetptr.att"/>
1072 <xsl:with-param name="olink.lang" select="$olink.lang"/>
1073 </xsl:call-template>
1076 <xsl:variable name="target.database"
1077 select="document($target.database.filename,/)"/>
1079 <xsl:if test="$olink.debug != 0">
1081 <xsl:text>Olink debug: root element of target.database '</xsl:text>
1082 <xsl:value-of select="$target.database.filename"/>
1083 <xsl:text>' is '</xsl:text>
1084 <xsl:value-of select="local-name($target.database/*[1])"/>
1085 <xsl:text>'.</xsl:text>
1089 <xsl:variable name="olink.key">
1090 <xsl:call-template name="select.olink.key">
1091 <xsl:with-param name="targetdoc.att" select="$targetdoc.att"/>
1092 <xsl:with-param name="targetptr.att" select="$targetptr.att"/>
1093 <xsl:with-param name="olink.lang" select="$olink.lang"/>
1094 <xsl:with-param name="target.database" select="$target.database"/>
1095 </xsl:call-template>
1098 <xsl:if test="string-length($olink.key) = 0">
1100 <xsl:text>Error: unresolved olink: </xsl:text>
1101 <xsl:text>targetdoc/targetptr = '</xsl:text>
1102 <xsl:value-of select="$targetdoc.att"/>
1103 <xsl:text>/</xsl:text>
1104 <xsl:value-of select="$targetptr.att"/>
1105 <xsl:text>'.</xsl:text>
1109 <xsl:variable name="href">
1110 <xsl:call-template name="make.olink.href">
1111 <xsl:with-param name="olink.key" select="$olink.key"/>
1112 <xsl:with-param name="target.database" select="$target.database"/>
1113 </xsl:call-template>
1116 <xsl:variable name="hottext">
1118 <xsl:when test="string-length($content) != 0">
1119 <xsl:copy-of select="$content"/>
1122 <xsl:call-template name="olink.hottext">
1123 <xsl:with-param name="olink.key" select="$olink.key"/>
1124 <xsl:with-param name="olink.lang" select="$olink.lang"/>
1125 <xsl:with-param name="target.database" select="$target.database"/>
1126 </xsl:call-template>
1131 <xsl:variable name="olink.docname.citation">
1132 <xsl:call-template name="olink.document.citation">
1133 <xsl:with-param name="olink.key" select="$olink.key"/>
1134 <xsl:with-param name="target.database" select="$target.database"/>
1135 <xsl:with-param name="olink.lang" select="$olink.lang"/>
1136 </xsl:call-template>
1139 <xsl:variable name="olink.page.citation">
1140 <xsl:call-template name="olink.page.citation">
1141 <xsl:with-param name="olink.key" select="$olink.key"/>
1142 <xsl:with-param name="target.database" select="$target.database"/>
1143 <xsl:with-param name="olink.lang" select="$olink.lang"/>
1144 </xsl:call-template>
1148 <xsl:when test="$href != ''">
1150 <xsl:apply-templates select="." mode="common.html.attributes"/>
1151 <xsl:copy-of select="$hottext"/>
1153 <xsl:copy-of select="$olink.page.citation"/>
1154 <xsl:copy-of select="$olink.docname.citation"/>
1157 <span class="olink"><xsl:copy-of select="$hottext"/></span>
1158 <xsl:copy-of select="$olink.page.citation"/>
1159 <xsl:copy-of select="$olink.docname.citation"/>
1165 <!-- Or use old olink mechanism -->
1167 <xsl:variable name="href">
1169 <xsl:when test="@linkmode">
1170 <!-- use the linkmode to get the base URI, use localinfo as fragid -->
1171 <xsl:variable name="modespec" select="key('id',@linkmode)"/>
1172 <xsl:if test="count($modespec) != 1
1173 or local-name($modespec) != 'modespec'">
1174 <xsl:message>Warning: olink linkmode pointer is wrong.</xsl:message>
1176 <xsl:value-of select="$modespec"/>
1177 <xsl:if test="@localinfo">
1178 <xsl:text>#</xsl:text>
1179 <xsl:value-of select="@localinfo"/>
1182 <xsl:when test="@type = 'href'">
1183 <xsl:call-template name="olink.outline">
1184 <xsl:with-param name="outline.base.uri"
1185 select="unparsed-entity-uri(@targetdocent)"/>
1186 <xsl:with-param name="localinfo" select="@localinfo"/>
1187 <xsl:with-param name="return" select="'href'"/>
1188 </xsl:call-template>
1191 <xsl:value-of select="$olink.resolver"/>
1192 <xsl:text>?</xsl:text>
1193 <xsl:value-of select="$olink.sysid"/>
1194 <xsl:value-of select="unparsed-entity-uri(@targetdocent)"/>
1195 <!-- XSL gives no access to the public identifier (grumble...) -->
1196 <xsl:if test="@localinfo">
1197 <xsl:text>&</xsl:text>
1198 <xsl:value-of select="$olink.fragid"/>
1199 <xsl:value-of select="@localinfo"/>
1206 <xsl:when test="$href != ''">
1208 <xsl:apply-templates select="." mode="common.html.attributes"/>
1209 <xsl:call-template name="olink.hottext"/>
1213 <xsl:call-template name="olink.hottext"/>
1220 <xsl:template match="*" mode="pagenumber.markup">
1221 <!-- no-op in HTML -->
1225 <xsl:template name="olink.outline">
1226 <xsl:param name="outline.base.uri"/>
1227 <xsl:param name="localinfo"/>
1228 <xsl:param name="return" select="href"/>
1230 <xsl:variable name="outline-file"
1231 select="concat($outline.base.uri,
1232 $olink.outline.ext)"/>
1234 <xsl:variable name="outline" select="document($outline-file,.)/div"/>
1236 <xsl:variable name="node-href">
1238 <xsl:when test="$localinfo != ''">
1239 <xsl:variable name="node" select="$outline//
1240 *[@id=$localinfo or @xml:id=$localinfo]"/>
1241 <xsl:value-of select="$node/@href"/>
1244 <xsl:value-of select="$outline/@href"/>
1249 <xsl:variable name="node-xref">
1251 <xsl:when test="$localinfo != ''">
1252 <xsl:variable name="node" select="$outline//
1253 *[@id=$localinfo or @xml:id=$localinfo]"/>
1254 <xsl:copy-of select="$node/xref"/>
1257 <xsl:value-of select="$outline/xref"/>
1263 <xsl:when test="$return = 'href'">
1264 <xsl:value-of select="$node-href"/>
1266 <xsl:when test="$return = 'xref'">
1267 <xsl:value-of select="$node-xref"/>
1270 <xsl:copy-of select="$node-xref"/>
1275 <!-- ==================================================================== -->
1277 <xsl:template name="xref.xreflabel">
1278 <!-- called to process an xreflabel...you might use this to make -->
1279 <!-- xreflabels come out in the right font for different targets, -->
1280 <!-- for example. -->
1281 <xsl:param name="target" select="."/>
1282 <xsl:value-of select="$target/@xreflabel"/>
1285 <!-- ==================================================================== -->
1287 <xsl:template match="title" mode="xref">
1288 <xsl:apply-templates/>
1291 <xsl:template match="command" mode="xref">
1292 <xsl:call-template name="inline.boldseq"/>
1295 <xsl:template match="function" mode="xref">
1296 <xsl:call-template name="inline.monoseq"/>
1299 <!-- ==================================================================== -->
1301 <xsl:template match="*" mode="insert.title.markup">
1302 <xsl:param name="purpose"/>
1303 <xsl:param name="xrefstyle"/>
1304 <xsl:param name="title"/>
1307 <!-- FIXME: what about the case where titleabbrev is inside the info? -->
1308 <xsl:when test="$purpose = 'xref' and titleabbrev">
1309 <xsl:apply-templates select="." mode="titleabbrev.markup"/>
1312 <xsl:copy-of select="$title"/>
1317 <xsl:template match="chapter|appendix" mode="insert.title.markup">
1318 <xsl:param name="purpose"/>
1319 <xsl:param name="xrefstyle"/>
1320 <xsl:param name="title"/>
1323 <xsl:when test="$purpose = 'xref'">
1325 <xsl:copy-of select="$title"/>
1329 <xsl:copy-of select="$title"/>
1334 <xsl:template match="*" mode="insert.subtitle.markup">
1335 <xsl:param name="purpose"/>
1336 <xsl:param name="xrefstyle"/>
1337 <xsl:param name="subtitle"/>
1339 <xsl:copy-of select="$subtitle"/>
1342 <xsl:template match="*" mode="insert.label.markup">
1343 <xsl:param name="purpose"/>
1344 <xsl:param name="xrefstyle"/>
1345 <xsl:param name="label"/>
1347 <xsl:copy-of select="$label"/>
1350 <xsl:template match="*" mode="insert.pagenumber.markup">
1351 <xsl:param name="purpose"/>
1352 <xsl:param name="xrefstyle"/>
1353 <xsl:param name="pagenumber"/>
1355 <xsl:copy-of select="$pagenumber"/>
1358 <xsl:template match="*" mode="insert.direction.markup">
1359 <xsl:param name="purpose"/>
1360 <xsl:param name="xrefstyle"/>
1361 <xsl:param name="direction"/>
1363 <xsl:copy-of select="$direction"/>
1366 <xsl:template match="*" mode="insert.olink.docname.markup">
1367 <xsl:param name="purpose"/>
1368 <xsl:param name="xrefstyle"/>
1369 <xsl:param name="docname"/>
1371 <span class="olinkdocname">
1372 <xsl:copy-of select="$docname"/>