Debian Codegraph @

xsl/common/gentext.xsl

raw
1 <?xml version='1.0'?>
2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3 xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"
4 exclude-result-prefixes="doc"
5 version='1.0'>
6
7 <!-- ********************************************************************
8 $Id
9 ********************************************************************
10
11 This file is part of the XSL DocBook Stylesheet distribution.
12 See ../README or http://docbook.sf.net/release/xsl/current/ for
13 copyright and other information.
14
15 ******************************************************************** -->
16
17 <!-- ==================================================================== -->
18
19
20 <xsl:template match="*" mode="object.title.template">
21 <xsl:call-template name="gentext.template">
22 <xsl:with-param name="context" select="'title'"/>
23 <xsl:with-param name="name">
24 <xsl:call-template name="xpath.location"/>
25 </xsl:with-param>
26 </xsl:call-template>
27 </xsl:template>
28
29 <xsl:template match="chapter" mode="object.title.template">
30 <xsl:choose>
31 <xsl:when test="string($chapter.autolabel) != 0">
32 <xsl:call-template name="gentext.template">
33 <xsl:with-param name="context" select="'title-numbered'"/>
34 <xsl:with-param name="name">
35 <xsl:call-template name="xpath.location"/>
36 </xsl:with-param>
37 </xsl:call-template>
38 </xsl:when>
39 <xsl:otherwise>
40 <xsl:call-template name="gentext.template">
41 <xsl:with-param name="context" select="'title-unnumbered'"/>
42 <xsl:with-param name="name">
43 <xsl:call-template name="xpath.location"/>
44 </xsl:with-param>
45 </xsl:call-template>
46 </xsl:otherwise>
47 </xsl:choose>
48 </xsl:template>
49
50 <xsl:template match="appendix" mode="object.title.template">
51 <xsl:choose>
52 <xsl:when test="string($appendix.autolabel) != 0">
53 <xsl:call-template name="gentext.template">
54 <xsl:with-param name="context" select="'title-numbered'"/>
55 <xsl:with-param name="name">
56 <xsl:call-template name="xpath.location"/>
57 </xsl:with-param>
58 </xsl:call-template>
59 </xsl:when>
60 <xsl:otherwise>
61 <xsl:call-template name="gentext.template">
62 <xsl:with-param name="context" select="'title-unnumbered'"/>
63 <xsl:with-param name="name">
64 <xsl:call-template name="xpath.location"/>
65 </xsl:with-param>
66 </xsl:call-template>
67 </xsl:otherwise>
68 </xsl:choose>
69 </xsl:template>
70
71 <xsl:template match="part" mode="object.title.template">
72 <xsl:choose>
73 <xsl:when test="string($part.autolabel) != 0">
74 <xsl:call-template name="gentext.template">
75 <xsl:with-param name="context" select="'title-numbered'"/>
76 <xsl:with-param name="name">
77 <xsl:call-template name="xpath.location"/>
78 </xsl:with-param>
79 </xsl:call-template>
80 </xsl:when>
81 <xsl:otherwise>
82 <xsl:call-template name="gentext.template">
83 <xsl:with-param name="context" select="'title-unnumbered'"/>
84 <xsl:with-param name="name">
85 <xsl:call-template name="xpath.location"/>
86 </xsl:with-param>
87 </xsl:call-template>
88 </xsl:otherwise>
89 </xsl:choose>
90 </xsl:template>
91
92 <xsl:template match="section|sect1|sect2|sect3|sect4|sect5|simplesect
93 |bridgehead"
94 mode="object.title.template">
95 <xsl:variable name="is.numbered">
96 <xsl:call-template name="label.this.section"/>
97 </xsl:variable>
98 <xsl:choose>
99 <xsl:when test="$is.numbered != 0">
100 <xsl:call-template name="gentext.template">
101 <xsl:with-param name="context" select="'title-numbered'"/>
102 <xsl:with-param name="name">
103 <xsl:call-template name="xpath.location"/>
104 </xsl:with-param>
105 </xsl:call-template>
106 </xsl:when>
107 <xsl:otherwise>
108 <xsl:call-template name="gentext.template">
109 <xsl:with-param name="context" select="'title-unnumbered'"/>
110 <xsl:with-param name="name">
111 <xsl:call-template name="xpath.location"/>
112 </xsl:with-param>
113 </xsl:call-template>
114 </xsl:otherwise>
115 </xsl:choose>
116 </xsl:template>
117
118 <xsl:template match="procedure" mode="object.title.template">
119 <xsl:choose>
120 <xsl:when test="$formal.procedures != 0 and title">
121 <xsl:call-template name="gentext.template">
122 <xsl:with-param name="context" select="'title'"/>
123 <xsl:with-param name="name">
124 <xsl:call-template name="xpath.location"/>
125 <xsl:text>.formal</xsl:text>
126 </xsl:with-param>
127 </xsl:call-template>
128 </xsl:when>
129 <xsl:otherwise>
130 <xsl:call-template name="gentext.template">
131 <xsl:with-param name="context" select="'title'"/>
132 <xsl:with-param name="name">
133 <xsl:call-template name="xpath.location"/>
134 </xsl:with-param>
135 </xsl:call-template>
136 </xsl:otherwise>
137 </xsl:choose>
138 </xsl:template>
139
140 <!-- ============================================================ -->
141
142 <xsl:template match="*" mode="object.subtitle.template">
143 <xsl:call-template name="gentext.template">
144 <xsl:with-param name="context" select="'subtitle'"/>
145 <xsl:with-param name="name">
146 <xsl:call-template name="xpath.location"/>
147 </xsl:with-param>
148 </xsl:call-template>
149 </xsl:template>
150
151 <!-- ============================================================ -->
152
153 <xsl:template match="*" mode="is.autonumber">
154 <xsl:value-of select="'0'"/>
155 </xsl:template>
156
157 <xsl:template match="section|sect1|sect2|sect3|sect4|sect5"
158 mode="is.autonumber">
159 <xsl:call-template name="label.this.section"/>
160 </xsl:template>
161
162 <xsl:template match="figure|example|table|equation" mode="is.autonumber">
163 <xsl:value-of select="'1'"/>
164 </xsl:template>
165
166 <xsl:template match="appendix" mode="is.autonumber">
167 <xsl:value-of select="$appendix.autolabel"/>
168 </xsl:template>
169
170 <xsl:template match="chapter" mode="is.autonumber">
171 <xsl:value-of select="$chapter.autolabel"/>
172 </xsl:template>
173
174 <xsl:template match="part" mode="is.autonumber">
175 <xsl:value-of select="$part.autolabel"/>
176 </xsl:template>
177
178 <xsl:template match="preface" mode="is.autonumber">
179 <xsl:value-of select="$preface.autolabel"/>
180 </xsl:template>
181
182 <xsl:template match="question|answer" mode="is.autonumber">
183 <xsl:choose>
184 <xsl:when test="$qanda.defaultlabel = 'number'
185 and not(label)">
186 <xsl:value-of select="'1'"/>
187 </xsl:when>
188 <xsl:otherwise>
189 <xsl:value-of select="'0'"/>
190 </xsl:otherwise>
191 </xsl:choose>
192 </xsl:template>
193
194 <xsl:template match="qandadiv" mode="is.autonumber">
195 <xsl:value-of select="$qandadiv.autolabel"/>
196 </xsl:template>
197
198 <xsl:template match="bridgehead" mode="is.autonumber">
199 <xsl:value-of select="$section.autolabel"/>
200 </xsl:template>
201
202 <xsl:template match="*" mode="object.xref.template">
203 <xsl:param name="purpose"/>
204 <xsl:param name="xrefstyle"/>
205 <xsl:param name="referrer"/>
206
207 <!-- Is autonumbering on? -->
208 <xsl:variable name="autonumber">
209 <xsl:apply-templates select="." mode="is.autonumber"/>
210 </xsl:variable>
211
212 <xsl:variable name="number-and-title-template">
213 <xsl:call-template name="gentext.template.exists">
214 <xsl:with-param name="context" select="'xref-number-and-title'"/>
215 <xsl:with-param name="name">
216 <xsl:call-template name="xpath.location"/>
217 </xsl:with-param>
218 </xsl:call-template>
219 </xsl:variable>
220
221 <xsl:variable name="number-template">
222 <xsl:call-template name="gentext.template.exists">
223 <xsl:with-param name="context" select="'xref-number'"/>
224 <xsl:with-param name="name">
225 <xsl:call-template name="xpath.location"/>
226 </xsl:with-param>
227 </xsl:call-template>
228 </xsl:variable>
229
230 <xsl:variable name="context">
231 <xsl:choose>
232 <xsl:when test="string($autonumber) != 0
233 and $number-and-title-template != 0
234 and $xref.with.number.and.title != 0">
235 <xsl:value-of select="'xref-number-and-title'"/>
236 </xsl:when>
237 <xsl:when test="string($autonumber) != 0
238 and $number-template != 0">
239 <xsl:value-of select="'xref-number'"/>
240 </xsl:when>
241 <xsl:otherwise>
242 <xsl:value-of select="'xref'"/>
243 </xsl:otherwise>
244 </xsl:choose>
245 </xsl:variable>
246
247 <xsl:call-template name="gentext.template">
248 <xsl:with-param name="context" select="$context"/>
249 <xsl:with-param name="name">
250 <xsl:call-template name="xpath.location"/>
251 </xsl:with-param>
252 <xsl:with-param name="purpose" select="$purpose"/>
253 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
254 <xsl:with-param name="referrer" select="$referrer"/>
255 </xsl:call-template>
256
257 </xsl:template>
258
259
260 <!-- ============================================================ -->
261
262 <xsl:template match="*" mode="object.title.markup">
263 <xsl:param name="allow-anchors" select="0"/>
264 <xsl:variable name="template">
265 <xsl:apply-templates select="." mode="object.title.template"/>
266 </xsl:variable>
267
268 <!--
269 <xsl:message>
270 <xsl:text>object.title.markup: </xsl:text>
271 <xsl:value-of select="local-name(.)"/>
272 <xsl:text>: </xsl:text>
273 <xsl:value-of select="$template"/>
274 </xsl:message>
275 -->
276
277 <xsl:call-template name="substitute-markup">
278 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
279 <xsl:with-param name="template" select="$template"/>
280 </xsl:call-template>
281 </xsl:template>
282
283 <xsl:template match="*" mode="object.title.markup.textonly">
284 <xsl:variable name="title">
285 <xsl:apply-templates select="." mode="object.title.markup"/>
286 </xsl:variable>
287 <xsl:value-of select="normalize-space($title)"/>
288 </xsl:template>
289
290 <!-- ============================================================ -->
291
292 <xsl:template match="*" mode="object.titleabbrev.markup">
293 <xsl:param name="allow-anchors" select="0"/>
294
295 <!-- Just for consistency in template naming -->
296
297 <xsl:apply-templates select="." mode="titleabbrev.markup">
298 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
299 </xsl:apply-templates>
300 </xsl:template>
301
302 <!-- ============================================================ -->
303
304 <xsl:template match="*" mode="object.subtitle.markup">
305 <xsl:variable name="template">
306 <xsl:apply-templates select="." mode="object.subtitle.template"/>
307 </xsl:variable>
308
309 <xsl:call-template name="substitute-markup">
310 <xsl:with-param name="template" select="$template"/>
311 </xsl:call-template>
312 </xsl:template>
313
314 <!-- ============================================================ -->
315
316 <xsl:template match="*" mode="object.xref.markup">
317 <xsl:param name="purpose"/>
318 <xsl:param name="xrefstyle"/>
319 <xsl:param name="referrer"/>
320 <xsl:param name="verbose" select="1"/>
321
322 <xsl:variable name="template">
323 <xsl:choose>
324 <xsl:when test="starts-with(normalize-space($xrefstyle), 'select:')">
325 <xsl:call-template name="make.gentext.template">
326 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
327 <xsl:with-param name="purpose" select="$purpose"/>
328 <xsl:with-param name="referrer" select="$referrer"/>
329 </xsl:call-template>
330 </xsl:when>
331 <xsl:when test="starts-with(normalize-space($xrefstyle), 'template:')">
332 <xsl:value-of select="substring-after(normalize-space($xrefstyle), 'template:')"/>
333 </xsl:when>
334 <xsl:otherwise>
335 <xsl:apply-templates select="." mode="object.xref.template">
336 <xsl:with-param name="purpose" select="$purpose"/>
337 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
338 <xsl:with-param name="referrer" select="$referrer"/>
339 </xsl:apply-templates>
340 </xsl:otherwise>
341 </xsl:choose>
342 </xsl:variable>
343
344 <!--
345 <xsl:message>
346 <xsl:text>object.xref.markup: </xsl:text>
347 <xsl:value-of select="local-name(.)"/>
348 <xsl:text>(</xsl:text>
349 <xsl:value-of select="$xrefstyle"/>
350 <xsl:text>, </xsl:text>
351 <xsl:value-of select="$purpose"/>
352 <xsl:text>)</xsl:text>
353 <xsl:text>: [</xsl:text>
354 <xsl:value-of select="$template"/>
355 <xsl:text>]</xsl:text>
356 </xsl:message>
357 -->
358
359 <xsl:if test="$template = '' and $verbose != 0">
360 <xsl:message>
361 <xsl:text>object.xref.markup: empty xref template</xsl:text>
362 <xsl:text> for linkend="</xsl:text>
363 <xsl:value-of select="@id|@xml:id"/>
364 <xsl:text>" and @xrefstyle="</xsl:text>
365 <xsl:value-of select="$xrefstyle"/>
366 <xsl:text>"</xsl:text>
367 </xsl:message>
368 </xsl:if>
369
370 <xsl:call-template name="substitute-markup">
371 <xsl:with-param name="purpose" select="$purpose"/>
372 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
373 <xsl:with-param name="referrer" select="$referrer"/>
374 <xsl:with-param name="template" select="$template"/>
375 <xsl:with-param name="verbose" select="$verbose"/>
376 </xsl:call-template>
377 </xsl:template>
378
379 <xsl:template match="listitem" mode="object.xref.markup">
380 <xsl:param name="verbose" select="1"/>
381
382 <xsl:choose>
383 <xsl:when test="parent::orderedlist">
384 <xsl:variable name="template">
385 <xsl:apply-templates select="." mode="object.xref.template"/>
386 </xsl:variable>
387 <xsl:call-template name="substitute-markup">
388 <xsl:with-param name="template" select="$template"/>
389 </xsl:call-template>
390 </xsl:when>
391 <xsl:when test="$verbose != 0">
392 <xsl:message>
393 <xsl:text>Xref is only supported to listitems in an</xsl:text>
394 <xsl:text> orderedlist: </xsl:text>
395 <xsl:value-of select="@id|@xml:id"/>
396 </xsl:message>
397 <xsl:text>???</xsl:text>
398 </xsl:when>
399 </xsl:choose>
400 </xsl:template>
401
402 <xsl:template match="question" mode="object.xref.markup">
403 <xsl:param name="purpose"/>
404 <xsl:param name="xrefstyle"/>
405 <xsl:param name="referrer"/>
406
407 <xsl:variable name="deflabel">
408 <xsl:choose>
409 <xsl:when test="ancestor-or-self::*[@defaultlabel]">
410 <xsl:value-of select="(ancestor-or-self::*[@defaultlabel])[last()]
411 /@defaultlabel"/>
412 </xsl:when>
413 <xsl:otherwise>
414 <xsl:value-of select="$qanda.defaultlabel"/>
415 </xsl:otherwise>
416 </xsl:choose>
417 </xsl:variable>
418
419 <xsl:variable name="template">
420 <xsl:choose>
421 <!-- This avoids double Q: Q: in xref when defaultlabel=qanda -->
422 <xsl:when test="$deflabel = 'qanda' and not(label)">%n</xsl:when>
423 <xsl:otherwise>
424 <xsl:apply-templates select="." mode="object.xref.template">
425 <xsl:with-param name="purpose" select="$purpose"/>
426 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
427 <xsl:with-param name="referrer" select="$referrer"/>
428 </xsl:apply-templates>
429 </xsl:otherwise>
430 </xsl:choose>
431 </xsl:variable>
432
433 <xsl:call-template name="substitute-markup">
434 <xsl:with-param name="purpose" select="$purpose"/>
435 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
436 <xsl:with-param name="referrer" select="$referrer"/>
437 <xsl:with-param name="template" select="$template"/>
438 </xsl:call-template>
439 </xsl:template>
440
441 <!-- ============================================================ -->
442
443 <xsl:template name="substitute-markup">
444 <xsl:param name="template" select="''"/>
445 <xsl:param name="allow-anchors" select="'0'"/>
446 <xsl:param name="title" select="''"/>
447 <xsl:param name="subtitle" select="''"/>
448 <xsl:param name="docname" select="''"/>
449 <xsl:param name="label" select="''"/>
450 <xsl:param name="pagenumber" select="''"/>
451 <xsl:param name="purpose"/>
452 <xsl:param name="xrefstyle"/>
453 <xsl:param name="referrer"/>
454 <xsl:param name="verbose"/>
455
456 <xsl:choose>
457 <xsl:when test="contains($template, '%')">
458 <xsl:call-template name="scape">
459 <xsl:with-param name="string" select="substring-before($template, '%')"/>
460 </xsl:call-template>
461 <xsl:variable name="candidate"
462 select="substring(substring-after($template, '%'), 1, 1)"/>
463 <xsl:choose>
464 <xsl:when test="$candidate = 't'">
465 <xsl:apply-templates select="." mode="insert.title.markup">
466 <xsl:with-param name="referrer" select="$referrer"/>
467 <xsl:with-param name="purpose" select="$purpose"/>
468 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
469 <xsl:with-param name="title">
470 <xsl:choose>
471 <xsl:when test="$title != ''">
472 <xsl:copy-of select="$title"/>
473 </xsl:when>
474 <xsl:otherwise>
475 <xsl:apply-templates select="." mode="title.markup">
476 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
477 <xsl:with-param name="verbose" select="$verbose"/>
478 </xsl:apply-templates>
479 </xsl:otherwise>
480 </xsl:choose>
481 </xsl:with-param>
482 </xsl:apply-templates>
483 </xsl:when>
484 <xsl:when test="$candidate = 's'">
485 <xsl:apply-templates select="." mode="insert.subtitle.markup">
486 <xsl:with-param name="purpose" select="$purpose"/>
487 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
488 <xsl:with-param name="subtitle">
489 <xsl:choose>
490 <xsl:when test="$subtitle != ''">
491 <xsl:copy-of select="$subtitle"/>
492 </xsl:when>
493 <xsl:otherwise>
494 <xsl:apply-templates select="." mode="subtitle.markup">
495 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
496 </xsl:apply-templates>
497 </xsl:otherwise>
498 </xsl:choose>
499 </xsl:with-param>
500 </xsl:apply-templates>
501 </xsl:when>
502 <xsl:when test="$candidate = 'n'">
503 <xsl:apply-templates select="." mode="insert.label.markup">
504 <xsl:with-param name="purpose" select="$purpose"/>
505 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
506 <xsl:with-param name="label">
507 <xsl:choose>
508 <xsl:when test="$label != ''">
509 <xsl:copy-of select="$label"/>
510 </xsl:when>
511 <xsl:otherwise>
512 <xsl:apply-templates select="." mode="label.markup"/>
513 </xsl:otherwise>
514 </xsl:choose>
515 </xsl:with-param>
516 </xsl:apply-templates>
517 </xsl:when>
518 <xsl:when test="$candidate = 'p'">
519 <xsl:apply-templates select="." mode="insert.pagenumber.markup">
520 <xsl:with-param name="purpose" select="$purpose"/>
521 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
522 <xsl:with-param name="pagenumber">
523 <xsl:choose>
524 <xsl:when test="$pagenumber != ''">
525 <xsl:copy-of select="$pagenumber"/>
526 </xsl:when>
527 <xsl:otherwise>
528 <xsl:apply-templates select="." mode="pagenumber.markup"/>
529 </xsl:otherwise>
530 </xsl:choose>
531 </xsl:with-param>
532 </xsl:apply-templates>
533 </xsl:when>
534 <xsl:when test="$candidate = 'o'">
535 <!-- olink target document title -->
536 <xsl:apply-templates select="." mode="insert.olink.docname.markup">
537 <xsl:with-param name="purpose" select="$purpose"/>
538 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
539 <xsl:with-param name="docname">
540 <xsl:choose>
541 <xsl:when test="$docname != ''">
542 <xsl:copy-of select="$docname"/>
543 </xsl:when>
544 <xsl:otherwise>
545 <xsl:apply-templates select="." mode="olink.docname.markup"/>
546 </xsl:otherwise>
547 </xsl:choose>
548 </xsl:with-param>
549 </xsl:apply-templates>
550 </xsl:when>
551 <xsl:when test="$candidate = 'd'">
552 <xsl:apply-templates select="." mode="insert.direction.markup">
553 <xsl:with-param name="purpose" select="$purpose"/>
554 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
555 <xsl:with-param name="direction">
556 <xsl:choose>
557 <xsl:when test="$referrer">
558 <xsl:variable name="referent-is-below">
559 <xsl:for-each select="preceding::xref">
560 <xsl:if test="generate-id(.) = generate-id($referrer)">1</xsl:if>
561 </xsl:for-each>
562 </xsl:variable>
563 <xsl:choose>
564 <xsl:when test="$referent-is-below = ''">
565 <xsl:call-template name="gentext">
566 <xsl:with-param name="key" select="'above'"/>
567 </xsl:call-template>
568 </xsl:when>
569 <xsl:otherwise>
570 <xsl:call-template name="gentext">
571 <xsl:with-param name="key" select="'below'"/>
572 </xsl:call-template>
573 </xsl:otherwise>
574 </xsl:choose>
575 </xsl:when>
576 <xsl:otherwise>
577 <xsl:message>Attempt to use %d in gentext with no referrer!</xsl:message>
578 </xsl:otherwise>
579 </xsl:choose>
580 </xsl:with-param>
581 </xsl:apply-templates>
582 </xsl:when>
583 <xsl:when test="$candidate = '%' ">
584 <xsl:text>%</xsl:text>
585 </xsl:when>
586 <xsl:otherwise>
587 <xsl:text>%</xsl:text><xsl:value-of select="$candidate"/>
588 </xsl:otherwise>
589 </xsl:choose>
590 <!-- recurse with the rest of the template string -->
591 <xsl:variable name="rest"
592 select="substring($template,
593 string-length(substring-before($template, '%'))+3)"/>
594 <xsl:call-template name="substitute-markup">
595 <xsl:with-param name="template" select="$rest"/>
596 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
597 <xsl:with-param name="title" select="$title"/>
598 <xsl:with-param name="subtitle" select="$subtitle"/>
599 <xsl:with-param name="docname" select="$docname"/>
600 <xsl:with-param name="label" select="$label"/>
601 <xsl:with-param name="pagenumber" select="$pagenumber"/>
602 <xsl:with-param name="purpose" select="$purpose"/>
603 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
604 <xsl:with-param name="referrer" select="$referrer"/>
605 <xsl:with-param name="verbose" select="$verbose"/>
606 </xsl:call-template>
607 </xsl:when>
608 <xsl:otherwise>
609 <xsl:call-template name="scape">
610 <xsl:with-param name="string" select="$template"/>
611 </xsl:call-template>
612 </xsl:otherwise>
613 </xsl:choose>
614 </xsl:template>
615
616 <!-- ============================================================ -->
617
618 <xsl:template name="make.gentext.template">
619 <xsl:param name="xrefstyle" select="''"/>
620 <xsl:param name="purpose"/>
621 <xsl:param name="referrer"/>
622 <xsl:param name="lang">
623 <xsl:call-template name="l10n.language"/>
624 </xsl:param>
625 <xsl:param name="target.elem" select="local-name(.)"/>
626
627 <!-- parse xrefstyle to get parts -->
628 <xsl:variable name="parts"
629 select="substring-after(normalize-space($xrefstyle), 'select:')"/>
630
631 <xsl:variable name="labeltype">
632 <xsl:choose>
633 <xsl:when test="contains($parts, 'labelnumber')">
634 <xsl:text>labelnumber</xsl:text>
635 </xsl:when>
636 <xsl:when test="contains($parts, 'labelname')">
637 <xsl:text>labelname</xsl:text>
638 </xsl:when>
639 <xsl:when test="contains($parts, 'label')">
640 <xsl:text>label</xsl:text>
641 </xsl:when>
642 </xsl:choose>
643 </xsl:variable>
644
645 <xsl:variable name="titletype">
646 <xsl:choose>
647 <xsl:when test="contains($parts, 'quotedtitle')">
648 <xsl:text>quotedtitle</xsl:text>
649 </xsl:when>
650 <xsl:when test="contains($parts, 'title')">
651 <xsl:text>title</xsl:text>
652 </xsl:when>
653 </xsl:choose>
654 </xsl:variable>
655
656 <xsl:variable name="pagetype">
657 <xsl:choose>
658 <xsl:when test="$insert.olink.page.number = 'no' and
659 local-name($referrer) = 'olink'">
660 <!-- suppress page numbers -->
661 </xsl:when>
662 <xsl:when test="$insert.xref.page.number = 'no' and
663 local-name($referrer) != 'olink'">
664 <!-- suppress page numbers -->
665 </xsl:when>
666 <xsl:when test="contains($parts, 'nopage')">
667 <xsl:text>nopage</xsl:text>
668 </xsl:when>
669 <xsl:when test="contains($parts, 'pagenumber')">
670 <xsl:text>pagenumber</xsl:text>
671 </xsl:when>
672 <xsl:when test="contains($parts, 'pageabbrev')">
673 <xsl:text>pageabbrev</xsl:text>
674 </xsl:when>
675 <xsl:when test="contains($parts, 'Page')">
676 <xsl:text>Page</xsl:text>
677 </xsl:when>
678 <xsl:when test="contains($parts, 'page')">
679 <xsl:text>page</xsl:text>
680 </xsl:when>
681 </xsl:choose>
682 </xsl:variable>
683
684 <xsl:variable name="docnametype">
685 <xsl:choose>
686 <xsl:when test="($olink.doctitle = 0 or
687 $olink.doctitle = 'no') and
688 local-name($referrer) = 'olink'">
689 <!-- suppress docname -->
690 </xsl:when>
691 <xsl:when test="contains($parts, 'nodocname')">
692 <xsl:text>nodocname</xsl:text>
693 </xsl:when>
694 <xsl:when test="contains($parts, 'docnamelong')">
695 <xsl:text>docnamelong</xsl:text>
696 </xsl:when>
697 <xsl:when test="contains($parts, 'docname')">
698 <xsl:text>docname</xsl:text>
699 </xsl:when>
700 </xsl:choose>
701 </xsl:variable>
702
703 <xsl:if test="$labeltype != ''">
704 <xsl:choose>
705 <xsl:when test="$labeltype = 'labelname'">
706 <xsl:call-template name="gentext">
707 <xsl:with-param name="key">
708 <xsl:choose>
709 <xsl:when test="local-name($referrer) = 'olink'">
710 <xsl:value-of select="$target.elem"/>
711 </xsl:when>
712 <xsl:otherwise>
713 <xsl:value-of select="local-name(.)"/>
714 </xsl:otherwise>
715 </xsl:choose>
716 </xsl:with-param>
717 </xsl:call-template>
718 </xsl:when>
719 <xsl:when test="$labeltype = 'labelnumber'">
720 <xsl:text>%n</xsl:text>
721 </xsl:when>
722 <xsl:when test="$labeltype = 'label'">
723 <xsl:call-template name="gentext.template">
724 <xsl:with-param name="context" select="'xref-number'"/>
725 <xsl:with-param name="name">
726 <xsl:choose>
727 <xsl:when test="local-name($referrer) = 'olink'">
728 <xsl:value-of select="$target.elem"/>
729 </xsl:when>
730 <xsl:otherwise>
731 <xsl:call-template name="xpath.location"/>
732 </xsl:otherwise>
733 </xsl:choose>
734 </xsl:with-param>
735 <xsl:with-param name="purpose" select="$purpose"/>
736 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
737 <xsl:with-param name="referrer" select="$referrer"/>
738 </xsl:call-template>
739 </xsl:when>
740 </xsl:choose>
741
742 <xsl:choose>
743 <xsl:when test="$titletype != ''">
744 <xsl:value-of select="$xref.label-title.separator"/>
745 </xsl:when>
746 <xsl:when test="$pagetype != ''">
747 <xsl:value-of select="$xref.label-page.separator"/>
748 </xsl:when>
749 </xsl:choose>
750 </xsl:if>
751
752 <xsl:if test="$titletype != ''">
753 <xsl:choose>
754 <xsl:when test="$titletype = 'title'">
755 <xsl:text>%t</xsl:text>
756 </xsl:when>
757 <xsl:when test="$titletype = 'quotedtitle'">
758 <xsl:call-template name="gentext.dingbat">
759 <xsl:with-param name="dingbat" select="'startquote'"/>
760 </xsl:call-template>
761 <xsl:text>%t</xsl:text>
762 <xsl:call-template name="gentext.dingbat">
763 <xsl:with-param name="dingbat" select="'endquote'"/>
764 </xsl:call-template>
765 </xsl:when>
766 </xsl:choose>
767
768 <xsl:choose>
769 <xsl:when test="$pagetype != '' and $pagetype != 'nopage'">
770 <xsl:value-of select="$xref.title-page.separator"/>
771 </xsl:when>
772 </xsl:choose>
773 </xsl:if>
774
775 <!-- special case: use regular xref template if just turning off page -->
776 <xsl:if test="($pagetype = 'nopage' or $docnametype = 'nodocname')
777 and local-name($referrer) != 'olink'
778 and $labeltype = ''
779 and $titletype = ''">
780 <xsl:apply-templates select="." mode="object.xref.template">
781 <xsl:with-param name="purpose" select="$purpose"/>
782 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
783 <xsl:with-param name="referrer" select="$referrer"/>
784 </xsl:apply-templates>
785 </xsl:if>
786
787 <xsl:if test="$pagetype != ''">
788 <xsl:choose>
789 <xsl:when test="$pagetype = 'page'">
790 <xsl:call-template name="gentext.template">
791 <xsl:with-param name="context" select="'xref'"/>
792 <xsl:with-param name="name" select="'page'"/>
793 </xsl:call-template>
794 </xsl:when>
795 <xsl:when test="$pagetype = 'Page'">
796 <xsl:call-template name="gentext.template">
797 <xsl:with-param name="context" select="'xref'"/>
798 <xsl:with-param name="name" select="'Page'"/>
799 </xsl:call-template>
800 </xsl:when>
801 <xsl:when test="$pagetype = 'pageabbrev'">
802 <xsl:call-template name="gentext.template">
803 <xsl:with-param name="context" select="'xref'"/>
804 <xsl:with-param name="name" select="'pageabbrev'"/>
805 </xsl:call-template>
806 </xsl:when>
807 <xsl:when test="$pagetype = 'pagenumber'">
808 <xsl:text>%p</xsl:text>
809 </xsl:when>
810 </xsl:choose>
811
812 </xsl:if>
813
814 <!-- Add reference to other document title -->
815 <xsl:if test="$docnametype != '' and local-name($referrer) = 'olink'">
816 <!-- Any separator should be in the gentext template -->
817 <xsl:choose>
818 <xsl:when test="$docnametype = 'docnamelong'">
819 <xsl:call-template name="gentext.template">
820 <xsl:with-param name="context" select="'xref'"/>
821 <xsl:with-param name="name" select="'docnamelong'"/>
822 </xsl:call-template>
823 </xsl:when>
824 <xsl:when test="$docnametype = 'docname'">
825 <xsl:call-template name="gentext.template">
826 <xsl:with-param name="context" select="'xref'"/>
827 <xsl:with-param name="name" select="'docname'"/>
828 </xsl:call-template>
829 </xsl:when>
830 </xsl:choose>
831
832 </xsl:if>
833
834 </xsl:template>
835
836 </xsl:stylesheet>