source: stylesheets/lfs-xsl/docbook-xsl-1.78.1/fo/xref.xsl@ 15c7d39

10.0 10.0-rc1 10.1 10.1-rc1 11.0 11.0-rc1 11.0-rc2 11.0-rc3 11.1 11.1-rc1 11.2 11.2-rc1 11.3 11.3-rc1 12.0 12.0-rc1 12.1 12.1-rc1 7.5 7.6 7.7 7.8 7.9 8.0 8.1 8.2 8.3 8.4 9.0 9.1 arm bdubbs/gcc13 ml-11.0 multilib renodr/libudev-from-systemd s6-init trunk xry111/arm64 xry111/arm64-12.0 xry111/clfs-ng xry111/lfs-next xry111/loongarch xry111/loongarch-12.0 xry111/loongarch-12.1 xry111/mips64el xry111/pip3 xry111/rust-wip-20221008 xry111/update-glibc
Last change on this file since 15c7d39 was 15c7d39, checked in by Matthew Burgess <matthew@…>, 11 years ago

Update stylesheets to docbook-xsl-1.78.1.

git-svn-id: http://svn.linuxfromscratch.org/LFS/trunk/BOOK@10355 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

  • Property mode set to 100644
File size: 56.1 KB
Line 
1<?xml version='1.0'?>
2<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3 xmlns:fo="http://www.w3.org/1999/XSL/Format"
4 xmlns:exsl="http://exslt.org/common"
5 xmlns:xlink='http://www.w3.org/1999/xlink'
6 exclude-result-prefixes="exsl xlink"
7 version='1.0'>
8
9<!-- ********************************************************************
10 $Id: xref.xsl 9723 2013-02-06 13:08:06Z kosek $
11 ********************************************************************
12
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.
16
17 ******************************************************************** -->
18
19<!-- Use internal variable for olink xlink role for consistency -->
20<xsl:variable
21 name="xolink.role">http://docbook.org/xlink/role/olink</xsl:variable>
22
23<!-- ==================================================================== -->
24
25<xsl:template match="anchor">
26 <xsl:variable name="id">
27 <xsl:call-template name="object.id"/>
28 </xsl:variable>
29
30 <xsl:variable name="wrapper.name">
31 <xsl:call-template name="inline.or.block"/>
32 </xsl:variable>
33
34 <xsl:element name="{$wrapper.name}">
35 <xsl:attribute name="id">
36 <xsl:value-of select="$id"/>
37 </xsl:attribute>
38 </xsl:element>
39</xsl:template>
40
41<!-- ==================================================================== -->
42
43<xsl:template match="xref" name="xref">
44 <xsl:param name="xhref" select="@xlink:href"/>
45 <!-- is the @xlink:href a local idref link? -->
46 <xsl:param name="xlink.idref">
47 <xsl:if test="starts-with($xhref,'#')
48 and (not(contains($xhref,'&#40;'))
49 or starts-with($xhref, '#xpointer&#40;id&#40;'))">
50 <xsl:call-template name="xpointer.idref">
51 <xsl:with-param name="xpointer" select="$xhref"/>
52 </xsl:call-template>
53 </xsl:if>
54 </xsl:param>
55 <xsl:param name="xlink.targets" select="key('id',$xlink.idref)"/>
56 <xsl:param name="linkend.targets" select="key('id',@linkend)"/>
57 <xsl:param name="target" select="($xlink.targets | $linkend.targets)[1]"/>
58 <xsl:param name="refelem" select="local-name($target)"/>
59
60 <xsl:variable name="xrefstyle">
61 <xsl:choose>
62 <xsl:when test="@role and not(@xrefstyle)
63 and $use.role.as.xrefstyle != 0">
64 <xsl:value-of select="@role"/>
65 </xsl:when>
66 <xsl:otherwise>
67 <xsl:value-of select="@xrefstyle"/>
68 </xsl:otherwise>
69 </xsl:choose>
70 </xsl:variable>
71
72 <xsl:variable name="content">
73 <fo:inline xsl:use-attribute-sets="xref.properties">
74 <xsl:choose>
75 <xsl:when test="@endterm">
76 <xsl:variable name="etargets" select="key('id',@endterm)"/>
77 <xsl:variable name="etarget" select="$etargets[1]"/>
78 <xsl:choose>
79 <xsl:when test="count($etarget) = 0">
80 <xsl:message>
81 <xsl:value-of select="count($etargets)"/>
82 <xsl:text>Endterm points to nonexistent ID: </xsl:text>
83 <xsl:value-of select="@endterm"/>
84 </xsl:message>
85 <xsl:text>???</xsl:text>
86 </xsl:when>
87 <xsl:otherwise>
88 <xsl:apply-templates select="$etarget" mode="endterm"/>
89 </xsl:otherwise>
90 </xsl:choose>
91 </xsl:when>
92
93 <xsl:when test="$target/@xreflabel">
94 <xsl:call-template name="xref.xreflabel">
95 <xsl:with-param name="target" select="$target"/>
96 </xsl:call-template>
97 </xsl:when>
98
99 <xsl:when test="$target">
100 <xsl:if test="not(parent::citation)">
101 <xsl:apply-templates select="$target" mode="xref-to-prefix"/>
102 </xsl:if>
103
104 <xsl:apply-templates select="$target" mode="xref-to">
105 <xsl:with-param name="referrer" select="."/>
106 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
107 </xsl:apply-templates>
108
109 <xsl:if test="not(parent::citation)">
110 <xsl:apply-templates select="$target" mode="xref-to-suffix"/>
111 </xsl:if>
112 </xsl:when>
113 <xsl:otherwise>
114 <xsl:message>
115 <xsl:text>ERROR: xref linking to </xsl:text>
116 <xsl:value-of select="@linkend|@xlink:href"/>
117 <xsl:text> has no generated link text.</xsl:text>
118 </xsl:message>
119 <xsl:text>???</xsl:text>
120 </xsl:otherwise>
121 </xsl:choose>
122 </fo:inline>
123 </xsl:variable>
124
125 <!-- Convert it into an active link -->
126 <xsl:call-template name="simple.xlink">
127 <xsl:with-param name="content" select="$content"/>
128 </xsl:call-template>
129
130 <!-- Add standard page reference? -->
131 <xsl:choose>
132 <xsl:when test="not($target)">
133 <!-- page numbers only for local targets -->
134 </xsl:when>
135 <xsl:when test="starts-with(normalize-space($xrefstyle), 'select:')
136 and contains($xrefstyle, 'nopage')">
137 <!-- negative xrefstyle in instance turns it off -->
138 </xsl:when>
139 <!-- positive xrefstyle already handles it -->
140 <xsl:when test="not(starts-with(normalize-space($xrefstyle), 'select:')
141 and (contains($xrefstyle, 'page')
142 or contains($xrefstyle, 'Page')))
143 and ( $insert.xref.page.number = 'yes'
144 or $insert.xref.page.number = '1')
145 or (local-name($target) = 'para' and
146 $xrefstyle = '')">
147 <xsl:apply-templates select="$target" mode="page.citation">
148 <xsl:with-param name="id" select="$target/@id|$target/@xml:id"/>
149 </xsl:apply-templates>
150 </xsl:when>
151 </xsl:choose>
152</xsl:template>
153
154<!-- ==================================================================== -->
155
156<!-- Handled largely like an xref -->
157<!-- To be done: add support for begin, end, and units attributes -->
158<xsl:template match="biblioref" name="biblioref">
159 <xsl:variable name="targets" select="key('id',@linkend)"/>
160 <xsl:variable name="target" select="$targets[1]"/>
161 <xsl:variable name="refelem" select="local-name($target)"/>
162
163 <xsl:call-template name="check.id.unique">
164 <xsl:with-param name="linkend" select="@linkend"/>
165 </xsl:call-template>
166
167 <xsl:choose>
168 <xsl:when test="$refelem=''">
169 <xsl:message>
170 <xsl:text>XRef to nonexistent id: </xsl:text>
171 <xsl:value-of select="@linkend"/>
172 </xsl:message>
173 <xsl:text>???</xsl:text>
174 </xsl:when>
175
176 <xsl:when test="@endterm">
177 <fo:basic-link internal-destination="{@linkend}"
178 xsl:use-attribute-sets="xref.properties">
179 <xsl:variable name="etargets" select="key('id',@endterm)"/>
180 <xsl:variable name="etarget" select="$etargets[1]"/>
181 <xsl:choose>
182 <xsl:when test="count($etarget) = 0">
183 <xsl:message>
184 <xsl:value-of select="count($etargets)"/>
185 <xsl:text>Endterm points to nonexistent ID: </xsl:text>
186 <xsl:value-of select="@endterm"/>
187 </xsl:message>
188 <xsl:text>???</xsl:text>
189 </xsl:when>
190 <xsl:otherwise>
191 <xsl:apply-templates select="$etarget" mode="endterm"/>
192 </xsl:otherwise>
193 </xsl:choose>
194 </fo:basic-link>
195 </xsl:when>
196
197 <xsl:when test="$target/@xreflabel">
198 <fo:basic-link internal-destination="{@linkend}"
199 xsl:use-attribute-sets="xref.properties">
200 <xsl:call-template name="xref.xreflabel">
201 <xsl:with-param name="target" select="$target"/>
202 </xsl:call-template>
203 </fo:basic-link>
204 </xsl:when>
205
206 <xsl:otherwise>
207 <xsl:if test="not(parent::citation)">
208 <xsl:apply-templates select="$target" mode="xref-to-prefix"/>
209 </xsl:if>
210
211 <fo:basic-link internal-destination="{@linkend}"
212 xsl:use-attribute-sets="xref.properties">
213 <xsl:apply-templates select="$target" mode="xref-to">
214 <xsl:with-param name="referrer" select="."/>
215 <xsl:with-param name="xrefstyle">
216 <xsl:choose>
217 <xsl:when test="@role and not(@xrefstyle) and $use.role.as.xrefstyle != 0">
218 <xsl:value-of select="@role"/>
219 </xsl:when>
220 <xsl:otherwise>
221 <xsl:value-of select="@xrefstyle"/>
222 </xsl:otherwise>
223 </xsl:choose>
224 </xsl:with-param>
225 </xsl:apply-templates>
226 </fo:basic-link>
227
228 <xsl:if test="not(parent::citation)">
229 <xsl:apply-templates select="$target" mode="xref-to-suffix"/>
230 </xsl:if>
231 </xsl:otherwise>
232 </xsl:choose>
233
234</xsl:template>
235
236<!-- ==================================================================== -->
237
238<xsl:template match="*" mode="endterm">
239 <!-- Process the children of the endterm element -->
240 <xsl:variable name="endterm">
241 <xsl:apply-templates select="child::node()"/>
242 </xsl:variable>
243
244 <xsl:choose>
245 <xsl:when test="$exsl.node.set.available != 0">
246 <xsl:apply-templates select="exsl:node-set($endterm)" mode="remove-ids"/>
247 </xsl:when>
248 <xsl:otherwise>
249 <xsl:copy-of select="$endterm"/>
250 </xsl:otherwise>
251 </xsl:choose>
252</xsl:template>
253
254<xsl:template match="*" mode="remove-ids">
255 <xsl:copy>
256 <xsl:for-each select="@*">
257 <xsl:choose>
258 <xsl:when test="name(.) != 'id'">
259 <xsl:copy/>
260 </xsl:when>
261 <xsl:otherwise>
262 <xsl:message>removing <xsl:value-of select="name(.)"/></xsl:message>
263 </xsl:otherwise>
264 </xsl:choose>
265 </xsl:for-each>
266 <xsl:apply-templates mode="remove-ids"/>
267 </xsl:copy>
268</xsl:template>
269
270<!--- ==================================================================== -->
271
272<xsl:template match="*" mode="xref-to-prefix"/>
273<xsl:template match="*" mode="xref-to-suffix"/>
274
275<xsl:template match="*" mode="xref-to">
276 <xsl:param name="referrer"/>
277 <xsl:param name="xrefstyle"/>
278 <xsl:param name="verbose" select="1"/>
279
280
281 <xsl:if test="$verbose != 0">
282 <xsl:message>
283 <xsl:text>Don't know what gentext to create for xref to: "</xsl:text>
284 <xsl:value-of select="name(.)"/>
285 <xsl:text>"</xsl:text>
286 </xsl:message>
287 <xsl:text>???</xsl:text>
288 </xsl:if>
289</xsl:template>
290
291<xsl:template match="title" mode="xref-to">
292 <xsl:param name="referrer"/>
293 <xsl:param name="xrefstyle"/>
294 <xsl:param name="verbose" select="1"/>
295
296 <!-- if you xref to a title, xref to the parent... -->
297 <xsl:choose>
298 <!-- FIXME: how reliable is this? -->
299 <xsl:when test="contains(local-name(parent::*), 'info')">
300 <xsl:apply-templates select="parent::*[2]" mode="xref-to">
301 <xsl:with-param name="referrer" select="$referrer"/>
302 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
303 <xsl:with-param name="verbose" select="$verbose"/>
304 </xsl:apply-templates>
305 </xsl:when>
306 <xsl:otherwise>
307 <xsl:apply-templates select="parent::*" mode="xref-to">
308 <xsl:with-param name="referrer" select="$referrer"/>
309 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
310 <xsl:with-param name="verbose" select="$verbose"/>
311 </xsl:apply-templates>
312 </xsl:otherwise>
313 </xsl:choose>
314</xsl:template>
315
316<xsl:template match="abstract|article|authorblurb|bibliodiv|bibliomset
317 |biblioset|blockquote|calloutlist|caution|colophon
318 |constraintdef|formalpara|glossdiv|important|indexdiv
319 |itemizedlist|legalnotice|lot|msg|msgexplan|msgmain
320 |msgrel|msgset|msgsub|note|orderedlist|partintro
321 |productionset|qandadiv|refsynopsisdiv|screenshot|segmentedlist
322 |set|setindex|sidebar|tip|toc|variablelist|warning"
323 mode="xref-to">
324 <xsl:param name="referrer"/>
325 <xsl:param name="xrefstyle"/>
326 <xsl:param name="verbose" select="1"/>
327
328 <!-- catch-all for things with (possibly optional) titles -->
329 <xsl:apply-templates select="." mode="object.xref.markup">
330 <xsl:with-param name="purpose" select="'xref'"/>
331 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
332 <xsl:with-param name="referrer" select="$referrer"/>
333 <xsl:with-param name="verbose" select="$verbose"/>
334 </xsl:apply-templates>
335</xsl:template>
336
337<xsl:template match="author|editor|othercredit|personname" mode="xref-to">
338 <xsl:param name="referrer"/>
339 <xsl:param name="xrefstyle"/>
340 <xsl:param name="verbose" select="1"/>
341
342 <xsl:call-template name="person.name"/>
343</xsl:template>
344
345<xsl:template match="authorgroup" mode="xref-to">
346 <xsl:param name="referrer"/>
347 <xsl:param name="xrefstyle"/>
348 <xsl:param name="verbose" select="1"/>
349
350 <xsl:call-template name="person.name.list"/>
351</xsl:template>
352
353<xsl:template match="figure|example|table|equation" mode="xref-to">
354 <xsl:param name="referrer"/>
355 <xsl:param name="xrefstyle"/>
356 <xsl:param name="verbose" select="1"/>
357
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>
364</xsl:template>
365
366<xsl:template match="procedure" mode="xref-to">
367 <xsl:param name="referrer"/>
368 <xsl:param name="xrefstyle"/>
369 <xsl:param name="verbose"/>
370
371 <xsl:apply-templates select="." mode="object.xref.markup">
372 <xsl:with-param name="purpose" select="'xref'"/>
373 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
374 <xsl:with-param name="referrer" select="$referrer"/>
375 <xsl:with-param name="verbose" select="$verbose"/>
376 </xsl:apply-templates>
377</xsl:template>
378
379<xsl:template match="task" mode="xref-to">
380 <xsl:param name="referrer"/>
381 <xsl:param name="xrefstyle"/>
382 <xsl:param name="verbose"/>
383
384 <xsl:apply-templates select="." mode="object.xref.markup">
385 <xsl:with-param name="purpose" select="'xref'"/>
386 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
387 <xsl:with-param name="referrer" select="$referrer"/>
388 <xsl:with-param name="verbose" select="$verbose"/>
389 </xsl:apply-templates>
390</xsl:template>
391
392<xsl:template match="cmdsynopsis" mode="xref-to">
393 <xsl:param name="referrer"/>
394 <xsl:param name="xrefstyle"/>
395 <xsl:param name="verbose" select="1"/>
396
397 <xsl:apply-templates select="(.//command)[1]" mode="xref"/>
398</xsl:template>
399
400<xsl:template match="funcsynopsis" mode="xref-to">
401 <xsl:param name="referrer"/>
402 <xsl:param name="xrefstyle"/>
403 <xsl:param name="verbose" select="1"/>
404
405 <xsl:apply-templates select="(.//function)[1]" mode="xref"/>
406</xsl:template>
407
408<xsl:template match="dedication|acknowledgements|preface|chapter|appendix" mode="xref-to">
409 <xsl:param name="referrer"/>
410 <xsl:param name="xrefstyle"/>
411 <xsl:param name="verbose" select="1"/>
412
413 <xsl:apply-templates select="." mode="object.xref.markup">
414 <xsl:with-param name="purpose" select="'xref'"/>
415 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
416 <xsl:with-param name="referrer" select="$referrer"/>
417 <xsl:with-param name="verbose" select="$verbose"/>
418 </xsl:apply-templates>
419</xsl:template>
420
421<xsl:template match="bibliography" mode="xref-to">
422 <xsl:param name="referrer"/>
423 <xsl:param name="xrefstyle"/>
424 <xsl:param name="verbose" select="1"/>
425
426 <xsl:apply-templates select="." mode="object.xref.markup">
427 <xsl:with-param name="purpose" select="'xref'"/>
428 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
429 <xsl:with-param name="referrer" select="$referrer"/>
430 <xsl:with-param name="verbose" select="$verbose"/>
431 </xsl:apply-templates>
432</xsl:template>
433
434<xsl:template match="biblioentry|bibliomixed" mode="xref-to-prefix">
435 <xsl:text>[</xsl:text>
436</xsl:template>
437
438<xsl:template match="biblioentry|bibliomixed" mode="xref-to-suffix">
439 <xsl:text>]</xsl:text>
440</xsl:template>
441
442<xsl:template match="biblioentry|bibliomixed" mode="xref-to">
443 <xsl:param name="referrer"/>
444 <xsl:param name="xrefstyle"/>
445 <xsl:param name="verbose" select="1"/>
446
447 <!-- handles both biblioentry and bibliomixed -->
448 <xsl:choose>
449 <xsl:when test="string(.) = ''">
450 <xsl:variable name="bib" select="document($bibliography.collection,.)"/>
451 <xsl:variable name="id" select="(@id|@xml:id)[1]"/>
452 <xsl:variable name="entry" select="$bib/bibliography/
453 *[@id=$id or @xml:id=$id][1]"/>
454 <xsl:choose>
455 <xsl:when test="$entry">
456 <xsl:choose>
457 <xsl:when test="$bibliography.numbered != 0">
458 <xsl:number from="bibliography" count="biblioentry|bibliomixed"
459 level="any" format="1"/>
460 </xsl:when>
461 <xsl:when test="local-name($entry/*[1]) = 'abbrev'">
462 <xsl:apply-templates select="$entry/*[1]"/>
463 </xsl:when>
464 <xsl:otherwise>
465 <xsl:value-of select="(@id|@xml:id)[1]"/>
466 </xsl:otherwise>
467 </xsl:choose>
468 </xsl:when>
469 <xsl:otherwise>
470 <xsl:message>
471 <xsl:text>No bibliography entry: </xsl:text>
472 <xsl:value-of select="$id"/>
473 <xsl:text> found in </xsl:text>
474 <xsl:value-of select="$bibliography.collection"/>
475 </xsl:message>
476 <xsl:value-of select="(@id|@xml:id)[1]"/>
477 </xsl:otherwise>
478 </xsl:choose>
479 </xsl:when>
480 <xsl:otherwise>
481 <xsl:choose>
482 <xsl:when test="$bibliography.numbered != 0">
483 <xsl:number from="bibliography" count="biblioentry|bibliomixed"
484 level="any" format="1"/>
485 </xsl:when>
486 <xsl:when test="local-name(*[1]) = 'abbrev'">
487 <xsl:apply-templates select="*[1]"/>
488 </xsl:when>
489 <xsl:otherwise>
490 <xsl:value-of select="(@id|@xml:id)[1]"/>
491 </xsl:otherwise>
492 </xsl:choose>
493 </xsl:otherwise>
494 </xsl:choose>
495</xsl:template>
496
497<xsl:template match="glossary" mode="xref-to">
498 <xsl:param name="referrer"/>
499 <xsl:param name="xrefstyle"/>
500 <xsl:param name="verbose" select="1"/>
501
502 <xsl:apply-templates select="." mode="object.xref.markup">
503 <xsl:with-param name="purpose" select="'xref'"/>
504 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
505 <xsl:with-param name="referrer" select="$referrer"/>
506 <xsl:with-param name="verbose" select="$verbose"/>
507 </xsl:apply-templates>
508</xsl:template>
509
510<xsl:template match="glossentry" mode="xref-to">
511 <xsl:choose>
512 <xsl:when test="$glossentry.show.acronym = 'primary'">
513 <xsl:choose>
514 <xsl:when test="acronym|abbrev">
515 <xsl:apply-templates select="(acronym|abbrev)[1]"/>
516 </xsl:when>
517 <xsl:otherwise>
518 <xsl:apply-templates select="glossterm[1]" mode="xref-to"/>
519 </xsl:otherwise>
520 </xsl:choose>
521 </xsl:when>
522 <xsl:otherwise>
523 <xsl:apply-templates select="glossterm[1]" mode="xref-to"/>
524 </xsl:otherwise>
525 </xsl:choose>
526</xsl:template>
527
528<xsl:template match="glossterm|firstterm" mode="xref-to">
529 <xsl:apply-templates/>
530</xsl:template>
531
532<xsl:template match="index" mode="xref-to">
533 <xsl:param name="referrer"/>
534 <xsl:param name="xrefstyle"/>
535 <xsl:param name="verbose" select="1"/>
536
537 <xsl:apply-templates select="." mode="object.xref.markup">
538 <xsl:with-param name="purpose" select="'xref'"/>
539 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
540 <xsl:with-param name="referrer" select="$referrer"/>
541 <xsl:with-param name="verbose" select="$verbose"/>
542 </xsl:apply-templates>
543</xsl:template>
544
545<xsl:template match="listitem" mode="xref-to">
546 <xsl:param name="referrer"/>
547 <xsl:param name="xrefstyle"/>
548 <xsl:param name="verbose" select="1"/>
549
550 <xsl:apply-templates select="." mode="object.xref.markup">
551 <xsl:with-param name="purpose" select="'xref'"/>
552 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
553 <xsl:with-param name="referrer" select="$referrer"/>
554 <xsl:with-param name="verbose" select="$verbose"/>
555 </xsl:apply-templates>
556</xsl:template>
557
558<xsl:template match="section|simplesect
559 |sect1|sect2|sect3|sect4|sect5
560 |refsect1|refsect2|refsect3|refsection" mode="xref-to">
561 <xsl:param name="referrer"/>
562 <xsl:param name="xrefstyle"/>
563 <xsl:param name="verbose" select="1"/>
564
565 <xsl:apply-templates select="." mode="object.xref.markup">
566 <xsl:with-param name="purpose" select="'xref'"/>
567 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
568 <xsl:with-param name="referrer" select="$referrer"/>
569 <xsl:with-param name="verbose" select="$verbose"/>
570 </xsl:apply-templates>
571 <!-- What about "in Chapter X"? -->
572</xsl:template>
573
574<xsl:template match="topic" mode="xref-to">
575 <xsl:param name="referrer"/>
576 <xsl:param name="xrefstyle"/>
577 <xsl:param name="verbose" select="1"/>
578
579 <xsl:apply-templates select="." mode="object.xref.markup">
580 <xsl:with-param name="purpose" select="'xref'"/>
581 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
582 <xsl:with-param name="referrer" select="$referrer"/>
583 <xsl:with-param name="verbose" select="$verbose"/>
584 </xsl:apply-templates>
585</xsl:template>
586
587<xsl:template match="bridgehead" 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 <!-- What about "in Chapter X"? -->
599</xsl:template>
600
601<xsl:template match="qandaset" 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</xsl:template>
613
614<xsl:template match="qandadiv" mode="xref-to">
615 <xsl:param name="referrer"/>
616 <xsl:param name="xrefstyle"/>
617 <xsl:param name="verbose" select="1"/>
618
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>
625</xsl:template>
626
627<xsl:template match="qandaentry" mode="xref-to">
628 <xsl:param name="referrer"/>
629 <xsl:param name="xrefstyle"/>
630 <xsl:param name="verbose" select="1"/>
631
632 <xsl:apply-templates select="question[1]" mode="xref-to">
633 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
634 <xsl:with-param name="referrer" select="$referrer"/>
635 <xsl:with-param name="verbose" select="$verbose"/>
636 </xsl:apply-templates>
637</xsl:template>
638
639<xsl:template match="question|answer" mode="xref-to">
640 <xsl:param name="referrer"/>
641 <xsl:param name="xrefstyle"/>
642 <xsl:param name="verbose" select="1"/>
643
644 <xsl:choose>
645 <xsl:when test="string-length(label) != 0">
646 <xsl:apply-templates select="." mode="label.markup"/>
647 </xsl:when>
648 <xsl:otherwise>
649 <xsl:apply-templates select="." mode="object.xref.markup">
650 <xsl:with-param name="purpose" select="'xref'"/>
651 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
652 <xsl:with-param name="referrer" select="$referrer"/>
653 <xsl:with-param name="verbose" select="$verbose"/>
654 </xsl:apply-templates>
655 </xsl:otherwise>
656 </xsl:choose>
657</xsl:template>
658
659<xsl:template match="part|reference" mode="xref-to">
660 <xsl:param name="referrer"/>
661 <xsl:param name="xrefstyle"/>
662 <xsl:param name="verbose" select="1"/>
663
664 <xsl:apply-templates select="." mode="object.xref.markup">
665 <xsl:with-param name="purpose" select="'xref'"/>
666 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
667 <xsl:with-param name="referrer" select="$referrer"/>
668 <xsl:with-param name="verbose" select="$verbose"/>
669 </xsl:apply-templates>
670</xsl:template>
671
672<xsl:template match="refentry" mode="xref-to">
673 <xsl:param name="referrer"/>
674 <xsl:param name="xrefstyle"/>
675 <xsl:param name="verbose" select="1"/>
676
677 <xsl:choose>
678 <xsl:when test="refmeta/refentrytitle">
679 <xsl:apply-templates select="refmeta/refentrytitle"/>
680 </xsl:when>
681 <xsl:otherwise>
682 <xsl:apply-templates select="refnamediv/refname[1]"/>
683 </xsl:otherwise>
684 </xsl:choose>
685 <xsl:apply-templates select="refmeta/manvolnum"/>
686</xsl:template>
687
688<xsl:template match="refnamediv" mode="xref-to">
689 <xsl:param name="referrer"/>
690 <xsl:param name="xrefstyle"/>
691 <xsl:param name="verbose" select="1"/>
692
693 <xsl:apply-templates select="refname[1]" mode="xref-to">
694 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
695 <xsl:with-param name="referrer" select="$referrer"/>
696 <xsl:with-param name="verbose" select="$verbose"/>
697 </xsl:apply-templates>
698</xsl:template>
699
700<xsl:template match="refname" mode="xref-to">
701 <xsl:param name="referrer"/>
702 <xsl:param name="xrefstyle"/>
703 <xsl:param name="verbose" select="1"/>
704
705 <xsl:apply-templates mode="xref-to">
706 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
707 <xsl:with-param name="referrer" select="$referrer"/>
708 <xsl:with-param name="verbose" select="$verbose"/>
709 </xsl:apply-templates>
710</xsl:template>
711
712<xsl:template match="step" mode="xref-to">
713 <xsl:param name="referrer"/>
714 <xsl:param name="xrefstyle"/>
715 <xsl:param name="verbose" select="1"/>
716
717 <xsl:call-template name="gentext">
718 <xsl:with-param name="key" select="'Step'"/>
719 </xsl:call-template>
720 <xsl:text> </xsl:text>
721 <xsl:apply-templates select="." mode="number"/>
722</xsl:template>
723
724<xsl:template match="varlistentry" mode="xref-to">
725 <xsl:param name="referrer"/>
726 <xsl:param name="xrefstyle"/>
727 <xsl:param name="verbose" select="1"/>
728
729 <xsl:apply-templates select="term[1]" mode="xref-to">
730 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
731 <xsl:with-param name="referrer" select="$referrer"/>
732 <xsl:with-param name="verbose" select="$verbose"/>
733 </xsl:apply-templates>
734</xsl:template>
735
736<xsl:template match="varlistentry/term" mode="xref-to">
737 <xsl:param name="verbose" select="1"/>
738 <!-- to avoid the comma that will be generated if there are several terms -->
739 <xsl:apply-templates/>
740</xsl:template>
741
742<xsl:template match="co" mode="xref-to">
743 <xsl:param name="referrer"/>
744 <xsl:param name="xrefstyle"/>
745 <xsl:param name="verbose" select="1"/>
746
747 <xsl:apply-templates select="." mode="callout-bug"/>
748</xsl:template>
749
750<xsl:template match="area|areaset" mode="xref-to">
751 <xsl:param name="referrer"/>
752 <xsl:param name="xrefstyle"/>
753
754 <xsl:call-template name="callout-bug">
755 <xsl:with-param name="conum">
756 <xsl:apply-templates select="." mode="conumber"/>
757 </xsl:with-param>
758 </xsl:call-template>
759</xsl:template>
760
761<xsl:template match="book" mode="xref-to">
762 <xsl:param name="referrer"/>
763 <xsl:param name="xrefstyle"/>
764 <xsl:param name="verbose" select="1"/>
765
766 <xsl:apply-templates select="." mode="object.xref.markup">
767 <xsl:with-param name="purpose" select="'xref'"/>
768 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
769 <xsl:with-param name="referrer" select="$referrer"/>
770 <xsl:with-param name="verbose" select="$verbose"/>
771 </xsl:apply-templates>
772</xsl:template>
773
774<!-- These are elements for which no link text exists, so an xref to one
775 uses the xrefstyle attribute if specified, or if not it falls back
776 to the container element's link text -->
777<xsl:template match="para|phrase|simpara|anchor|quote" mode="xref-to">
778 <xsl:param name="referrer"/>
779 <xsl:param name="xrefstyle"/>
780 <xsl:param name="verbose"/>
781
782 <xsl:variable name="context" select="(ancestor::simplesect
783 |ancestor::section
784 |ancestor::sect1
785 |ancestor::sect2
786 |ancestor::sect3
787 |ancestor::sect4
788 |ancestor::sect5
789 |ancestor::topic
790 |ancestor::refsection
791 |ancestor::refsect1
792 |ancestor::refsect2
793 |ancestor::refsect3
794 |ancestor::chapter
795 |ancestor::appendix
796 |ancestor::preface
797 |ancestor::partintro
798 |ancestor::dedication
799 |ancestor::acknowledgements
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:choose>
809 <xsl:when test="$xrefstyle != ''">
810 <xsl:apply-templates select="." mode="object.xref.markup">
811 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
812 <xsl:with-param name="referrer" select="$referrer"/>
813 <xsl:with-param name="verbose" select="$verbose"/>
814 </xsl:apply-templates>
815 </xsl:when>
816 <xsl:otherwise>
817 <xsl:if test="$verbose != 0">
818 <xsl:message>
819 <xsl:text>WARNING: xref to &lt;</xsl:text>
820 <xsl:value-of select="local-name()"/>
821 <xsl:text> id="</xsl:text>
822 <xsl:value-of select="@id|@xml:id"/>
823 <xsl:text>"&gt; has no generated text. Trying its ancestor elements.</xsl:text>
824 </xsl:message>
825 </xsl:if>
826 <xsl:apply-templates select="$context" mode="xref-to">
827 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
828 <xsl:with-param name="referrer" select="$referrer"/>
829 <xsl:with-param name="verbose" select="$verbose"/>
830 </xsl:apply-templates>
831 </xsl:otherwise>
832 </xsl:choose>
833</xsl:template>
834
835<xsl:template match="indexterm" mode="xref-to">
836 <xsl:value-of select="primary"/>
837</xsl:template>
838
839<xsl:template match="primary|secondary|tertiary" mode="xref-to">
840 <xsl:value-of select="."/>
841</xsl:template>
842
843<!-- ==================================================================== -->
844
845<xsl:template match="link" name="link">
846 <xsl:param name="linkend" select="@linkend"/>
847 <xsl:param name="targets" select="key('id',$linkend)"/>
848 <xsl:param name="target" select="$targets[1]"/>
849
850 <xsl:variable name="xrefstyle">
851 <xsl:choose>
852 <xsl:when test="@role and not(@xrefstyle)
853 and $use.role.as.xrefstyle != 0">
854 <xsl:value-of select="@role"/>
855 </xsl:when>
856 <xsl:otherwise>
857 <xsl:value-of select="@xrefstyle"/>
858 </xsl:otherwise>
859 </xsl:choose>
860 </xsl:variable>
861
862 <xsl:variable name="content">
863 <fo:inline xsl:use-attribute-sets="xref.properties">
864 <xsl:choose>
865 <xsl:when test="count(child::node()) &gt; 0">
866 <!-- If it has content, use it -->
867 <xsl:apply-templates/>
868 </xsl:when>
869 <!-- look for an endterm -->
870 <xsl:when test="@endterm">
871 <xsl:variable name="etargets" select="key('id',@endterm)"/>
872 <xsl:variable name="etarget" select="$etargets[1]"/>
873 <xsl:choose>
874 <xsl:when test="count($etarget) = 0">
875 <xsl:message>
876 <xsl:value-of select="count($etargets)"/>
877 <xsl:text>Endterm points to nonexistent ID: </xsl:text>
878 <xsl:value-of select="@endterm"/>
879 </xsl:message>
880 <xsl:text>???</xsl:text>
881 </xsl:when>
882 <xsl:otherwise>
883 <xsl:apply-templates select="$etarget" mode="endterm"/>
884 </xsl:otherwise>
885 </xsl:choose>
886 </xsl:when>
887 <!-- Use the xlink:href if no other text -->
888 <xsl:when test="@xlink:href">
889 <fo:inline hyphenate="false">
890 <xsl:call-template name="hyphenate-url">
891 <xsl:with-param name="url" select="@xlink:href"/>
892 </xsl:call-template>
893 </fo:inline>
894 </xsl:when>
895 <xsl:otherwise>
896 <xsl:message>
897 <xsl:text>Link element has no content and no Endterm. </xsl:text>
898 <xsl:text>Nothing to show in the link to </xsl:text>
899 <xsl:value-of select="$target"/>
900 </xsl:message>
901 <xsl:text>???</xsl:text>
902 </xsl:otherwise>
903 </xsl:choose>
904 </fo:inline>
905 </xsl:variable>
906
907 <xsl:call-template name="simple.xlink">
908 <xsl:with-param name="node" select="."/>
909 <xsl:with-param name="linkend" select="$linkend"/>
910 <xsl:with-param name="content" select="$content"/>
911 </xsl:call-template>
912
913 <!-- Add standard page reference? -->
914 <xsl:choose>
915 <!-- page numbering on link only enabled for @linkend -->
916 <!-- There is no link element in DB5 with xlink:href -->
917 <xsl:when test="not($linkend)">
918 </xsl:when>
919 <!-- negative xrefstyle in instance turns it off -->
920 <xsl:when test="starts-with(normalize-space($xrefstyle), 'select:')
921 and contains($xrefstyle, 'nopage')">
922 </xsl:when>
923 <xsl:when test="(starts-with(normalize-space($xrefstyle), 'select:')
924 and $insert.link.page.number = 'maybe'
925 and (contains($xrefstyle, 'page')
926 or contains($xrefstyle, 'Page')))
927 or ( $insert.link.page.number = 'yes'
928 or $insert.link.page.number = '1')
929 or local-name($target) = 'para'">
930 <xsl:apply-templates select="$target" mode="page.citation">
931 <xsl:with-param name="id" select="$linkend"/>
932 </xsl:apply-templates>
933 </xsl:when>
934 </xsl:choose>
935</xsl:template>
936
937<xsl:template match="ulink" name="ulink">
938 <xsl:param name="url" select="@url"/>
939
940 <xsl:variable name ="ulink.url">
941 <xsl:call-template name="fo-external-image">
942 <xsl:with-param name="filename" select="$url"/>
943 </xsl:call-template>
944 </xsl:variable>
945
946 <fo:basic-link xsl:use-attribute-sets="xref.properties"
947 external-destination="{$ulink.url}">
948 <xsl:choose>
949 <xsl:when test="count(child::node())=0 or (string(.) = $url)">
950 <fo:inline hyphenate="false">
951 <xsl:call-template name="hyphenate-url">
952 <xsl:with-param name="url" select="$url"/>
953 </xsl:call-template>
954 </fo:inline>
955 </xsl:when>
956 <xsl:otherwise>
957 <xsl:apply-templates/>
958 </xsl:otherwise>
959 </xsl:choose>
960 </fo:basic-link>
961 <!-- * Call the template for determining whether the URL for this -->
962 <!-- * hyperlink is displayed, and how to display it (either inline or -->
963 <!-- * as a numbered footnote). -->
964 <xsl:call-template name="hyperlink.url.display">
965 <xsl:with-param name="url" select="$url"/>
966 <xsl:with-param name="ulink.url" select="$ulink.url"/>
967 </xsl:call-template>
968</xsl:template>
969
970<xsl:template name="hyperlink.url.display">
971 <!-- * This template is called for all external hyperlinks (ulinks and -->
972 <!-- * for all simple xlinks); it determines whether the URL for the -->
973 <!-- * hyperlink is displayed, and how to display it (either inline or -->
974 <!-- * as a numbered footnote). -->
975 <xsl:param name="url"/>
976 <xsl:param name="ulink.url">
977 <!-- * ulink.url is just the value of the URL wrapped in 'url(...)' -->
978 <xsl:call-template name="fo-external-image">
979 <xsl:with-param name="filename" select="$url"/>
980 </xsl:call-template>
981 </xsl:param>
982
983 <xsl:if test="count(child::node()) != 0
984 and string(.) != $url
985 and $ulink.show != 0">
986 <!-- * Display the URL for this hyperlink only if it is non-empty, -->
987 <!-- * and the value of its content is not a URL that is the same as -->
988 <!-- * URL it links to, and if ulink.show is non-zero. -->
989 <xsl:choose>
990 <xsl:when test="$ulink.footnotes != 0 and not(ancestor::footnote) and not(ancestor::*[@floatstyle='before'])">
991 <!-- * ulink.show and ulink.footnote are both non-zero; that -->
992 <!-- * means we display the URL as a footnote (instead of inline) -->
993 <fo:footnote>
994 <xsl:call-template name="ulink.footnote.number"/>
995 <fo:footnote-body xsl:use-attribute-sets="footnote.properties">
996 <fo:block>
997 <xsl:call-template name="ulink.footnote.number"/>
998 <xsl:text> </xsl:text>
999 <fo:basic-link external-destination="{$ulink.url}">
1000 <xsl:value-of select="$url"/>
1001 </fo:basic-link>
1002 </fo:block>
1003 </fo:footnote-body>
1004 </fo:footnote>
1005 </xsl:when>
1006 <xsl:otherwise>
1007 <!-- * ulink.show is non-zero, but ulink.footnote is not; that -->
1008 <!-- * means we display the URL inline -->
1009 <fo:inline hyphenate="false">
1010 <!-- * put square brackets around the URL -->
1011 <xsl:text> [</xsl:text>
1012 <fo:basic-link external-destination="{$ulink.url}">
1013 <xsl:call-template name="hyphenate-url">
1014 <xsl:with-param name="url" select="$url"/>
1015 </xsl:call-template>
1016 </fo:basic-link>
1017 <xsl:text>]</xsl:text>
1018 </fo:inline>
1019 </xsl:otherwise>
1020 </xsl:choose>
1021 </xsl:if>
1022
1023</xsl:template>
1024
1025<xsl:template name="ulink.footnote.number">
1026 <fo:inline xsl:use-attribute-sets="footnote.mark.properties">
1027 <xsl:choose>
1028 <xsl:when test="$fop.extensions != 0">
1029 <xsl:attribute name="vertical-align">super</xsl:attribute>
1030 </xsl:when>
1031 <xsl:otherwise>
1032 <xsl:attribute name="baseline-shift">super</xsl:attribute>
1033 </xsl:otherwise>
1034 </xsl:choose>
1035 <xsl:variable name="fnum">
1036 <!-- * Determine the footnote number to display for this hyperlink, -->
1037 <!-- * by counting all foonotes, ulinks, and any elements that have -->
1038 <!-- * an xlink:href attribute that meets the following criteria: -->
1039 <!-- * -->
1040 <!-- * - the content of the element is not a URI that is the same -->
1041 <!-- * URI as the value of the href attribute -->
1042 <!-- * - the href attribute is not an internal ID reference (does -->
1043 <!-- * not start with a hash sign) -->
1044 <!-- * - the href is not part of an olink reference (the element -->
1045 <!-- * - does not have an xlink:role attribute that indicates it is -->
1046 <!-- * an olink, and the href does not contain a hash sign) -->
1047 <!-- * - the element either has no xlink:type attribute or has -->
1048 <!-- * an xlink:type attribute whose value is 'simple' -->
1049 <!-- FIXME: list in @from is probably not complete -->
1050 <xsl:number level="any"
1051 from="chapter|appendix|preface|article|refentry|bibliography[not(parent::article)]"
1052 count="footnote[not(@label)][not(ancestor::tgroup)]
1053 |ulink[node()][@url != .][not(ancestor::footnote)]
1054 |*[node()][@xlink:href][not(@xlink:href = .)][not(starts-with(@xlink:href,'#'))]
1055 [not(contains(@xlink:href,'#') and @xlink:role = $xolink.role)]
1056 [not(@xlink:type) or @xlink:type='simple']
1057 [not(ancestor::footnote)]"
1058 format="1"/>
1059 </xsl:variable>
1060 <xsl:choose>
1061 <xsl:when test="string-length($footnote.number.symbols) &gt;= $fnum">
1062 <xsl:value-of select="substring($footnote.number.symbols, $fnum, 1)"/>
1063 </xsl:when>
1064 <xsl:otherwise>
1065 <xsl:number value="$fnum" format="{$footnote.number.format}"/>
1066 </xsl:otherwise>
1067 </xsl:choose>
1068 </fo:inline>
1069</xsl:template>
1070
1071<xsl:template name="hyphenate-url">
1072 <xsl:param name="url" select="''"/>
1073 <xsl:choose>
1074 <xsl:when test="$ulink.hyphenate = ''">
1075 <xsl:value-of select="$url"/>
1076 </xsl:when>
1077 <xsl:when test="string-length($url) &gt; 1">
1078 <xsl:variable name="char" select="substring($url, 1, 1)"/>
1079 <xsl:value-of select="$char"/>
1080 <xsl:if test="contains($ulink.hyphenate.chars, $char)">
1081 <!-- Do not hyphen in-between // -->
1082 <xsl:if test="not($char = '/' and substring($url,2,1) = '/')">
1083 <xsl:copy-of select="$ulink.hyphenate"/>
1084 </xsl:if>
1085 </xsl:if>
1086 <!-- recurse to the next character -->
1087 <xsl:call-template name="hyphenate-url">
1088 <xsl:with-param name="url" select="substring($url, 2)"/>
1089 </xsl:call-template>
1090 </xsl:when>
1091 <xsl:otherwise>
1092 <xsl:value-of select="$url"/>
1093 </xsl:otherwise>
1094 </xsl:choose>
1095</xsl:template>
1096
1097<xsl:template match="olink" name="olink">
1098 <!-- olink content may be passed in from xlink olink -->
1099 <xsl:param name="content" select="NOTANELEMENT"/>
1100
1101 <xsl:choose>
1102 <!-- olinks resolved by stylesheet and target database -->
1103 <xsl:when test="@targetdoc or @targetptr or
1104 (@xlink:role=$xolink.role and
1105 contains(@xlink:href, '#') )" >
1106
1107 <xsl:variable name="targetdoc.att">
1108 <xsl:choose>
1109 <xsl:when test="@targetdoc != ''">
1110 <xsl:value-of select="@targetdoc"/>
1111 </xsl:when>
1112 <xsl:when test="@xlink:role=$xolink.role and
1113 contains(@xlink:href, '#')" >
1114 <xsl:value-of select="substring-before(@xlink:href, '#')"/>
1115 </xsl:when>
1116 </xsl:choose>
1117 </xsl:variable>
1118
1119 <xsl:variable name="targetptr.att">
1120 <xsl:choose>
1121 <xsl:when test="@targetptr != ''">
1122 <xsl:value-of select="@targetptr"/>
1123 </xsl:when>
1124 <xsl:when test="@xlink:role=$xolink.role and
1125 contains(@xlink:href, '#')" >
1126 <xsl:value-of select="substring-after(@xlink:href, '#')"/>
1127 </xsl:when>
1128 </xsl:choose>
1129 </xsl:variable>
1130
1131 <xsl:variable name="olink.lang">
1132 <xsl:call-template name="l10n.language">
1133 <xsl:with-param name="xref-context" select="true()"/>
1134 </xsl:call-template>
1135 </xsl:variable>
1136
1137 <xsl:variable name="target.database.filename">
1138 <xsl:call-template name="select.target.database">
1139 <xsl:with-param name="targetdoc.att" select="$targetdoc.att"/>
1140 <xsl:with-param name="targetptr.att" select="$targetptr.att"/>
1141 <xsl:with-param name="olink.lang" select="$olink.lang"/>
1142 </xsl:call-template>
1143 </xsl:variable>
1144
1145 <xsl:variable name="target.database"
1146 select="document($target.database.filename, /)"/>
1147
1148 <xsl:if test="$olink.debug != 0">
1149 <xsl:message>
1150 <xsl:text>Olink debug: root element of target.database is '</xsl:text>
1151 <xsl:value-of select="local-name($target.database/*[1])"/>
1152 <xsl:text>'.</xsl:text>
1153 </xsl:message>
1154 </xsl:if>
1155
1156 <xsl:variable name="olink.key">
1157 <xsl:call-template name="select.olink.key">
1158 <xsl:with-param name="targetdoc.att" select="$targetdoc.att"/>
1159 <xsl:with-param name="targetptr.att" select="$targetptr.att"/>
1160 <xsl:with-param name="olink.lang" select="$olink.lang"/>
1161 <xsl:with-param name="target.database" select="$target.database"/>
1162 </xsl:call-template>
1163 </xsl:variable>
1164
1165 <xsl:if test="string-length($olink.key) = 0">
1166 <xsl:message>
1167 <xsl:text>Error: unresolved olink: </xsl:text>
1168 <xsl:text>targetdoc/targetptr = '</xsl:text>
1169 <xsl:value-of select="$targetdoc.att"/>
1170 <xsl:text>/</xsl:text>
1171 <xsl:value-of select="$targetptr.att"/>
1172 <xsl:text>'.</xsl:text>
1173 </xsl:message>
1174 </xsl:if>
1175
1176 <xsl:variable name="href">
1177 <xsl:call-template name="make.olink.href">
1178 <xsl:with-param name="olink.key" select="$olink.key"/>
1179 <xsl:with-param name="target.database" select="$target.database"/>
1180 </xsl:call-template>
1181 </xsl:variable>
1182
1183 <!-- Olink that points to internal id can be a link -->
1184 <xsl:variable name="linkend">
1185 <xsl:call-template name="olink.as.linkend">
1186 <xsl:with-param name="olink.key" select="$olink.key"/>
1187 <xsl:with-param name="olink.lang" select="$olink.lang"/>
1188 <xsl:with-param name="target.database" select="$target.database"/>
1189 </xsl:call-template>
1190 </xsl:variable>
1191
1192 <xsl:variable name="hottext">
1193 <xsl:choose>
1194 <xsl:when test="string-length($content) != 0">
1195 <xsl:copy-of select="$content"/>
1196 </xsl:when>
1197 <xsl:otherwise>
1198 <xsl:call-template name="olink.hottext">
1199 <xsl:with-param name="olink.key" select="$olink.key"/>
1200 <xsl:with-param name="olink.lang" select="$olink.lang"/>
1201 <xsl:with-param name="target.database" select="$target.database"/>
1202 </xsl:call-template>
1203 </xsl:otherwise>
1204 </xsl:choose>
1205 </xsl:variable>
1206
1207 <xsl:variable name="olink.docname.citation">
1208 <xsl:call-template name="olink.document.citation">
1209 <xsl:with-param name="olink.key" select="$olink.key"/>
1210 <xsl:with-param name="target.database" select="$target.database"/>
1211 <xsl:with-param name="olink.lang" select="$olink.lang"/>
1212 </xsl:call-template>
1213 </xsl:variable>
1214
1215 <xsl:variable name="olink.page.citation">
1216 <xsl:call-template name="olink.page.citation">
1217 <xsl:with-param name="olink.key" select="$olink.key"/>
1218 <xsl:with-param name="target.database" select="$target.database"/>
1219 <xsl:with-param name="olink.lang" select="$olink.lang"/>
1220 <xsl:with-param name="linkend" select="$linkend"/>
1221 </xsl:call-template>
1222 </xsl:variable>
1223
1224 <xsl:choose>
1225 <xsl:when test="$linkend != ''">
1226 <fo:basic-link internal-destination="{$linkend}"
1227 xsl:use-attribute-sets="xref.properties">
1228 <xsl:call-template name="anchor"/>
1229 <xsl:copy-of select="$hottext"/>
1230 <xsl:copy-of select="$olink.page.citation"/>
1231 </fo:basic-link>
1232 </xsl:when>
1233 <xsl:when test="$href != ''">
1234 <xsl:choose>
1235 <xsl:when test="$fop1.extensions != 0">
1236 <xsl:variable name="mybeg" select="substring-before($href,'#')"/>
1237 <xsl:variable name="myend" select="substring-after($href,'#')"/>
1238 <fo:basic-link external-destination="url({concat($mybeg,'#dest=',$myend)})"
1239 xsl:use-attribute-sets="olink.properties">
1240 <xsl:copy-of select="$hottext"/>
1241 </fo:basic-link>
1242 <xsl:copy-of select="$olink.page.citation"/>
1243 <xsl:copy-of select="$olink.docname.citation"/>
1244 </xsl:when>
1245 <xsl:when test="$xep.extensions != 0">
1246 <fo:basic-link external-destination="url({$href})"
1247 xsl:use-attribute-sets="olink.properties">
1248 <xsl:call-template name="anchor"/>
1249 <xsl:copy-of select="$hottext"/>
1250 </fo:basic-link>
1251 <xsl:copy-of select="$olink.page.citation"/>
1252 <xsl:copy-of select="$olink.docname.citation"/>
1253 </xsl:when>
1254 <xsl:when test="$axf.extensions != 0">
1255 <fo:basic-link external-destination="{$href}"
1256 xsl:use-attribute-sets="olink.properties">
1257 <xsl:copy-of select="$hottext"/>
1258 </fo:basic-link>
1259 <xsl:copy-of select="$olink.page.citation"/>
1260 <xsl:copy-of select="$olink.docname.citation"/>
1261 </xsl:when>
1262 <xsl:otherwise>
1263 <fo:basic-link external-destination="{$href}"
1264 xsl:use-attribute-sets="olink.properties">
1265 <xsl:copy-of select="$hottext"/>
1266 </fo:basic-link>
1267 <xsl:copy-of select="$olink.page.citation"/>
1268 <xsl:copy-of select="$olink.docname.citation"/>
1269 </xsl:otherwise>
1270 </xsl:choose>
1271 </xsl:when>
1272 <xsl:otherwise>
1273 <xsl:copy-of select="$hottext"/>
1274 <xsl:copy-of select="$olink.page.citation"/>
1275 <xsl:copy-of select="$olink.docname.citation"/>
1276 </xsl:otherwise>
1277 </xsl:choose>
1278 </xsl:when>
1279
1280 <!-- olink never implemented in FO for old olink entity syntax -->
1281 <xsl:otherwise>
1282 <xsl:apply-templates/>
1283 </xsl:otherwise>
1284 </xsl:choose>
1285</xsl:template>
1286
1287<xsl:template match="*" mode="insert.olink.docname.markup">
1288 <xsl:param name="docname" select="''"/>
1289
1290 <fo:inline font-style="italic">
1291 <xsl:value-of select="$docname"/>
1292 </fo:inline>
1293
1294</xsl:template>
1295
1296<!-- This prevents error message when processing olinks with xrefstyle -->
1297<xsl:template match="olink" mode="object.xref.template"/>
1298
1299
1300<xsl:template name="olink.as.linkend">
1301 <xsl:param name="olink.key" select="''"/>
1302 <xsl:param name="olink.lang" select="''"/>
1303 <xsl:param name="target.database" select="NotANode"/>
1304
1305 <xsl:variable name="targetdoc">
1306 <xsl:value-of select="substring-before($olink.key, '/')"/>
1307 </xsl:variable>
1308
1309 <xsl:variable name="targetptr">
1310 <xsl:value-of
1311 select="substring-before(substring-after($olink.key, '/'), '/')"/>
1312 </xsl:variable>
1313
1314 <xsl:variable name="target.lang">
1315 <xsl:variable name="candidate">
1316 <xsl:for-each select="$target.database" >
1317 <xsl:value-of
1318 select="key('targetptr-key', $olink.key)[1]/@lang" />
1319 </xsl:for-each>
1320 </xsl:variable>
1321 <xsl:choose>
1322 <xsl:when test="$candidate != ''">
1323 <xsl:value-of select="$candidate"/>
1324 </xsl:when>
1325 <xsl:otherwise>
1326 <xsl:value-of select="$olink.lang"/>
1327 </xsl:otherwise>
1328 </xsl:choose>
1329 </xsl:variable>
1330
1331 <xsl:if test="$current.docid = $targetdoc and
1332 $olink.lang = $target.lang">
1333 <xsl:variable name="targets" select="key('id',$targetptr)"/>
1334 <xsl:variable name="target" select="$targets[1]"/>
1335 <xsl:if test="$target">
1336 <xsl:value-of select="$targetptr"/>
1337 </xsl:if>
1338 </xsl:if>
1339
1340</xsl:template>
1341
1342
1343<!-- ==================================================================== -->
1344
1345<xsl:template name="title.xref">
1346 <xsl:param name="target" select="."/>
1347 <xsl:choose>
1348 <xsl:when test="local-name($target) = 'figure'
1349 or local-name($target) = 'example'
1350 or local-name($target) = 'equation'
1351 or local-name($target) = 'table'
1352 or local-name($target) = 'dedication'
1353 or local-name($target) = 'acknowledgements'
1354 or local-name($target) = 'preface'
1355 or local-name($target) = 'bibliography'
1356 or local-name($target) = 'glossary'
1357 or local-name($target) = 'index'
1358 or local-name($target) = 'setindex'
1359 or local-name($target) = 'colophon'">
1360 <xsl:call-template name="gentext.startquote"/>
1361 <xsl:apply-templates select="$target" mode="title.markup"/>
1362 <xsl:call-template name="gentext.endquote"/>
1363 </xsl:when>
1364 <xsl:otherwise>
1365 <fo:inline font-style="italic">
1366 <xsl:apply-templates select="$target" mode="title.markup"/>
1367 </fo:inline>
1368 </xsl:otherwise>
1369 </xsl:choose>
1370</xsl:template>
1371
1372<xsl:template name="number.xref">
1373 <xsl:param name="target" select="."/>
1374 <xsl:apply-templates select="$target" mode="label.markup"/>
1375</xsl:template>
1376
1377<!-- ==================================================================== -->
1378
1379<xsl:template name="xref.xreflabel">
1380 <!-- called to process an xreflabel...you might use this to make -->
1381 <!-- xreflabels come out in the right font for different targets, -->
1382 <!-- for example. -->
1383 <xsl:param name="target" select="."/>
1384 <xsl:value-of select="$target/@xreflabel"/>
1385</xsl:template>
1386
1387<!-- ==================================================================== -->
1388
1389<xsl:template match="title" mode="xref">
1390 <xsl:apply-templates/>
1391</xsl:template>
1392
1393<xsl:template match="command" mode="xref">
1394 <xsl:call-template name="inline.boldseq"/>
1395</xsl:template>
1396
1397<xsl:template match="function" mode="xref">
1398 <xsl:call-template name="inline.monoseq"/>
1399</xsl:template>
1400
1401<xsl:template match="*" mode="page.citation">
1402 <xsl:param name="id" select="'???'"/>
1403
1404 <fo:basic-link internal-destination="{$id}"
1405 xsl:use-attribute-sets="xref.properties">
1406 <fo:inline keep-together.within-line="always">
1407 <xsl:call-template name="substitute-markup">
1408 <xsl:with-param name="template">
1409 <xsl:call-template name="gentext.template">
1410 <xsl:with-param name="name" select="'page.citation'"/>
1411 <xsl:with-param name="context" select="'xref'"/>
1412 </xsl:call-template>
1413 </xsl:with-param>
1414 </xsl:call-template>
1415 </fo:inline>
1416 </fo:basic-link>
1417</xsl:template>
1418
1419<xsl:template match="*" mode="pagenumber.markup">
1420 <xsl:variable name="id">
1421 <xsl:call-template name="object.id"/>
1422 </xsl:variable>
1423 <fo:page-number-citation ref-id="{$id}"/>
1424</xsl:template>
1425
1426<!-- ==================================================================== -->
1427
1428<xsl:template match="*" mode="insert.title.markup">
1429 <xsl:param name="purpose"/>
1430 <xsl:param name="xrefstyle"/>
1431 <xsl:param name="title"/>
1432
1433 <xsl:choose>
1434 <xsl:when test="$purpose = 'xref'">
1435 <xsl:copy-of select="$title"/>
1436 </xsl:when>
1437 <xsl:otherwise>
1438 <xsl:copy-of select="$title"/>
1439 </xsl:otherwise>
1440 </xsl:choose>
1441</xsl:template>
1442
1443<xsl:template match="chapter|appendix" mode="insert.title.markup">
1444 <xsl:param name="purpose"/>
1445 <xsl:param name="xrefstyle"/>
1446 <xsl:param name="title"/>
1447
1448 <xsl:choose>
1449 <xsl:when test="$purpose = 'xref'">
1450 <fo:inline font-style="italic">
1451 <xsl:copy-of select="$title"/>
1452 </fo:inline>
1453 </xsl:when>
1454 <xsl:otherwise>
1455 <xsl:copy-of select="$title"/>
1456 </xsl:otherwise>
1457 </xsl:choose>
1458</xsl:template>
1459
1460<xsl:template match="*" mode="insert.subtitle.markup">
1461 <xsl:param name="purpose"/>
1462 <xsl:param name="xrefstyle"/>
1463 <xsl:param name="subtitle"/>
1464
1465 <xsl:copy-of select="$subtitle"/>
1466</xsl:template>
1467
1468<xsl:template match="*" mode="insert.label.markup">
1469 <xsl:param name="purpose"/>
1470 <xsl:param name="xrefstyle"/>
1471 <xsl:param name="label"/>
1472
1473 <xsl:copy-of select="$label"/>
1474</xsl:template>
1475
1476<xsl:template match="*" mode="insert.pagenumber.markup">
1477 <xsl:param name="purpose"/>
1478 <xsl:param name="xrefstyle"/>
1479 <xsl:param name="pagenumber"/>
1480
1481 <xsl:copy-of select="$pagenumber"/>
1482</xsl:template>
1483
1484<xsl:template match="*" mode="insert.direction.markup">
1485 <xsl:param name="purpose"/>
1486 <xsl:param name="xrefstyle"/>
1487 <xsl:param name="direction"/>
1488
1489 <xsl:copy-of select="$direction"/>
1490</xsl:template>
1491
1492<xsl:template match="olink" mode="pagenumber.markup">
1493 <!-- Local olinks can use page-citation -->
1494 <xsl:variable name="targetdoc.att" select="@targetdoc"/>
1495 <xsl:variable name="targetptr.att" select="@targetptr"/>
1496
1497 <xsl:variable name="olink.lang">
1498 <xsl:call-template name="l10n.language">
1499 <xsl:with-param name="xref-context" select="true()"/>
1500 </xsl:call-template>
1501 </xsl:variable>
1502
1503 <xsl:variable name="target.database.filename">
1504 <xsl:call-template name="select.target.database">
1505 <xsl:with-param name="targetdoc.att" select="$targetdoc.att"/>
1506 <xsl:with-param name="targetptr.att" select="$targetptr.att"/>
1507 <xsl:with-param name="olink.lang" select="$olink.lang"/>
1508 </xsl:call-template>
1509 </xsl:variable>
1510
1511 <xsl:variable name="target.database"
1512 select="document($target.database.filename, /)"/>
1513
1514 <xsl:if test="$olink.debug != 0">
1515 <xsl:message>
1516 <xsl:text>Olink debug: root element of target.database is '</xsl:text>
1517 <xsl:value-of select="local-name($target.database/*[1])"/>
1518 <xsl:text>'.</xsl:text>
1519 </xsl:message>
1520 </xsl:if>
1521
1522 <xsl:variable name="olink.key">
1523 <xsl:call-template name="select.olink.key">
1524 <xsl:with-param name="targetdoc.att" select="$targetdoc.att"/>
1525 <xsl:with-param name="targetptr.att" select="$targetptr.att"/>
1526 <xsl:with-param name="olink.lang" select="$olink.lang"/>
1527 <xsl:with-param name="target.database" select="$target.database"/>
1528 </xsl:call-template>
1529 </xsl:variable>
1530
1531 <!-- Olink that points to internal id can be a link -->
1532 <xsl:variable name="linkend">
1533 <xsl:call-template name="olink.as.linkend">
1534 <xsl:with-param name="olink.key" select="$olink.key"/>
1535 <xsl:with-param name="olink.lang" select="$olink.lang"/>
1536 <xsl:with-param name="target.database" select="$target.database"/>
1537 </xsl:call-template>
1538 </xsl:variable>
1539
1540 <xsl:choose>
1541 <xsl:when test="$linkend != ''">
1542 <fo:page-number-citation ref-id="{$linkend}"/>
1543 </xsl:when>
1544 <xsl:otherwise>
1545 <xsl:message>
1546 <xsl:text>Olink error: no page number linkend for local olink '</xsl:text>
1547 <xsl:value-of select="$olink.key"/>
1548 <xsl:text>'</xsl:text>
1549 </xsl:message>
1550 </xsl:otherwise>
1551 </xsl:choose>
1552</xsl:template>
1553
1554</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.