docbook_xsl_wrapper 0.1.2 → 0.5.2

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