Debian Codegraph @

xsl/common/common.xsl

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