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