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