Debian Codegraph @

doc/docbook-xsl/common/common.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 xmlns:dyn="http://exslt.org/dynamic"
5 xmlns:saxon="http://icl.com/saxon"
6 exclude-result-prefixes="doc dyn saxon"
7 version='1.0'>
8
9 <!-- ********************************************************************
10 $Id$
11 ********************************************************************
12
13 This file is part of the XSL DocBook Stylesheet distribution.
14 See ../README or http://nwalsh.com/docbook/xsl/ for copyright
15 and other information.
16
17 This file contains general templates common to both the HTML and FO
18 versions of the DocBook stylesheets.
19 ******************************************************************** -->
20
21 <doc:reference xmlns="">
22 <referenceinfo>
23 <releaseinfo role="meta">
24 $Id$
25 </releaseinfo>
26 <author><surname>Walsh</surname>
27 <firstname>Norman</firstname></author>
28 <copyright><year>1999</year><year>2000</year>
29 <holder>Norman Walsh</holder>
30 </copyright>
31 </referenceinfo>
32 <title>Common Template Reference</title>
33
34 <partintro id="partintro">
35 <title>Introduction</title>
36
37 <para>This is technical reference documentation for the DocBook XSL
38 Stylesheets; it documents (some of) the parameters, templates, and
39 other elements of the stylesheets.</para>
40
41 <para>This is not intended to be <quote>user</quote> documentation.
42 It is provided for developers writing customization layers for the
43 stylesheets, and for anyone who's interested in <quote>how it
44 works</quote>.</para>
45
46 <para>Although I am trying to be thorough, this documentation is known
47 to be incomplete. Don't forget to read the source, too :-)</para>
48 </partintro>
49
50 </doc:reference>
51
52 <!-- ==================================================================== -->
53 <!-- Establish strip/preserve whitespace rules -->
54
55 <xsl:preserve-space elements="*"/>
56
57 <xsl:strip-space elements="
58 abstract affiliation anchor answer appendix area areaset areaspec
59 artheader article audiodata audioobject author authorblurb authorgroup
60 beginpage bibliodiv biblioentry bibliography biblioset blockquote book
61 bookbiblio bookinfo callout calloutlist caption caution chapter
62 citerefentry cmdsynopsis co collab colophon colspec confgroup
63 copyright dedication docinfo editor entrytbl epigraph equation
64 example figure footnote footnoteref formalpara funcprototype
65 funcsynopsis glossary glossdef glossdiv glossentry glosslist graphicco
66 group highlights imagedata imageobject imageobjectco important index
67 indexdiv indexentry indexterm info informalequation informalexample
68 informalfigure informaltable inlineequation inlinemediaobject
69 itemizedlist itermset keycombo keywordset legalnotice listitem lot
70 mediaobject mediaobjectco menuchoice msg msgentry msgexplan msginfo
71 msgmain msgrel msgset msgsub msgtext note objectinfo
72 orderedlist othercredit part partintro preface printhistory procedure
73 programlistingco publisher qandadiv qandaentry qandaset question
74 refentry reference refmeta refnamediv refsection refsect1 refsect1info refsect2
75 refsect2info refsect3 refsect3info refsynopsisdiv refsynopsisdivinfo
76 revhistory revision row sbr screenco screenshot sect1 sect1info sect2
77 sect2info sect3 sect3info sect4 sect4info sect5 sect5info section
78 sectioninfo seglistitem segmentedlist seriesinfo set setindex setinfo
79 shortcut sidebar simplelist simplesect spanspec step subject
80 subjectset substeps synopfragment table tbody textobject tfoot tgroup
81 thead tip toc tocchap toclevel1 toclevel2 toclevel3 toclevel4
82 toclevel5 tocpart varargs variablelist varlistentry videodata
83 videoobject void warning subjectset
84
85 classsynopsis
86 constructorsynopsis
87 destructorsynopsis
88 fieldsynopsis
89 methodparam
90 methodsynopsis
91 ooclass
92 ooexception
93 oointerface
94 simplemsgentry
95 manvolnum
96 "/>
97 <!-- ====================================================================== -->
98
99 <doc:template name="is.component" xmlns="">
100 <refpurpose>Tests if a given node is a component-level element</refpurpose>
101
102 <refdescription>
103 <para>This template returns '1' if the specified node is a component
104 (Chapter, Appendix, etc.), and '0' otherwise.</para>
105 </refdescription>
106
107 <refparameter>
108 <variablelist>
109 <varlistentry><term>node</term>
110 <listitem>
111 <para>The node which is to be tested.</para>
112 </listitem>
113 </varlistentry>
114 </variablelist>
115 </refparameter>
116
117 <refreturn>
118 <para>This template returns '1' if the specified node is a component
119 (Chapter, Appendix, etc.), and '0' otherwise.</para>
120 </refreturn>
121 </doc:template>
122
123 <xsl:template name="is.component">
124 <xsl:param name="node" select="."/>
125 <xsl:choose>
126 <xsl:when test="local-name($node) = 'appendix'
127 or local-name($node) = 'article'
128 or local-name($node) = 'chapter'
129 or local-name($node) = 'preface'
130 or local-name($node) = 'bibliography'
131 or local-name($node) = 'glossary'
132 or local-name($node) = 'index'">1</xsl:when>
133 <xsl:otherwise>0</xsl:otherwise>
134 </xsl:choose>
135 </xsl:template>
136
137 <!-- ====================================================================== -->
138
139 <doc:template name="is.section" xmlns="">
140 <refpurpose>Tests if a given node is a section-level element</refpurpose>
141
142 <refdescription>
143 <para>This template returns '1' if the specified node is a section
144 (Section, Sect1, Sect2, etc.), and '0' otherwise.</para>
145 </refdescription>
146
147 <refparameter>
148 <variablelist>
149 <varlistentry><term>node</term>
150 <listitem>
151 <para>The node which is to be tested.</para>
152 </listitem>
153 </varlistentry>
154 </variablelist>
155 </refparameter>
156
157 <refreturn>
158 <para>This template returns '1' if the specified node is a section
159 (Section, Sect1, Sect2, etc.), and '0' otherwise.</para>
160 </refreturn>
161 </doc:template>
162
163 <xsl:template name="is.section">
164 <xsl:param name="node" select="."/>
165 <xsl:choose>
166 <xsl:when test="local-name($node) = 'section'
167 or local-name($node) = 'sect1'
168 or local-name($node) = 'sect2'
169 or local-name($node) = 'sect3'
170 or local-name($node) = 'sect4'
171 or local-name($node) = 'sect5'
172 or local-name($node) = 'refsect1'
173 or local-name($node) = 'refsect2'
174 or local-name($node) = 'refsect3'
175 or local-name($node) = 'simplesect'">1</xsl:when>
176 <xsl:otherwise>0</xsl:otherwise>
177 </xsl:choose>
178 </xsl:template>
179
180 <!-- ====================================================================== -->
181
182 <doc:template name="section.level" xmlns="">
183 <refpurpose>Returns the hierarchical level of a section</refpurpose>
184
185 <refdescription>
186 <para>This template calculates the hierarchical level of a section.
187 The element <sgmltag>sect1</sgmltag> is at level 1, <sgmltag>sect2</sgmltag> is
188 at level 2, etc.</para>
189
190 <para>Recursive sections are calculated down to the fifth level.</para>
191 </refdescription>
192
193 <refparameter>
194 <variablelist>
195 <varlistentry><term>node</term>
196 <listitem>
197 <para>The section node for which the level should be calculated.
198 Defaults to the context node.</para>
199 </listitem>
200 </varlistentry>
201 </variablelist>
202 </refparameter>
203
204 <refreturn>
205 <para>The section level, <quote>1</quote>, <quote>2</quote>, etc.
206 </para>
207 </refreturn>
208 </doc:template>
209
210 <xsl:template name="section.level">
211 <xsl:param name="node" select="."/>
212 <xsl:choose>
213 <xsl:when test="local-name($node)='sect1'">1</xsl:when>
214 <xsl:when test="local-name($node)='sect2'">2</xsl:when>
215 <xsl:when test="local-name($node)='sect3'">3</xsl:when>
216 <xsl:when test="local-name($node)='sect4'">4</xsl:when>
217 <xsl:when test="local-name($node)='sect5'">5</xsl:when>
218 <xsl:when test="local-name($node)='section'">
219 <xsl:choose>
220 <xsl:when test="$node/../../../../../../section">6</xsl:when>
221 <xsl:when test="$node/../../../../../section">5</xsl:when>
222 <xsl:when test="$node/../../../../section">4</xsl:when>
223 <xsl:when test="$node/../../../section">3</xsl:when>
224 <xsl:when test="$node/../../section">2</xsl:when>
225 <xsl:otherwise>1</xsl:otherwise>
226 </xsl:choose>
227 </xsl:when>
228 <xsl:when test="local-name($node)='refsect1' or
229 local-name($node)='refsect2' or
230 local-name($node)='refsect3' or
231 local-name($node)='refsection' or
232 local-name($node)='refsynopsisdiv'">
233 <xsl:call-template name="refentry.section.level">
234 <xsl:with-param name="node" select="$node"/>
235 </xsl:call-template>
236 </xsl:when>
237 <xsl:when test="local-name($node)='simplesect'">
238 <xsl:choose>
239 <xsl:when test="$node/../../sect1">2</xsl:when>
240 <xsl:when test="$node/../../sect2">3</xsl:when>
241 <xsl:when test="$node/../../sect3">4</xsl:when>
242 <xsl:when test="$node/../../sect4">5</xsl:when>
243 <xsl:when test="$node/../../sect5">5</xsl:when>
244 <xsl:when test="$node/../../section">
245 <xsl:choose>
246 <xsl:when test="$node/../../../../../section">5</xsl:when>
247 <xsl:when test="$node/../../../../section">4</xsl:when>
248 <xsl:when test="$node/../../../section">3</xsl:when>
249 <xsl:otherwise>2</xsl:otherwise>
250 </xsl:choose>
251 </xsl:when>
252 <xsl:otherwise>1</xsl:otherwise>
253 </xsl:choose>
254 </xsl:when>
255 <xsl:otherwise>1</xsl:otherwise>
256 </xsl:choose>
257 </xsl:template><!-- section.level -->
258
259 <doc:template name="qanda.section.level" xmlns="">
260 <refpurpose>Returns the hierarchical level of a QandASet</refpurpose>
261
262 <refdescription>
263 <para>This template calculates the hierarchical level of a QandASet.
264 </para>
265 </refdescription>
266
267 <refreturn>
268 <para>The level, <quote>1</quote>, <quote>2</quote>, etc.
269 </para>
270 </refreturn>
271 </doc:template>
272
273 <xsl:template name="qanda.section.level">
274 <xsl:variable name="section"
275 select="(ancestor::section
276 |ancestor::simplesect
277 |ancestor::sect5
278 |ancestor::sect4
279 |ancestor::sect3
280 |ancestor::sect2
281 |ancestor::sect1
282 |ancestor::refsect3
283 |ancestor::refsect2
284 |ancestor::refsect1)[last()]"/>
285
286 <xsl:choose>
287 <xsl:when test="count($section) = '0'">1</xsl:when>
288 <xsl:otherwise>
289 <xsl:variable name="slevel">
290 <xsl:call-template name="section.level">
291 <xsl:with-param name="node" select="$section"/>
292 </xsl:call-template>
293 </xsl:variable>
294 <xsl:value-of select="$slevel + 1"/>
295 </xsl:otherwise>
296 </xsl:choose>
297 </xsl:template>
298
299 <!-- Finds the total section depth of a section in a refentry -->
300 <xsl:template name="refentry.section.level">
301 <xsl:param name="node" select="."/>
302
303 <xsl:variable name="RElevel">
304 <xsl:call-template name="refentry.level">
305 <xsl:with-param name="node" select="$node/ancestor::refentry[1]"/>
306 </xsl:call-template>
307 </xsl:variable>
308
309 <xsl:variable name="levelinRE">
310 <xsl:choose>
311 <xsl:when test="local-name($node)='refsynopsisdiv'">1</xsl:when>
312 <xsl:when test="local-name($node)='refsect1'">1</xsl:when>
313 <xsl:when test="local-name($node)='refsect2'">2</xsl:when>
314 <xsl:when test="local-name($node)='refsect3'">3</xsl:when>
315 <xsl:when test="local-name($node)='refsection'">
316 <xsl:choose>
317 <xsl:when test="$node/../../../../../refsection">5</xsl:when>
318 <xsl:when test="$node/../../../../refsection">4</xsl:when>
319 <xsl:when test="$node/../../../refsection">3</xsl:when>
320 <xsl:when test="$node/../../refsection">2</xsl:when>
321 <xsl:otherwise>1</xsl:otherwise>
322 </xsl:choose>
323 </xsl:when>
324 </xsl:choose>
325 </xsl:variable>
326
327 <xsl:value-of select="$levelinRE + $RElevel"/>
328 </xsl:template>
329
330 <!-- Finds the section depth of a refentry -->
331 <xsl:template name="refentry.level">
332 <xsl:param name="node" select="."/>
333 <xsl:variable name="container"
334 select="($node/ancestor::section |
335 $node/ancestor::sect1 |
336 $node/ancestor::sect2 |
337 $node/ancestor::sect3 |
338 $node/ancestor::sect4 |
339 $node/ancestor::sect5)[last()]"/>
340
341 <xsl:choose>
342 <xsl:when test="$container">
343 <xsl:variable name="slevel">
344 <xsl:call-template name="section.level">
345 <xsl:with-param name="node" select="$container"/>
346 </xsl:call-template>
347 </xsl:variable>
348 <xsl:value-of select="$slevel + 1"/>
349 </xsl:when>
350 <xsl:otherwise>1</xsl:otherwise>
351 </xsl:choose>
352 </xsl:template>
353
354 <xsl:template name="qandadiv.section.level">
355 <xsl:variable name="section.level">
356 <xsl:call-template name="qanda.section.level"/>
357 </xsl:variable>
358 <xsl:variable name="anc.divs" select="ancestor::qandadiv"/>
359
360 <xsl:value-of select="count($anc.divs) + number($section.level)"/>
361 </xsl:template>
362
363 <xsl:template name="question.answer.label">
364 <xsl:variable name="deflabel">
365 <xsl:choose>
366 <xsl:when test="ancestor-or-self::*[@defaultlabel]">
367 <xsl:value-of select="(ancestor-or-self::*[@defaultlabel])[last()]
368 /@defaultlabel"/>
369 </xsl:when>
370 <xsl:otherwise>
371 <xsl:value-of select="$qanda.defaultlabel"/>
372 </xsl:otherwise>
373 </xsl:choose>
374 </xsl:variable>
375
376 <xsl:variable name="label" select="@label"/>
377
378 <!--
379 (hnr (hierarchical-number-recursive (normalize "qandadiv") node))
380
381 (parsect (ancestor-member node (section-element-list)))
382
383 (defnum (if (and %qanda-inherit-numeration%
384 %section-autolabel%)
385 (if (node-list-empty? parsect)
386 (section-autolabel-prefix node)
387 (section-autolabel parsect))
388 ""))
389
390 (hnumber (let loop ((numlist hnr) (number defnum)
391 (sep (if (equal? defnum "") "" ".")))
392 (if (null? numlist)
393 number
394 (loop (cdr numlist)
395 (string-append number
396 sep
397 (number->string (car numlist)))
398 "."))))
399 (cnumber (child-number (parent node)))
400 (number (string-append hnumber
401 (if (equal? hnumber "")
402 ""
403 ".")
404 (number->string cnumber))))
405 -->
406
407 <xsl:choose>
408 <xsl:when test="$deflabel = 'qanda'">
409 <xsl:call-template name="gentext">
410 <xsl:with-param name="key">
411 <xsl:choose>
412 <xsl:when test="local-name(.) = 'question'">question</xsl:when>
413 <xsl:when test="local-name(.) = 'answer'">answer</xsl:when>
414 <xsl:when test="local-name(.) = 'qandadiv'">qandadiv</xsl:when>
415 <xsl:otherwise>qandaset</xsl:otherwise>
416 </xsl:choose>
417 </xsl:with-param>
418 </xsl:call-template>
419 </xsl:when>
420 <xsl:when test="$deflabel = 'label'">
421 <xsl:value-of select="$label"/>
422 </xsl:when>
423 <xsl:when test="$deflabel = 'number'
424 and local-name(.) = 'question'">
425 <xsl:apply-templates select="ancestor::qandaset[1]"
426 mode="number"/>
427 <xsl:choose>
428 <xsl:when test="ancestor::qandadiv">
429 <xsl:apply-templates select="ancestor::qandadiv[1]"
430 mode="number"/>
431 <xsl:apply-templates select="ancestor::qandaentry"
432 mode="number"/>
433 </xsl:when>
434 <xsl:otherwise>
435 <xsl:apply-templates select="ancestor::qandaentry"
436 mode="number"/>
437 </xsl:otherwise>
438 </xsl:choose>
439 </xsl:when>
440 <xsl:otherwise>
441 <!-- nothing -->
442 </xsl:otherwise>
443 </xsl:choose>
444 </xsl:template>
445
446 <xsl:template match="qandaset" mode="number">
447 <!-- FIXME: -->
448 </xsl:template>
449
450 <xsl:template match="qandadiv" mode="number">
451 <xsl:number level="multiple" from="qandaset" format="1."/>
452 </xsl:template>
453
454 <xsl:template match="qandaentry" mode="number">
455 <xsl:choose>
456 <xsl:when test="ancestor::qandadiv">
457 <xsl:number level="single" from="qandadiv" format="1."/>
458 </xsl:when>
459 <xsl:otherwise>
460 <xsl:number level="single" from="qandaset" format="1."/>
461 </xsl:otherwise>
462 </xsl:choose>
463 </xsl:template>
464
465 <!-- ====================================================================== -->
466
467 <xsl:template name="object.id">
468 <xsl:param name="object" select="."/>
469 <xsl:choose>
470 <xsl:when test="$object/@id">
471 <xsl:value-of select="$object/@id"/>
472 </xsl:when>
473 <xsl:when test="$object/@xml:id">
474 <xsl:value-of select="$object/@xml:id"/>
475 </xsl:when>
476 <xsl:otherwise>
477 <xsl:value-of select="generate-id($object)"/>
478 </xsl:otherwise>
479 </xsl:choose>
480 </xsl:template>
481
482 <xsl:template name="person.name">
483 <!-- Formats a personal name. Handles corpauthor as a special case. -->
484 <xsl:param name="node" select="."/>
485
486 <xsl:variable name="style">
487 <xsl:choose>
488 <xsl:when test="$node/@role">
489 <xsl:value-of select="$node/@role"/>
490 </xsl:when>
491 <xsl:otherwise>
492 <xsl:call-template name="gentext.template">
493 <xsl:with-param name="context" select="'styles'"/>
494 <xsl:with-param name="name" select="'person-name'"/>
495 </xsl:call-template>
496 </xsl:otherwise>
497 </xsl:choose>
498 </xsl:variable>
499
500 <xsl:choose>
501 <!-- the personname element is a specialcase -->
502 <xsl:when test="$node/personname">
503 <xsl:call-template name="person.name">
504 <xsl:with-param name="node" select="$node/personname"/>
505 </xsl:call-template>
506 </xsl:when>
507
508 <!-- handle corpauthor as a special case...-->
509 <xsl:when test="local-name($node)='corpauthor'">
510 <xsl:apply-templates select="$node"/>
511 </xsl:when>
512
513 <xsl:otherwise>
514 <xsl:choose>
515 <!-- Handle case when personname contains only general markup (DocBook 5.0) -->
516 <xsl:when test="$node/self::personname and not($node/firstname or $node/honorific or $node/lineage or $node/othername or $node/surname)">
517 <xsl:apply-templates select="$node/node()"/>
518 </xsl:when>
519 <xsl:when test="$style = 'family-given'">
520 <xsl:call-template name="person.name.family-given">
521 <xsl:with-param name="node" select="$node"/>
522 </xsl:call-template>
523 </xsl:when>
524 <xsl:when test="$style = 'last-first'">
525 <xsl:call-template name="person.name.last-first">
526 <xsl:with-param name="node" select="$node"/>
527 </xsl:call-template>
528 </xsl:when>
529 <xsl:otherwise>
530 <xsl:call-template name="person.name.first-last">
531 <xsl:with-param name="node" select="$node"/>
532 </xsl:call-template>
533 </xsl:otherwise>
534 </xsl:choose>
535 </xsl:otherwise>
536 </xsl:choose>
537 </xsl:template>
538
539 <xsl:template name="person.name.family-given">
540 <xsl:param name="node" select="."/>
541
542 <!-- The family-given style applies a convention for identifying given -->
543 <!-- and family names in locales where it may be ambiguous -->
544 <xsl:apply-templates select="$node//surname[1]"/>
545
546 <xsl:if test="$node//surname and $node//firstname">
547 <xsl:text> </xsl:text>
548 </xsl:if>
549
550 <xsl:apply-templates select="$node//firstname[1]"/>
551
552 <xsl:text> [FAMILY Given]</xsl:text>
553 </xsl:template>
554
555 <xsl:template name="person.name.last-first">
556 <xsl:param name="node" select="."/>
557
558 <xsl:apply-templates select="$node//surname[1]"/>
559
560 <xsl:if test="$node//surname and $node//firstname">
561 <xsl:text>, </xsl:text>
562 </xsl:if>
563
564 <xsl:apply-templates select="$node//firstname[1]"/>
565 </xsl:template>
566
567 <xsl:template name="person.name.first-last">
568 <xsl:param name="node" select="."/>
569
570 <xsl:if test="$node//honorific">
571 <xsl:apply-templates select="$node//honorific[1]"/>
572 <xsl:value-of select="$punct.honorific"/>
573 </xsl:if>
574
575 <xsl:if test="$node//firstname">
576 <xsl:if test="$node//honorific">
577 <xsl:text> </xsl:text>
578 </xsl:if>
579 <xsl:apply-templates select="$node//firstname[1]"/>
580 </xsl:if>
581
582 <xsl:if test="$node//othername and $author.othername.in.middle != 0">
583 <xsl:if test="$node//honorific or $node//firstname">
584 <xsl:text> </xsl:text>
585 </xsl:if>
586 <xsl:apply-templates select="$node//othername[1]"/>
587 </xsl:if>
588
589 <xsl:if test="$node//surname">
590 <xsl:if test="$node//honorific or $node//firstname
591 or ($node//othername and $author.othername.in.middle != 0)">
592 <xsl:text> </xsl:text>
593 </xsl:if>
594 <xsl:apply-templates select="$node//surname[1]"/>
595 </xsl:if>
596
597 <xsl:if test="$node//lineage">
598 <xsl:text>, </xsl:text>
599 <xsl:apply-templates select="$node//lineage[1]"/>
600 </xsl:if>
601 </xsl:template>
602
603 <xsl:template name="person.name.list">
604 <!-- Return a formatted string representation of the contents of
605 the current element. The current element must contain one or
606 more AUTHORs, CORPAUTHORs, OTHERCREDITs, and/or EDITORs.
607
608 John Doe
609 or
610 John Doe and Jane Doe
611 or
612 John Doe, Jane Doe, and A. Nonymous
613 -->
614 <xsl:param name="person.list"
615 select="author|corpauthor|othercredit|editor"/>
616 <xsl:param name="person.count" select="count($person.list)"/>
617 <xsl:param name="count" select="1"/>
618
619 <xsl:choose>
620 <xsl:when test="$count &gt; $person.count"></xsl:when>
621 <xsl:otherwise>
622 <xsl:call-template name="person.name">
623 <xsl:with-param name="node" select="$person.list[position()=$count]"/>
624 </xsl:call-template>
625
626 <xsl:choose>
627 <xsl:when test="$person.count = 2 and $count = 1">
628 <xsl:call-template name="gentext.template">
629 <xsl:with-param name="context" select="'authorgroup'"/>
630 <xsl:with-param name="name" select="'sep2'"/>
631 </xsl:call-template>
632 </xsl:when>
633 <xsl:when test="$person.count &gt; 2 and $count+1 = $person.count">
634 <xsl:call-template name="gentext.template">
635 <xsl:with-param name="context" select="'authorgroup'"/>
636 <xsl:with-param name="name" select="'seplast'"/>
637 </xsl:call-template>
638 </xsl:when>
639 <xsl:when test="$count &lt; $person.count">
640 <xsl:call-template name="gentext.template">
641 <xsl:with-param name="context" select="'authorgroup'"/>
642 <xsl:with-param name="name" select="'sep'"/>
643 </xsl:call-template>
644 </xsl:when>
645 </xsl:choose>
646
647 <xsl:call-template name="person.name.list">
648 <xsl:with-param name="person.list" select="$person.list"/>
649 <xsl:with-param name="person.count" select="$person.count"/>
650 <xsl:with-param name="count" select="$count+1"/>
651 </xsl:call-template>
652 </xsl:otherwise>
653 </xsl:choose>
654 </xsl:template><!-- person.name.list -->
655
656 <!-- === synopsis ======================================================= -->
657 <!-- The following definitions match those given in the reference
658 documentation for DocBook V3.0
659 -->
660
661 <xsl:variable name="arg.choice.opt.open.str">[</xsl:variable>
662 <xsl:variable name="arg.choice.opt.close.str">]</xsl:variable>
663 <xsl:variable name="arg.choice.req.open.str">{</xsl:variable>
664 <xsl:variable name="arg.choice.req.close.str">}</xsl:variable>
665 <xsl:variable name="arg.choice.plain.open.str"><xsl:text> </xsl:text></xsl:variable>
666 <xsl:variable name="arg.choice.plain.close.str"><xsl:text> </xsl:text></xsl:variable>
667 <xsl:variable name="arg.choice.def.open.str">[</xsl:variable>
668 <xsl:variable name="arg.choice.def.close.str">]</xsl:variable>
669 <xsl:variable name="arg.rep.repeat.str">...</xsl:variable>
670 <xsl:variable name="arg.rep.norepeat.str"></xsl:variable>
671 <xsl:variable name="arg.rep.def.str"></xsl:variable>
672 <xsl:variable name="arg.or.sep"> | </xsl:variable>
673 <xsl:variable name="cmdsynopsis.hanging.indent">4pi</xsl:variable>
674
675 <!-- ====================================================================== -->
676
677 <!--
678 <xsl:template name="xref.g.subst">
679 <xsl:param name="string"></xsl:param>
680 <xsl:param name="target" select="."/>
681 <xsl:variable name="subst">%g</xsl:variable>
682
683 <xsl:choose>
684 <xsl:when test="contains($string, $subst)">
685 <xsl:value-of select="substring-before($string, $subst)"/>
686 <xsl:call-template name="gentext.element.name">
687 <xsl:with-param name="element.name" select="local-name($target)"/>
688 </xsl:call-template>
689 <xsl:call-template name="xref.g.subst">
690 <xsl:with-param name="string"
691 select="substring-after($string, $subst)"/>
692 <xsl:with-param name="target" select="$target"/>
693 </xsl:call-template>
694 </xsl:when>
695 <xsl:otherwise>
696 <xsl:value-of select="$string"/>
697 </xsl:otherwise>
698 </xsl:choose>
699 </xsl:template>
700
701 <xsl:template name="xref.t.subst">
702 <xsl:param name="string"></xsl:param>
703 <xsl:param name="target" select="."/>
704 <xsl:variable name="subst">%t</xsl:variable>
705
706 <xsl:choose>
707 <xsl:when test="contains($string, $subst)">
708 <xsl:call-template name="xref.g.subst">
709 <xsl:with-param name="string"
710 select="substring-before($string, $subst)"/>
711 <xsl:with-param name="target" select="$target"/>
712 </xsl:call-template>
713 <xsl:call-template name="title.xref">
714 <xsl:with-param name="target" select="$target"/>
715 </xsl:call-template>
716 <xsl:call-template name="xref.t.subst">
717 <xsl:with-param name="string"
718 select="substring-after($string, $subst)"/>
719 <xsl:with-param name="target" select="$target"/>
720 </xsl:call-template>
721 </xsl:when>
722 <xsl:otherwise>
723 <xsl:call-template name="xref.g.subst">
724 <xsl:with-param name="string" select="$string"/>
725 <xsl:with-param name="target" select="$target"/>
726 </xsl:call-template>
727 </xsl:otherwise>
728 </xsl:choose>
729 </xsl:template>
730
731 <xsl:template name="xref.n.subst">
732 <xsl:param name="string"></xsl:param>
733 <xsl:param name="target" select="."/>
734 <xsl:variable name="subst">%n</xsl:variable>
735
736 <xsl:choose>
737 <xsl:when test="contains($string, $subst)">
738 <xsl:call-template name="xref.t.subst">
739 <xsl:with-param name="string"
740 select="substring-before($string, $subst)"/>
741 <xsl:with-param name="target" select="$target"/>
742 </xsl:call-template>
743 <xsl:call-template name="number.xref">
744 <xsl:with-param name="target" select="$target"/>
745 </xsl:call-template>
746 <xsl:call-template name="xref.t.subst">
747 <xsl:with-param name="string"
748 select="substring-after($string, $subst)"/>
749 <xsl:with-param name="target" select="$target"/>
750 </xsl:call-template>
751 </xsl:when>
752 <xsl:otherwise>
753 <xsl:call-template name="xref.t.subst">
754 <xsl:with-param name="string" select="$string"/>
755 <xsl:with-param name="target" select="$target"/>
756 </xsl:call-template>
757 </xsl:otherwise>
758 </xsl:choose>
759 </xsl:template>
760
761 <xsl:template name="subst.xref.text">
762 <xsl:param name="xref.text"></xsl:param>
763 <xsl:param name="target" select="."/>
764
765 <xsl:call-template name="xref.n.subst">
766 <xsl:with-param name="string" select="$xref.text"/>
767 <xsl:with-param name="target" select="$target"/>
768 </xsl:call-template>
769 </xsl:template>
770 -->
771
772 <!-- ====================================================================== -->
773
774 <xsl:template name="filename-basename">
775 <!-- We assume all filenames are really URIs and use "/" -->
776 <xsl:param name="filename"></xsl:param>
777 <xsl:param name="recurse" select="false()"/>
778
779 <xsl:choose>
780 <xsl:when test="substring-after($filename, '/') != ''">
781 <xsl:call-template name="filename-basename">
782 <xsl:with-param name="filename"
783 select="substring-after($filename, '/')"/>
784 <xsl:with-param name="recurse" select="true()"/>
785 </xsl:call-template>
786 </xsl:when>
787 <xsl:otherwise>
788 <xsl:value-of select="$filename"/>
789 </xsl:otherwise>
790 </xsl:choose>
791 </xsl:template>
792
793 <xsl:template name="filename-extension">
794 <xsl:param name="filename"></xsl:param>
795 <xsl:param name="recurse" select="false()"/>
796
797 <!-- Make sure we only look at the base name... -->
798 <xsl:variable name="basefn">
799 <xsl:choose>
800 <xsl:when test="$recurse">
801 <xsl:value-of select="$filename"/>
802 </xsl:when>
803 <xsl:otherwise>
804 <xsl:call-template name="filename-basename">
805 <xsl:with-param name="filename" select="$filename"/>
806 </xsl:call-template>
807 </xsl:otherwise>
808 </xsl:choose>
809 </xsl:variable>
810
811 <xsl:choose>
812 <xsl:when test="substring-after($basefn, '.') != ''">
813 <xsl:call-template name="filename-extension">
814 <xsl:with-param name="filename"
815 select="substring-after($basefn, '.')"/>
816 <xsl:with-param name="recurse" select="true()"/>
817 </xsl:call-template>
818 </xsl:when>
819 <xsl:when test="$recurse">
820 <xsl:value-of select="$basefn"/>
821 </xsl:when>
822 <xsl:otherwise></xsl:otherwise>
823 </xsl:choose>
824 </xsl:template>
825
826 <!-- ====================================================================== -->
827
828 <doc:template name="select.mediaobject" xmlns="">
829 <refpurpose>Selects and processes an appropriate media object from a list</refpurpose>
830
831 <refdescription>
832 <para>This template takes a list of media objects (usually the
833 children of a mediaobject or inlinemediaobject) and processes
834 the "right" object.</para>
835
836 <para>This template relies on a template named
837 "select.mediaobject.index" to determine which object
838 in the list is appropriate.</para>
839
840 <para>If no acceptable object is located, nothing happens.</para>
841 </refdescription>
842
843 <refparameter>
844 <variablelist>
845 <varlistentry><term>olist</term>
846 <listitem>
847 <para>The node list of potential objects to examine.</para>
848 </listitem>
849 </varlistentry>
850 </variablelist>
851 </refparameter>
852
853 <refreturn>
854 <para>Calls &lt;xsl:apply-templates&gt; on the selected object.</para>
855 </refreturn>
856 </doc:template>
857
858 <xsl:template name="select.mediaobject">
859 <xsl:param name="olist"
860 select="imageobject|imageobjectco
861 |videoobject|audioobject|textobject"/>
862
863 <xsl:variable name="mediaobject.index">
864 <xsl:call-template name="select.mediaobject.index">
865 <xsl:with-param name="olist" select="$olist"/>
866 <xsl:with-param name="count" select="1"/>
867 </xsl:call-template>
868 </xsl:variable>
869
870 <xsl:if test="$mediaobject.index != ''">
871 <xsl:apply-templates select="$olist[position() = $mediaobject.index]"/>
872 </xsl:if>
873 </xsl:template>
874
875 <!-- ====================================================================== -->
876
877 <doc:template name="select.mediaobject.index" xmlns="">
878 <refpurpose>Selects the position of the appropriate media object from a list</refpurpose>
879
880 <refdescription>
881 <para>This template takes a list of media objects (usually the
882 children of a mediaobject or inlinemediaobject) and determines
883 the "right" object. It returns the position of that object
884 to be used by the calling template.</para>
885
886 <para>If the parameter <parameter>use.role.for.mediaobject</parameter>
887 is nonzero, then it first checks for an object with
888 a role attribute of the appropriate value. It takes the first
889 of those. Otherwise, it takes the first acceptable object
890 through a recursive pass through the list.</para>
891
892 <para>This template relies on a template named "is.acceptable.mediaobject"
893 to determine if a given object is an acceptable graphic. The semantics
894 of media objects is that the first acceptable graphic should be used.
895 </para>
896
897 <para>If no acceptable object is located, no index is returned.</para>
898 </refdescription>
899
900 <refparameter>
901 <variablelist>
902 <varlistentry><term>olist</term>
903 <listitem>
904 <para>The node list of potential objects to examine.</para>
905 </listitem>
906 </varlistentry>
907 <varlistentry><term>count</term>
908 <listitem>
909 <para>The position in the list currently being considered by the
910 recursive process.</para>
911 </listitem>
912 </varlistentry>
913 </variablelist>
914 </refparameter>
915
916 <refreturn>
917 <para>Returns the position in the original list of the selected object.</para>
918 </refreturn>
919 </doc:template>
920
921 <xsl:template name="select.mediaobject.index">
922 <xsl:param name="olist"
923 select="imageobject|imageobjectco
924 |videoobject|audioobject|textobject"/>
925 <xsl:param name="count">1</xsl:param>
926
927 <xsl:choose>
928 <!-- Test for objects preferred by role -->
929 <xsl:when test="$use.role.for.mediaobject != 0
930 and $preferred.mediaobject.role != ''
931 and $olist[@role = $preferred.mediaobject.role]">
932
933 <!-- Get the first hit's position index -->
934 <xsl:for-each select="$olist">
935 <xsl:if test="@role = $preferred.mediaobject.role and
936 not(preceding-sibling::*[@role = $preferred.mediaobject.role])">
937 <xsl:value-of select="position()"/>
938 </xsl:if>
939 </xsl:for-each>
940 </xsl:when>
941
942 <xsl:when test="$use.role.for.mediaobject != 0
943 and $olist[@role = $stylesheet.result.type]">
944 <!-- Get the first hit's position index -->
945 <xsl:for-each select="$olist">
946 <xsl:if test="@role = $stylesheet.result.type and
947 not(preceding-sibling::*[@role = $stylesheet.result.type])">
948 <xsl:value-of select="position()"/>
949 </xsl:if>
950 </xsl:for-each>
951 </xsl:when>
952 <!-- Accept 'html' for $stylesheet.result.type = 'xhtml' -->
953 <xsl:when test="$use.role.for.mediaobject != 0
954 and $stylesheet.result.type = 'xhtml'
955 and $olist[@role = 'html']">
956 <!-- Get the first hit's position index -->
957 <xsl:for-each select="$olist">
958 <xsl:if test="@role = 'html' and
959 not(preceding-sibling::*[@role = 'html'])">
960 <xsl:value-of select="position()"/>
961 </xsl:if>
962 </xsl:for-each>
963 </xsl:when>
964
965 <!-- If no selection by role, and there is only one object, use it -->
966 <xsl:when test="count($olist) = 1 and $count = 1">
967 <xsl:value-of select="$count"/>
968 </xsl:when>
969
970 <xsl:otherwise>
971 <!-- Otherwise select first acceptable object -->
972 <xsl:if test="$count &lt;= count($olist)">
973 <xsl:variable name="object" select="$olist[position()=$count]"/>
974
975 <xsl:variable name="useobject">
976 <xsl:choose>
977 <!-- The phrase is used only when contains TeX Math and output is FO -->
978 <xsl:when test="local-name($object)='textobject' and $object/phrase
979 and $object/@role='tex' and $stylesheet.result.type = 'fo'
980 and $tex.math.in.alt != ''">
981 <xsl:text>1</xsl:text>
982 </xsl:when>
983 <!-- The phrase is never used -->
984 <xsl:when test="local-name($object)='textobject' and $object/phrase">
985 <xsl:text>0</xsl:text>
986 </xsl:when>
987 <xsl:when test="local-name($object)='textobject'
988 and $object/ancestor::equation ">
989 <!-- The first textobject is not a reasonable fallback
990 for equation image -->
991 <xsl:text>0</xsl:text>
992 </xsl:when>
993 <!-- The first textobject is a reasonable fallback -->
994 <xsl:when test="local-name($object)='textobject'
995 and $object[not(@role) or @role!='tex']">
996 <xsl:text>1</xsl:text>
997 </xsl:when>
998 <!-- don't use graphic when output is FO, TeX Math is used
999 and there is math in alt element -->
1000 <xsl:when test="$object/ancestor::equation and
1001 $object/ancestor::equation/alt[@role='tex']
1002 and $stylesheet.result.type = 'fo'
1003 and $tex.math.in.alt != ''">
1004 <xsl:text>0</xsl:text>
1005 </xsl:when>
1006 <!-- If there's only one object, use it -->
1007 <xsl:when test="$count = 1 and count($olist) = 1">
1008 <xsl:text>1</xsl:text>
1009 </xsl:when>
1010 <!-- Otherwise, see if this one is a useable graphic -->
1011 <xsl:otherwise>
1012 <xsl:choose>
1013 <!-- peek inside imageobjectco to simplify the test -->
1014 <xsl:when test="local-name($object) = 'imageobjectco'">
1015 <xsl:call-template name="is.acceptable.mediaobject">
1016 <xsl:with-param name="object" select="$object/imageobject"/>
1017 </xsl:call-template>
1018 </xsl:when>
1019 <xsl:otherwise>
1020 <xsl:call-template name="is.acceptable.mediaobject">
1021 <xsl:with-param name="object" select="$object"/>
1022 </xsl:call-template>
1023 </xsl:otherwise>
1024 </xsl:choose>
1025 </xsl:otherwise>
1026 </xsl:choose>
1027 </xsl:variable>
1028
1029 <xsl:choose>
1030 <xsl:when test="$useobject='1'">
1031 <xsl:value-of select="$count"/>
1032 </xsl:when>
1033 <xsl:otherwise>
1034 <xsl:call-template name="select.mediaobject.index">
1035 <xsl:with-param name="olist" select="$olist"/>
1036 <xsl:with-param name="count" select="$count + 1"/>
1037 </xsl:call-template>
1038 </xsl:otherwise>
1039 </xsl:choose>
1040 </xsl:if>
1041 </xsl:otherwise>
1042 </xsl:choose>
1043 </xsl:template>
1044
1045 <doc:template name="is.acceptable.mediaobject" xmlns="">
1046 <refpurpose>Returns '1' if the specified media object is recognized</refpurpose>
1047
1048 <refdescription>
1049 <para>This template examines a media object and returns '1' if the
1050 object is recognized as a graphic.</para>
1051 </refdescription>
1052
1053 <refparameter>
1054 <variablelist>
1055 <varlistentry><term>object</term>
1056 <listitem>
1057 <para>The media object to consider.</para>
1058 </listitem>
1059 </varlistentry>
1060 </variablelist>
1061 </refparameter>
1062
1063 <refreturn>
1064 <para>0 or 1</para>
1065 </refreturn>
1066 </doc:template>
1067
1068 <xsl:template name="is.acceptable.mediaobject">
1069 <xsl:param name="object"></xsl:param>
1070
1071 <xsl:variable name="filename">
1072 <xsl:call-template name="mediaobject.filename">
1073 <xsl:with-param name="object" select="$object"/>
1074 </xsl:call-template>
1075 </xsl:variable>
1076
1077 <xsl:variable name="ext">
1078 <xsl:call-template name="filename-extension">
1079 <xsl:with-param name="filename" select="$filename"/>
1080 </xsl:call-template>
1081 </xsl:variable>
1082
1083 <!-- there will only be one -->
1084 <xsl:variable name="data" select="$object/videodata
1085 |$object/imagedata
1086 |$object/audiodata"/>
1087
1088 <xsl:variable name="format" select="$data/@format"/>
1089
1090 <xsl:variable name="graphic.format">
1091 <xsl:if test="$format">
1092 <xsl:call-template name="is.graphic.format">
1093 <xsl:with-param name="format" select="$format"/>
1094 </xsl:call-template>
1095 </xsl:if>
1096 </xsl:variable>
1097
1098 <xsl:variable name="graphic.ext">
1099 <xsl:if test="$ext">
1100 <xsl:call-template name="is.graphic.extension">
1101 <xsl:with-param name="ext" select="$ext"/>
1102 </xsl:call-template>
1103 </xsl:if>
1104 </xsl:variable>
1105
1106 <xsl:choose>
1107 <xsl:when test="$use.svg = 0 and $format = 'SVG'">0</xsl:when>
1108 <xsl:when xmlns:svg="http://www.w3.org/2000/svg"
1109 test="$use.svg != 0 and $object/svg:*">1</xsl:when>
1110 <xsl:when test="$graphic.format = '1'">1</xsl:when>
1111 <xsl:when test="$graphic.ext = '1'">1</xsl:when>
1112 <xsl:otherwise>0</xsl:otherwise>
1113 </xsl:choose>
1114 </xsl:template>
1115
1116 <xsl:template name="mediaobject.filename">
1117 <xsl:param name="object"></xsl:param>
1118
1119 <xsl:variable name="data" select="$object/videodata
1120 |$object/imagedata
1121 |$object/audiodata
1122 |$object"/>
1123
1124 <xsl:variable name="filename">
1125 <xsl:choose>
1126 <xsl:when test="$data[@fileref]">
1127 <xsl:apply-templates select="$data/@fileref"/>
1128 </xsl:when>
1129 <xsl:when test="$data[@entityref]">
1130 <xsl:value-of select="unparsed-entity-uri($data/@entityref)"/>
1131 </xsl:when>
1132 <xsl:otherwise></xsl:otherwise>
1133 </xsl:choose>
1134 </xsl:variable>
1135
1136 <xsl:variable name="real.ext">
1137 <xsl:call-template name="filename-extension">
1138 <xsl:with-param name="filename" select="$filename"/>
1139 </xsl:call-template>
1140 </xsl:variable>
1141
1142 <xsl:variable name="ext">
1143 <xsl:choose>
1144 <xsl:when test="$real.ext != ''">
1145 <xsl:value-of select="$real.ext"/>
1146 </xsl:when>
1147 <xsl:otherwise>
1148 <xsl:value-of select="$graphic.default.extension"/>
1149 </xsl:otherwise>
1150 </xsl:choose>
1151 </xsl:variable>
1152
1153 <xsl:variable name="graphic.ext">
1154 <xsl:call-template name="is.graphic.extension">
1155 <xsl:with-param name="ext" select="$ext"/>
1156 </xsl:call-template>
1157 </xsl:variable>
1158
1159 <xsl:choose>
1160 <xsl:when test="$real.ext = ''">
1161 <xsl:choose>
1162 <xsl:when test="$ext != ''">
1163 <xsl:value-of select="$filename"/>
1164 <xsl:text>.</xsl:text>
1165 <xsl:value-of select="$ext"/>
1166 </xsl:when>
1167 <xsl:otherwise>
1168 <xsl:value-of select="$filename"/>
1169 </xsl:otherwise>
1170 </xsl:choose>
1171 </xsl:when>
1172 <xsl:when test="not($graphic.ext)">
1173 <xsl:choose>
1174 <xsl:when test="$graphic.default.extension != ''">
1175 <xsl:value-of select="$filename"/>
1176 <xsl:text>.</xsl:text>
1177 <xsl:value-of select="$graphic.default.extension"/>
1178 </xsl:when>
1179 <xsl:otherwise>
1180 <xsl:value-of select="$filename"/>
1181 </xsl:otherwise>
1182 </xsl:choose>
1183 </xsl:when>
1184 <xsl:otherwise>
1185 <xsl:value-of select="$filename"/>
1186 </xsl:otherwise>
1187 </xsl:choose>
1188 </xsl:template>
1189
1190 <!-- ====================================================================== -->
1191
1192 <doc:template name="check.id.unique" xmlns="">
1193 <refpurpose>Warn users about references to non-unique IDs</refpurpose>
1194 <refdescription>
1195 <para>If passed an ID in <varname>linkend</varname>,
1196 <function>check.id.unique</function> prints
1197 a warning message to the user if either the ID does not exist or
1198 the ID is not unique.</para>
1199 </refdescription>
1200 </doc:template>
1201
1202 <xsl:template name="check.id.unique">
1203 <xsl:param name="linkend"></xsl:param>
1204 <xsl:if test="$linkend != ''">
1205 <xsl:variable name="targets" select="key('id',$linkend)"/>
1206 <xsl:variable name="target" select="$targets[1]"/>
1207
1208 <xsl:if test="count($targets)=0">
1209 <xsl:message>
1210 <xsl:text>Error: no ID for constraint linkend: </xsl:text>
1211 <xsl:value-of select="$linkend"/>
1212 <xsl:text>.</xsl:text>
1213 </xsl:message>
1214 <!--
1215 <xsl:message>
1216 <xsl:text>If the ID exists in your document, did your </xsl:text>
1217 <xsl:text>XSLT Processor load the DTD?</xsl:text>
1218 </xsl:message>
1219 -->
1220 </xsl:if>
1221
1222 <xsl:if test="count($targets)>1">
1223 <xsl:message>
1224 <xsl:text>Warning: multiple "IDs" for constraint linkend: </xsl:text>
1225 <xsl:value-of select="$linkend"/>
1226 <xsl:text>.</xsl:text>
1227 </xsl:message>
1228 </xsl:if>
1229 </xsl:if>
1230 </xsl:template>
1231
1232 <doc:template name="check.idref.targets" xmlns="">
1233 <refpurpose>Warn users about incorrectly typed references</refpurpose>
1234 <refdescription>
1235 <para>If passed an ID in <varname>linkend</varname>,
1236 <function>check.idref.targets</function> makes sure that the element
1237 pointed to by the link is one of the elements listed in
1238 <varname>element-list</varname> and warns the user otherwise.</para>
1239 </refdescription>
1240 </doc:template>
1241
1242 <xsl:template name="check.idref.targets">
1243 <xsl:param name="linkend"></xsl:param>
1244 <xsl:param name="element-list"></xsl:param>
1245 <xsl:if test="$linkend != ''">
1246 <xsl:variable name="targets" select="key('id',$linkend)"/>
1247 <xsl:variable name="target" select="$targets[1]"/>
1248
1249 <xsl:if test="count($target) &gt; 0">
1250 <xsl:if test="not(contains(concat(' ', $element-list, ' '), local-name($target)))">
1251 <xsl:message>
1252 <xsl:text>Error: linkend (</xsl:text>
1253 <xsl:value-of select="$linkend"/>
1254 <xsl:text>) points to "</xsl:text>
1255 <xsl:value-of select="local-name($target)"/>
1256 <xsl:text>" not (one of): </xsl:text>
1257 <xsl:value-of select="$element-list"/>
1258 </xsl:message>
1259 </xsl:if>
1260 </xsl:if>
1261 </xsl:if>
1262 </xsl:template>
1263
1264 <!-- ====================================================================== -->
1265 <!-- Procedure Step Numeration -->
1266
1267 <xsl:param name="procedure.step.numeration.formats" select="'1aiAI'"/>
1268
1269 <xsl:template name="procedure.step.numeration">
1270 <xsl:param name="context" select="."/>
1271 <xsl:variable name="format.length"
1272 select="string-length($procedure.step.numeration.formats)"/>
1273 <xsl:choose>
1274 <xsl:when test="local-name($context) = 'substeps'">
1275 <xsl:variable name="ssdepth"
1276 select="count($context/ancestor::substeps)"/>
1277 <xsl:variable name="sstype" select="($ssdepth mod $format.length)+2"/>
1278 <xsl:choose>
1279 <xsl:when test="$sstype &gt; $format.length">
1280 <xsl:value-of select="substring($procedure.step.numeration.formats,1,1)"/>
1281 </xsl:when>
1282 <xsl:otherwise>
1283 <xsl:value-of select="substring($procedure.step.numeration.formats,$sstype,1)"/>
1284 </xsl:otherwise>
1285 </xsl:choose>
1286 </xsl:when>
1287 <xsl:when test="local-name($context) = 'step'">
1288 <xsl:variable name="sdepth"
1289 select="count($context/ancestor::substeps)"/>
1290 <xsl:variable name="stype" select="($sdepth mod $format.length)+1"/>
1291 <xsl:value-of select="substring($procedure.step.numeration.formats,$stype,1)"/>
1292 </xsl:when>
1293 <xsl:otherwise>
1294 <xsl:message>
1295 <xsl:text>Unexpected context in procedure.step.numeration: </xsl:text>
1296 <xsl:value-of select="local-name($context)"/>
1297 </xsl:message>
1298 </xsl:otherwise>
1299 </xsl:choose>
1300 </xsl:template>
1301
1302 <xsl:template match="step" mode="number">
1303 <xsl:param name="rest" select="''"/>
1304 <xsl:param name="recursive" select="1"/>
1305 <xsl:variable name="format">
1306 <xsl:call-template name="procedure.step.numeration"/>
1307 </xsl:variable>
1308 <xsl:variable name="num">
1309 <xsl:number count="step" format="{$format}"/>
1310 </xsl:variable>
1311 <xsl:choose>
1312 <xsl:when test="$recursive != 0 and ancestor::step">
1313 <xsl:apply-templates select="ancestor::step[1]" mode="number">
1314 <xsl:with-param name="rest" select="concat('.', $num, $rest)"/>
1315 </xsl:apply-templates>
1316 </xsl:when>
1317 <xsl:otherwise>
1318 <xsl:value-of select="concat($num, $rest)"/>
1319 </xsl:otherwise>
1320 </xsl:choose>
1321 </xsl:template>
1322
1323 <!-- ====================================================================== -->
1324 <!-- OrderedList Numeration -->
1325
1326 <xsl:template name="orderedlist-starting-number">
1327 <xsl:param name="list" select="."/>
1328
1329 <!-- Need a neutral dbxxx -->
1330 <xsl:variable name="pi-html-start">
1331 <xsl:call-template name="pi-attribute">
1332 <xsl:with-param name="pis"
1333 select="$list/processing-instruction('dbhtml')"/>
1334 <xsl:with-param name="attribute" select="'start'"/>
1335 </xsl:call-template>
1336 </xsl:variable>
1337
1338 <xsl:variable name="pi-fo-start">
1339 <xsl:call-template name="pi-attribute">
1340 <xsl:with-param name="pis"
1341 select="$list/processing-instruction('dbfo')"/>
1342 <xsl:with-param name="attribute" select="'start'"/>
1343 </xsl:call-template>
1344 </xsl:variable>
1345
1346 <xsl:choose>
1347 <xsl:when test="not($list/@continuation = 'continues')">
1348 <xsl:choose>
1349 <xsl:when test="@startingnumber">
1350 <xsl:value-of select="@startingnumber"/>
1351 </xsl:when>
1352 <xsl:when test="$pi-html-start != ''">
1353 <xsl:value-of select="$pi-html-start"/>
1354 </xsl:when>
1355 <xsl:when test="$pi-fo-start != ''">
1356 <xsl:value-of select="$pi-fo-start"/>
1357 </xsl:when>
1358 <xsl:otherwise>1</xsl:otherwise>
1359 </xsl:choose>
1360 </xsl:when>
1361 <xsl:otherwise>
1362 <xsl:variable name="prevlist"
1363 select="$list/preceding::orderedlist[1]"/>
1364 <xsl:choose>
1365 <xsl:when test="count($prevlist) = 0">2</xsl:when>
1366 <xsl:otherwise>
1367 <xsl:variable name="prevlength" select="count($prevlist/listitem)"/>
1368 <xsl:variable name="prevstart">
1369 <xsl:call-template name="orderedlist-starting-number">
1370 <xsl:with-param name="list" select="$prevlist"/>
1371 </xsl:call-template>
1372 </xsl:variable>
1373 <xsl:value-of select="$prevstart + $prevlength"/>
1374 </xsl:otherwise>
1375 </xsl:choose>
1376 </xsl:otherwise>
1377 </xsl:choose>
1378 </xsl:template>
1379
1380 <xsl:template name="orderedlist-item-number">
1381 <!-- context node must be a listitem in an orderedlist -->
1382 <xsl:param name="node" select="."/>
1383
1384 <xsl:choose>
1385 <xsl:when test="$node/@override">
1386 <xsl:value-of select="$node/@override"/>
1387 </xsl:when>
1388 <xsl:when test="$node/preceding-sibling::listitem">
1389 <xsl:variable name="pnum">
1390 <xsl:call-template name="orderedlist-item-number">
1391 <xsl:with-param name="node" select="$node/preceding-sibling::listitem[1]"/>
1392 </xsl:call-template>
1393 </xsl:variable>
1394 <xsl:value-of select="$pnum + 1"/>
1395 </xsl:when>
1396 <xsl:otherwise>
1397 <xsl:call-template name="orderedlist-starting-number">
1398 <xsl:with-param name="list" select="parent::*"/>
1399 </xsl:call-template>
1400 </xsl:otherwise>
1401 </xsl:choose>
1402 </xsl:template>
1403
1404 <xsl:template name="next.numeration">
1405 <xsl:param name="numeration" select="'default'"/>
1406 <xsl:choose>
1407 <!-- Change this list if you want to change the order of numerations -->
1408 <xsl:when test="$numeration = 'arabic'">loweralpha</xsl:when>
1409 <xsl:when test="$numeration = 'loweralpha'">lowerroman</xsl:when>
1410 <xsl:when test="$numeration = 'lowerroman'">upperalpha</xsl:when>
1411 <xsl:when test="$numeration = 'upperalpha'">upperroman</xsl:when>
1412 <xsl:when test="$numeration = 'upperroman'">arabic</xsl:when>
1413 <xsl:otherwise>arabic</xsl:otherwise>
1414 </xsl:choose>
1415 </xsl:template>
1416
1417 <xsl:template name="list.numeration">
1418 <xsl:param name="node" select="."/>
1419
1420 <xsl:choose>
1421 <xsl:when test="$node/@numeration">
1422 <xsl:value-of select="$node/@numeration"/>
1423 </xsl:when>
1424 <xsl:otherwise>
1425 <xsl:choose>
1426 <xsl:when test="$node/ancestor::orderedlist">
1427 <xsl:call-template name="next.numeration">
1428 <xsl:with-param name="numeration">
1429 <xsl:call-template name="list.numeration">
1430 <xsl:with-param name="node" select="$node/ancestor::orderedlist[1]"/>
1431 </xsl:call-template>
1432 </xsl:with-param>
1433 </xsl:call-template>
1434 </xsl:when>
1435 <xsl:otherwise>
1436 <xsl:call-template name="next.numeration"/>
1437 </xsl:otherwise>
1438 </xsl:choose>
1439 </xsl:otherwise>
1440 </xsl:choose>
1441 </xsl:template>
1442
1443 <!-- ====================================================================== -->
1444 <!-- ItemizedList "Numeration" -->
1445
1446 <xsl:template name="next.itemsymbol">
1447 <xsl:param name="itemsymbol" select="'default'"/>
1448 <xsl:choose>
1449 <!-- Change this list if you want to change the order of symbols -->
1450 <xsl:when test="$itemsymbol = 'disc'">circle</xsl:when>
1451 <xsl:when test="$itemsymbol = 'circle'">square</xsl:when>
1452 <xsl:otherwise>disc</xsl:otherwise>
1453 </xsl:choose>
1454 </xsl:template>
1455
1456 <xsl:template name="list.itemsymbol">
1457 <xsl:param name="node" select="."/>
1458
1459 <xsl:choose>
1460 <xsl:when test="@override">
1461 <xsl:value-of select="@override"/>
1462 </xsl:when>
1463 <xsl:when test="$node/@mark">
1464 <xsl:value-of select="$node/@mark"/>
1465 </xsl:when>
1466 <xsl:otherwise>
1467 <xsl:choose>
1468 <xsl:when test="$node/ancestor::itemizedlist">
1469 <xsl:call-template name="next.itemsymbol">
1470 <xsl:with-param name="itemsymbol">
1471 <xsl:call-template name="list.itemsymbol">
1472 <xsl:with-param name="node" select="$node/ancestor::itemizedlist[1]"/>
1473 </xsl:call-template>
1474 </xsl:with-param>
1475 </xsl:call-template>
1476 </xsl:when>
1477 <xsl:otherwise>
1478 <xsl:call-template name="next.itemsymbol"/>
1479 </xsl:otherwise>
1480 </xsl:choose>
1481 </xsl:otherwise>
1482 </xsl:choose>
1483 </xsl:template>
1484
1485 <!-- ====================================================================== -->
1486
1487 <doc:template name="copyright.years" xmlns="">
1488 <refpurpose>Print a set of years with collapsed ranges</refpurpose>
1489
1490 <refdescription>
1491 <para>This template prints a list of year elements with consecutive
1492 years printed as a range. In other words:</para>
1493
1494 <screen><![CDATA[<year>1992</year>
1495 <year>1993</year>
1496 <year>1994</year>]]></screen>
1497
1498 <para>is printed <quote>1992-1994</quote>, whereas:</para>
1499
1500 <screen><![CDATA[<year>1992</year>
1501 <year>1994</year>]]></screen>
1502
1503 <para>is printed <quote>1992, 1994</quote>.</para>
1504
1505 <para>This template assumes that all the year elements contain only
1506 decimal year numbers, that the elements are sorted in increasing
1507 numerical order, that there are no duplicates, and that all the years
1508 are expressed in full <quote>century+year</quote>
1509 (<quote>1999</quote> not <quote>99</quote>) notation.</para>
1510 </refdescription>
1511
1512 <refparameter>
1513 <variablelist>
1514 <varlistentry><term>years</term>
1515 <listitem>
1516 <para>The initial set of year elements.</para>
1517 </listitem>
1518 </varlistentry>
1519 <varlistentry><term>print.ranges</term>
1520 <listitem>
1521 <para>If non-zero, multi-year ranges are collapsed. If zero, all years
1522 are printed discretely.</para>
1523 </listitem>
1524 </varlistentry>
1525 <varlistentry><term>single.year.ranges</term>
1526 <listitem>
1527 <para>If non-zero, two consecutive years will be printed as a range,
1528 otherwise, they will be printed discretely. In other words, a single
1529 year range is <quote>1991-1992</quote> but discretely it's
1530 <quote>1991, 1992</quote>.</para>
1531 </listitem>
1532 </varlistentry>
1533 </variablelist>
1534 </refparameter>
1535
1536 <refreturn>
1537 <para>This template returns the formatted list of years.</para>
1538 </refreturn>
1539 </doc:template>
1540
1541 <xsl:template name="copyright.years">
1542 <xsl:param name="years"/>
1543 <xsl:param name="print.ranges" select="1"/>
1544 <xsl:param name="single.year.ranges" select="0"/>
1545 <xsl:param name="firstyear" select="0"/>
1546 <xsl:param name="nextyear" select="0"/>
1547
1548 <!--
1549 <xsl:message terminate="no">
1550 <xsl:text>CY: </xsl:text>
1551 <xsl:value-of select="count($years)"/>
1552 <xsl:text>, </xsl:text>
1553 <xsl:value-of select="$firstyear"/>
1554 <xsl:text>, </xsl:text>
1555 <xsl:value-of select="$nextyear"/>
1556 <xsl:text>, </xsl:text>
1557 <xsl:value-of select="$print.ranges"/>
1558 <xsl:text>, </xsl:text>
1559 <xsl:value-of select="$single.year.ranges"/>
1560 <xsl:text> (</xsl:text>
1561 <xsl:value-of select="$years[1]"/>
1562 <xsl:text>)</xsl:text>
1563 </xsl:message>
1564 -->
1565
1566 <xsl:choose>
1567 <xsl:when test="$print.ranges = 0 and count($years) &gt; 0">
1568 <xsl:choose>
1569 <xsl:when test="count($years) = 1">
1570 <xsl:apply-templates select="$years[1]" mode="titlepage.mode"/>
1571 </xsl:when>
1572 <xsl:otherwise>
1573 <xsl:apply-templates select="$years[1]" mode="titlepage.mode"/>
1574 <xsl:text>, </xsl:text>
1575 <xsl:call-template name="copyright.years">
1576 <xsl:with-param name="years"
1577 select="$years[position() &gt; 1]"/>
1578 <xsl:with-param name="print.ranges" select="$print.ranges"/>
1579 <xsl:with-param name="single.year.ranges"
1580 select="$single.year.ranges"/>
1581 </xsl:call-template>
1582 </xsl:otherwise>
1583 </xsl:choose>
1584 </xsl:when>
1585 <xsl:when test="count($years) = 0">
1586 <xsl:variable name="lastyear" select="$nextyear - 1"/>
1587 <xsl:choose>
1588 <xsl:when test="$firstyear = 0">
1589 <!-- there weren't any years at all -->
1590 </xsl:when>
1591 <xsl:when test="$firstyear = $lastyear">
1592 <xsl:value-of select="$firstyear"/>
1593 </xsl:when>
1594 <xsl:when test="$single.year.ranges = 0
1595 and $lastyear = $firstyear + 1">
1596 <xsl:value-of select="$firstyear"/>
1597 <xsl:text>, </xsl:text>
1598 <xsl:value-of select="$lastyear"/>
1599 </xsl:when>
1600 <xsl:otherwise>
1601 <xsl:value-of select="$firstyear"/>
1602 <xsl:text>-</xsl:text>
1603 <xsl:value-of select="$lastyear"/>
1604 </xsl:otherwise>
1605 </xsl:choose>
1606 </xsl:when>
1607 <xsl:when test="$firstyear = 0">
1608 <xsl:call-template name="copyright.years">
1609 <xsl:with-param name="years"
1610 select="$years[position() &gt; 1]"/>
1611 <xsl:with-param name="firstyear" select="$years[1]"/>
1612 <xsl:with-param name="nextyear" select="$years[1] + 1"/>
1613 <xsl:with-param name="print.ranges" select="$print.ranges"/>
1614 <xsl:with-param name="single.year.ranges"
1615 select="$single.year.ranges"/>
1616 </xsl:call-template>
1617 </xsl:when>
1618 <xsl:when test="$nextyear = $years[1]">
1619 <xsl:call-template name="copyright.years">
1620 <xsl:with-param name="years"
1621 select="$years[position() &gt; 1]"/>
1622 <xsl:with-param name="firstyear" select="$firstyear"/>
1623 <xsl:with-param name="nextyear" select="$nextyear + 1"/>
1624 <xsl:with-param name="print.ranges" select="$print.ranges"/>
1625 <xsl:with-param name="single.year.ranges"
1626 select="$single.year.ranges"/>
1627 </xsl:call-template>
1628 </xsl:when>
1629 <xsl:otherwise>
1630 <!-- we have years left, but they aren't in the current range -->
1631 <xsl:choose>
1632 <xsl:when test="$nextyear = $firstyear + 1">
1633 <xsl:value-of select="$firstyear"/>
1634 <xsl:text>, </xsl:text>
1635 </xsl:when>
1636 <xsl:when test="$single.year.ranges = 0
1637 and $nextyear = $firstyear + 2">
1638 <xsl:value-of select="$firstyear"/>
1639 <xsl:text>, </xsl:text>
1640 <xsl:value-of select="$nextyear - 1"/>
1641 <xsl:text>, </xsl:text>
1642 </xsl:when>
1643 <xsl:otherwise>
1644 <xsl:value-of select="$firstyear"/>
1645 <xsl:text>-</xsl:text>
1646 <xsl:value-of select="$nextyear - 1"/>
1647 <xsl:text>, </xsl:text>
1648 </xsl:otherwise>
1649 </xsl:choose>
1650 <xsl:call-template name="copyright.years">
1651 <xsl:with-param name="years"
1652 select="$years[position() &gt; 1]"/>
1653 <xsl:with-param name="firstyear" select="$years[1]"/>
1654 <xsl:with-param name="nextyear" select="$years[1] + 1"/>
1655 <xsl:with-param name="print.ranges" select="$print.ranges"/>
1656 <xsl:with-param name="single.year.ranges"
1657 select="$single.year.ranges"/>
1658 </xsl:call-template>
1659 </xsl:otherwise>
1660 </xsl:choose>
1661 </xsl:template>
1662
1663 <!-- ====================================================================== -->
1664
1665 <doc:template name="find.path.params" xmlns="">
1666 <refpurpose>Search in a table for the "best" match for the node</refpurpose>
1667
1668 <refdescription>
1669 <para>This template searches in a table for the value that most-closely
1670 (in the typical best-match sense of XSLT) matches the current (element)
1671 node location.</para>
1672 </refdescription>
1673 </doc:template>
1674
1675 <xsl:template name="find.path.params">
1676 <xsl:param name="node" select="."/>
1677 <xsl:param name="table" select="''"/>
1678 <xsl:param name="location">
1679 <xsl:call-template name="xpath.location">
1680 <xsl:with-param name="node" select="$node"/>
1681 </xsl:call-template>
1682 </xsl:param>
1683
1684 <xsl:variable name="value">
1685 <xsl:call-template name="lookup.key">
1686 <xsl:with-param name="key" select="$location"/>
1687 <xsl:with-param name="table" select="$table"/>
1688 </xsl:call-template>
1689 </xsl:variable>
1690
1691 <xsl:choose>
1692 <xsl:when test="$value != ''">
1693 <xsl:value-of select="$value"/>
1694 </xsl:when>
1695 <xsl:when test="contains($location, '/')">
1696 <xsl:call-template name="find.path.params">
1697 <xsl:with-param name="node" select="$node"/>
1698 <xsl:with-param name="table" select="$table"/>
1699 <xsl:with-param name="location" select="substring-after($location, '/')"/>
1700 </xsl:call-template>
1701 </xsl:when>
1702 </xsl:choose>
1703 </xsl:template>
1704
1705 <xsl:template name="relative-uri">
1706 <xsl:param name="filename" select="."/>
1707 <xsl:param name="destdir" select="''"/>
1708
1709 <xsl:variable name="srcurl">
1710 <xsl:call-template name="strippath">
1711 <xsl:with-param name="filename">
1712 <xsl:call-template name="xml.base.dirs">
1713 <xsl:with-param name="base.elem"
1714 select="$filename/ancestor-or-self::*
1715 [@xml:base != ''][1]"/>
1716 </xsl:call-template>
1717 <xsl:value-of select="$filename"/>
1718 </xsl:with-param>
1719 </xsl:call-template>
1720 </xsl:variable>
1721
1722 <xsl:variable name="srcurl.trimmed">
1723 <xsl:call-template name="trim.common.uri.paths">
1724 <xsl:with-param name="uriA" select="$srcurl"/>
1725 <xsl:with-param name="uriB" select="$destdir"/>
1726 <xsl:with-param name="return" select="'A'"/>
1727 </xsl:call-template>
1728 </xsl:variable>
1729
1730 <xsl:variable name="destdir.trimmed">
1731 <xsl:call-template name="trim.common.uri.paths">
1732 <xsl:with-param name="uriA" select="$srcurl"/>
1733 <xsl:with-param name="uriB" select="$destdir"/>
1734 <xsl:with-param name="return" select="'B'"/>
1735 </xsl:call-template>
1736 </xsl:variable>
1737
1738 <xsl:variable name="depth">
1739 <xsl:call-template name="count.uri.path.depth">
1740 <xsl:with-param name="filename" select="$destdir.trimmed"/>
1741 </xsl:call-template>
1742 </xsl:variable>
1743
1744 <xsl:call-template name="copy-string">
1745 <xsl:with-param name="string" select="'../'"/>
1746 <xsl:with-param name="count" select="$depth"/>
1747 </xsl:call-template>
1748 <xsl:value-of select="$srcurl.trimmed"/>
1749
1750 </xsl:template>
1751
1752 <!-- ===================================== -->
1753
1754 <xsl:template name="xml.base.dirs">
1755 <xsl:param name="base.elem" select="NONODE"/>
1756
1757 <!-- Recursively resolve xml:base attributes, up to a
1758 full path with : in uri -->
1759 <xsl:if test="$base.elem/ancestor::*[@xml:base != ''] and
1760 not(contains($base.elem/@xml:base, ':'))">
1761 <xsl:call-template name="xml.base.dirs">
1762 <xsl:with-param name="base.elem"
1763 select="$base.elem/ancestor::*[@xml:base != ''][1]"/>
1764 </xsl:call-template>
1765 </xsl:if>
1766 <xsl:call-template name="getdir">
1767 <xsl:with-param name="filename" select="$base.elem/@xml:base"/>
1768 </xsl:call-template>
1769
1770 </xsl:template>
1771
1772 <!-- ===================================== -->
1773
1774 <xsl:template name="strippath">
1775 <xsl:param name="filename" select="''"/>
1776 <xsl:choose>
1777 <!-- Leading .. are not eliminated -->
1778 <xsl:when test="starts-with($filename, '../')">
1779 <xsl:value-of select="'../'"/>
1780 <xsl:call-template name="strippath">
1781 <xsl:with-param name="filename" select="substring-after($filename, '../')"/>
1782 </xsl:call-template>
1783 </xsl:when>
1784 <xsl:when test="contains($filename, '/../')">
1785 <xsl:call-template name="strippath">
1786 <xsl:with-param name="filename">
1787 <xsl:call-template name="getdir">
1788 <xsl:with-param name="filename" select="substring-before($filename, '/../')"/>
1789 </xsl:call-template>
1790 <xsl:value-of select="substring-after($filename, '/../')"/>
1791 </xsl:with-param>
1792 </xsl:call-template>
1793 </xsl:when>
1794 <xsl:otherwise>
1795 <xsl:value-of select="$filename"/>
1796 </xsl:otherwise>
1797 </xsl:choose>
1798 </xsl:template>
1799
1800 <!-- ===================================== -->
1801
1802 <xsl:template name="getdir">
1803 <xsl:param name="filename" select="''"/>
1804 <xsl:if test="contains($filename, '/')">
1805 <xsl:value-of select="substring-before($filename, '/')"/>
1806 <xsl:text>/</xsl:text>
1807 <xsl:call-template name="getdir">
1808 <xsl:with-param name="filename" select="substring-after($filename, '/')"/>
1809 </xsl:call-template>
1810 </xsl:if>
1811 </xsl:template>
1812
1813 <!-- ===================================== -->
1814
1815 <doc:template name="string.upper" xmlns="">
1816 <refpurpose>Converts a string to all uppercase letters</refpurpose>
1817
1818 <refdescription>
1819 <para>Given a string, this template does a language-aware conversion
1820 of that string to all uppercase letters, based on the values of the
1821 <literal>lowercase.alpha</literal> and
1822 <literal>uppercase.alpha</literal> gentext keys for the current
1823 locale. It affects only those characters found in the values of
1824 <literal>lowercase.alpha</literal> and
1825 <literal>uppercase.alpha</literal>. All other characters are left
1826 unchanged.</para>
1827 </refdescription>
1828
1829 <refparameter>
1830 <variablelist>
1831 <varlistentry><term>string</term>
1832 <listitem>
1833 <para>The string to convert to uppercase.</para>
1834 </listitem>
1835 </varlistentry>
1836 </variablelist>
1837 </refparameter>
1838 </doc:template>
1839
1840 <xsl:template name="string.upper">
1841 <xsl:param name="string" select="''"/>
1842 <xsl:variable name="lowercase.alpha">
1843 <xsl:call-template name="gentext">
1844 <xsl:with-param name="key" select="'lowercase.alpha'"/>
1845 </xsl:call-template>
1846 </xsl:variable>
1847 <xsl:variable name="uppercase.alpha">
1848 <xsl:call-template name="gentext">
1849 <xsl:with-param name="key" select="'uppercase.alpha'"/>
1850 </xsl:call-template>
1851 </xsl:variable>
1852 <xsl:value-of select="translate($string,$lowercase.alpha,$uppercase.alpha)"/>
1853 </xsl:template>
1854
1855 <!-- ===================================== -->
1856
1857 <doc:template name="string.lower" xmlns="">
1858 <refpurpose>Converts a string to all lowercase letters</refpurpose>
1859
1860 <refdescription>
1861 <para>Given a string, this template does a language-aware conversion
1862 of that string to all lowercase letters, based on the values of the
1863 <literal>uppercase.alpha</literal> and
1864 <literal>lowercase.alpha</literal> gentext keys for the current
1865 locale. It affects only those characters found in the values of
1866 <literal>uppercase.alpha</literal> and
1867 <literal>lowercase.alpha</literal>. All other characters are left
1868 unchanged.</para>
1869 </refdescription>
1870
1871 <refparameter>
1872 <variablelist>
1873 <varlistentry><term>string</term>
1874 <listitem>
1875 <para>The string to convert to lowercase.</para>
1876 </listitem>
1877 </varlistentry>
1878 </variablelist>
1879 </refparameter>
1880 </doc:template>
1881
1882 <xsl:template name="string.lower">
1883 <xsl:param name="string" select="''"/>
1884 <xsl:variable name="uppercase.alpha">
1885 <xsl:call-template name="gentext">
1886 <xsl:with-param name="key" select="'uppercase.alpha'"/>
1887 </xsl:call-template>
1888 </xsl:variable>
1889 <xsl:variable name="lowercase.alpha">
1890 <xsl:call-template name="gentext">
1891 <xsl:with-param name="key" select="'lowercase.alpha'"/>
1892 </xsl:call-template>
1893 </xsl:variable>
1894 <xsl:value-of select="translate($string,$uppercase.alpha,$lowercase.alpha)"/>
1895 </xsl:template>
1896
1897 <!-- ===================================== -->
1898
1899 <doc:template name="select.choice.separator" xmlns="">
1900 <refpurpose>Returns localized choice separator</refpurpose>
1901 <refdescription>
1902 <para>This template enables auto-generation of an appropriate
1903 localized "choice" separator (for example, "and" or "or") before
1904 the final item in an inline list (though it could also be useful
1905 for generating choice separators for non-inline lists).</para>
1906
1907 <para>It currently works by evaluating a processing instruction
1908 (PI) of the form &lt;?dbchoice&#xa0;choice="foo"?> :
1909
1910 <itemizedlist>
1911 <listitem>
1912 <simpara>if the value of the <sgmltag>choice</sgmltag>
1913 pseudo-attribute is "and" or "or", returns a localized "and"
1914 or "or"</simpara>
1915 </listitem>
1916 <listitem>
1917 <simpara>otherwise returns the literal value of the
1918 <sgmltag>choice</sgmltag> pseudo-attribute</simpara>
1919 </listitem>
1920 </itemizedlist>
1921
1922 The latter is provided only as a temporary workaround because the
1923 locale files do not currently have translations for the word
1924 <wordasword>or</wordasword>. So if you want to generate a a
1925 logical "or" separator in French (for example), you currently need
1926 to do this:
1927
1928 <literallayout>&lt;?dbchoice choice="ou"?></literallayout>
1929 </para>
1930
1931 <warning>
1932 <para>The <sgmltag>dbchoice</sgmltag> processing instruction is
1933 an unfortunate hack; support for it may disappear in the future
1934 (particularly if and when a more appropriate means for marking
1935 up "choice" lists becomes available in DocBook).</para>
1936 </warning>
1937 </refdescription>
1938 </doc:template>
1939
1940 <xsl:template name="select.choice.separator">
1941
1942 <xsl:variable name="choice">
1943 <xsl:call-template name="pi-attribute">
1944 <xsl:with-param name="pis" select="processing-instruction('dbchoice')"/>
1945 <xsl:with-param name="attribute">choice</xsl:with-param>
1946 </xsl:call-template>
1947 </xsl:variable>
1948
1949 <xsl:choose>
1950 <!-- if value of $choice is "and" or "or", translate to equivalent in -->
1951 <!-- current locale -->
1952 <xsl:when test="$choice = 'and' or $choice = 'or'">
1953 <xsl:call-template name="gentext">
1954 <xsl:with-param name="key" select="$choice"/>
1955 </xsl:call-template>
1956 </xsl:when>
1957 <!-- otherwise, just output value of $choice, whatever it is -->
1958 <xsl:otherwise>
1959 <xsl:value-of select="$choice"/>
1960 </xsl:otherwise>
1961 </xsl:choose>
1962 </xsl:template>
1963
1964 <!-- ===================================== -->
1965
1966 <doc:template name="evaluate.info.profile" xmlns="">
1967 <refpurpose>Evaluates an info profile</refpurpose>
1968 <refdescription>
1969 <para>This function evaluates an "info profile" matching the XPath
1970 expression given by the <parameter>profile</parameter>
1971 parameter. It relies on the XSLT <function>evaluate()</function>
1972 extension function.</para>
1973
1974 <para>The value of the <parameter>profile</parameter> parameter
1975 can include the literal string <literal>$info</literal>. If found
1976 in the value of the <parameter>profile</parameter> parameter, the
1977 literal string <literal>$info</literal> string is replaced with
1978 the value of the <parameter>info</parameter> parameter, which
1979 should be a set of <replaceable>*info</replaceable> nodes; the
1980 expression is then evaluated using the XSLT
1981 <function>evaluate()</function> extension function.</para>
1982 </refdescription>
1983 <refparameter>
1984 <variablelist>
1985 <varlistentry>
1986 <term>profile</term>
1987 <listitem>
1988 <para>A string representing an XPath expression </para>
1989 </listitem>
1990 </varlistentry>
1991 <varlistentry>
1992 <term>info</term>
1993 <listitem>
1994 <para>A set of *info nodes</para>
1995 </listitem>
1996 </varlistentry>
1997 </variablelist>
1998 </refparameter>
1999
2000 <refreturn>
2001 <para>Returns a node (the result of evaluating the
2002 <parameter>profile</parameter> parameter)</para>
2003 </refreturn>
2004 </doc:template>
2005
2006 <xsl:template name="evaluate.info.profile">
2007 <xsl:param name="profile"/>
2008 <xsl:param name="info"/>
2009 <xsl:choose>
2010 <!-- * xsltproc and Xalan both support dyn:evaluate() -->
2011 <xsl:when test="function-available('dyn:evaluate')">
2012 <xsl:apply-templates
2013 select="dyn:evaluate($profile)" mode="get.refentry.metadata"/>
2014 </xsl:when>
2015 <!-- * Saxon has its own evaluate() & doesn't support dyn:evaluate() -->
2016 <xsl:when test="function-available('saxon:evaluate')">
2017 <xsl:apply-templates
2018 select="saxon:evaluate($profile)" mode="get.refentry.metadata"/>
2019 </xsl:when>
2020 <xsl:otherwise>
2021 <xsl:message terminate="yes">
2022 Error: The "info profiling" mechanism currently requires an XSLT
2023 engine that supports the evaluate() XSLT extension function. Your XSLT
2024 engine does not support it.
2025 </xsl:message>
2026 </xsl:otherwise>
2027 </xsl:choose>
2028 </xsl:template>
2029
2030 <!-- ===================================== -->
2031
2032 <doc:template name="log.message" xmlns="">
2033 <refpurpose>Logs/emits formatted notes and warnings</refpurpose>
2034
2035 <refdescription>
2036 <para>The <function>log.message</function> function is a utility
2037 function for logging/emitting formatted messages&#xa0;– that is,
2038 notes and warnings, along with a given log "level" and an
2039 identifier for the "source" that the message relates to.</para>
2040 </refdescription>
2041
2042 <refparameter>
2043 <variablelist>
2044 <varlistentry>
2045 <term>level</term>
2046 <listitem>
2047 <para>Text to indicate the message level
2048 (<literal>Note</literal> or
2049 <literal>Warning</literal>)</para>
2050 </listitem>
2051 </varlistentry>
2052 <varlistentry>
2053 <term>source</term>
2054 <listitem>
2055 <para>Text to identify source element the
2056 notification/warning relates to</para>
2057 </listitem>
2058 </varlistentry>
2059 <varlistentry>
2060 <term>message</term>
2061 <listitem>
2062 <para>Message to lot/emit</para>
2063 </listitem>
2064 </varlistentry>
2065 <varlistentry>
2066 <term>message-width</term>
2067 <listitem>
2068 <para>Expected maximum message width</para>
2069 </listitem>
2070 </varlistentry>
2071 </variablelist>
2072 </refparameter>
2073 <refreturn>
2074 <para>Outputs a message (generally, to standard error).</para></refreturn>
2075 </doc:template>
2076
2077 <xsl:template name="log.message">
2078 <xsl:param name="level"/>
2079 <xsl:param name="source"/>
2080 <xsl:param name="message"/>
2081 <xsl:param name="message-width">50</xsl:param>
2082 <xsl:message><xsl:value-of
2083 select="$level"/><xsl:text>: </xsl:text><xsl:value-of
2084 select="$message"/><xsl:call-template
2085 name="copy-string">
2086 <xsl:with-param name="string" select="'&#x20;'"/>
2087 <xsl:with-param
2088 name="count"
2089 select="$message-width - string-length($message)"/>
2090 </xsl:call-template><xsl:value-of
2091 select="$source"/></xsl:message>
2092 </xsl:template>
2093
2094 </xsl:stylesheet>