OLD | NEW |
| (Empty) |
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: labels.xsl 9664 2012-11-07 20:02:17Z 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 <!-- label markup --> | |
20 | |
21 <doc:mode mode="label.markup" xmlns=""> | |
22 <refpurpose>Provides access to element labels</refpurpose> | |
23 <refdescription id="label.markup-desc"> | |
24 <para>Processing an element in the | |
25 <literal role="mode">label.markup</literal> mode produces the | |
26 element label.</para> | |
27 <para>Trailing punctuation is not added to the label. | |
28 </para> | |
29 </refdescription> | |
30 </doc:mode> | |
31 | |
32 <xsl:template match="*" mode="intralabel.punctuation"> | |
33 <xsl:text>.</xsl:text> | |
34 </xsl:template> | |
35 | |
36 <xsl:template match="*" mode="label.markup"> | |
37 <xsl:param name="verbose" select="1"/> | |
38 <xsl:if test="$verbose"> | |
39 <xsl:message> | |
40 <xsl:text>Request for label of unexpected element: </xsl:text> | |
41 <xsl:value-of select="local-name(.)"/> | |
42 </xsl:message> | |
43 </xsl:if> | |
44 </xsl:template> | |
45 | |
46 <xsl:template match="set|book" mode="label.markup"> | |
47 <xsl:if test="@label"> | |
48 <xsl:value-of select="@label"/> | |
49 </xsl:if> | |
50 </xsl:template> | |
51 | |
52 <xsl:template match="part" mode="label.markup"> | |
53 <xsl:choose> | |
54 <xsl:when test="@label"> | |
55 <xsl:value-of select="@label"/> | |
56 </xsl:when> | |
57 <xsl:when test="string($part.autolabel) != 0"> | |
58 <xsl:variable name="format"> | |
59 <xsl:call-template name="autolabel.format"> | |
60 <xsl:with-param name="format" select="$part.autolabel"/> | |
61 </xsl:call-template> | |
62 </xsl:variable> | |
63 <xsl:number from="book" count="part" format="{$format}"/> | |
64 </xsl:when> | |
65 </xsl:choose> | |
66 </xsl:template> | |
67 | |
68 <xsl:template match="partintro" mode="label.markup"> | |
69 <!-- no label --> | |
70 </xsl:template> | |
71 | |
72 <xsl:template match="preface" mode="label.markup"> | |
73 <xsl:choose> | |
74 <xsl:when test="@label"> | |
75 <xsl:value-of select="@label"/> | |
76 </xsl:when> | |
77 <xsl:when test="string($preface.autolabel) != 0"> | |
78 <xsl:if test="$component.label.includes.part.label != 0 and | |
79 ancestor::part"> | |
80 <xsl:variable name="part.label"> | |
81 <xsl:apply-templates select="ancestor::part" | |
82 mode="label.markup"/> | |
83 </xsl:variable> | |
84 <xsl:if test="$part.label != ''"> | |
85 <xsl:value-of select="$part.label"/> | |
86 <xsl:apply-templates select="ancestor::part" | |
87 mode="intralabel.punctuation"/> | |
88 </xsl:if> | |
89 </xsl:if> | |
90 <xsl:variable name="format"> | |
91 <xsl:call-template name="autolabel.format"> | |
92 <xsl:with-param name="format" select="$preface.autolabel"/> | |
93 </xsl:call-template> | |
94 </xsl:variable> | |
95 <xsl:choose> | |
96 <xsl:when test="$label.from.part != 0 and ancestor::part"> | |
97 <xsl:number from="part" count="preface" format="{$format}" level="any"
/> | |
98 </xsl:when> | |
99 <xsl:otherwise> | |
100 <xsl:number from="book" count="preface" format="{$format}" level="any"
/> | |
101 </xsl:otherwise> | |
102 </xsl:choose> | |
103 </xsl:when> | |
104 </xsl:choose> | |
105 </xsl:template> | |
106 | |
107 <xsl:template match="chapter" mode="label.markup"> | |
108 <xsl:choose> | |
109 <xsl:when test="@label"> | |
110 <xsl:value-of select="@label"/> | |
111 </xsl:when> | |
112 <xsl:when test="string($chapter.autolabel) != 0"> | |
113 <xsl:if test="$component.label.includes.part.label != 0 and | |
114 ancestor::part"> | |
115 <xsl:variable name="part.label"> | |
116 <xsl:apply-templates select="ancestor::part" | |
117 mode="label.markup"/> | |
118 </xsl:variable> | |
119 <xsl:if test="$part.label != ''"> | |
120 <xsl:value-of select="$part.label"/> | |
121 <xsl:apply-templates select="ancestor::part" | |
122 mode="intralabel.punctuation"/> | |
123 </xsl:if> | |
124 </xsl:if> | |
125 <xsl:variable name="format"> | |
126 <xsl:call-template name="autolabel.format"> | |
127 <xsl:with-param name="format" select="$chapter.autolabel"/> | |
128 </xsl:call-template> | |
129 </xsl:variable> | |
130 <xsl:choose> | |
131 <xsl:when test="$label.from.part != 0 and ancestor::part"> | |
132 <xsl:number from="part" count="chapter" format="{$format}" level="any"
/> | |
133 </xsl:when> | |
134 <xsl:otherwise> | |
135 <xsl:number from="book" count="chapter" format="{$format}" level="any"
/> | |
136 </xsl:otherwise> | |
137 </xsl:choose> | |
138 </xsl:when> | |
139 </xsl:choose> | |
140 </xsl:template> | |
141 | |
142 <xsl:template match="appendix" mode="label.markup"> | |
143 <xsl:choose> | |
144 <xsl:when test="@label"> | |
145 <xsl:value-of select="@label"/> | |
146 </xsl:when> | |
147 <xsl:when test="string($appendix.autolabel) != 0"> | |
148 <xsl:if test="$component.label.includes.part.label != 0 and | |
149 ancestor::part"> | |
150 <xsl:variable name="part.label"> | |
151 <xsl:apply-templates select="ancestor::part" | |
152 mode="label.markup"/> | |
153 </xsl:variable> | |
154 <xsl:if test="$part.label != ''"> | |
155 <xsl:value-of select="$part.label"/> | |
156 <xsl:apply-templates select="ancestor::part" | |
157 mode="intralabel.punctuation"/> | |
158 </xsl:if> | |
159 </xsl:if> | |
160 <xsl:variable name="format"> | |
161 <xsl:call-template name="autolabel.format"> | |
162 <xsl:with-param name="format" select="$appendix.autolabel"/> | |
163 </xsl:call-template> | |
164 </xsl:variable> | |
165 <xsl:choose> | |
166 <xsl:when test="$label.from.part != 0 and ancestor::part"> | |
167 <xsl:number from="part" count="appendix" format="{$format}" level="any
"/> | |
168 </xsl:when> | |
169 <xsl:otherwise> | |
170 <xsl:number from="book|article" | |
171 count="appendix" format="{$format}" level="any"/> | |
172 </xsl:otherwise> | |
173 </xsl:choose> | |
174 </xsl:when> | |
175 </xsl:choose> | |
176 </xsl:template> | |
177 | |
178 <xsl:template match="article" mode="label.markup"> | |
179 <xsl:if test="@label"> | |
180 <xsl:value-of select="@label"/> | |
181 </xsl:if> | |
182 </xsl:template> | |
183 | |
184 <xsl:template match="dedication|colophon" mode="label.markup"> | |
185 <xsl:if test="@label"> | |
186 <xsl:value-of select="@label"/> | |
187 </xsl:if> | |
188 </xsl:template> | |
189 | |
190 <xsl:template match="reference" mode="label.markup"> | |
191 <xsl:choose> | |
192 <xsl:when test="@label"> | |
193 <xsl:value-of select="@label"/> | |
194 </xsl:when> | |
195 <xsl:when test="string($reference.autolabel) != 0"> | |
196 <xsl:if test="$component.label.includes.part.label != 0 and | |
197 ancestor::part"> | |
198 <xsl:variable name="part.label"> | |
199 <xsl:apply-templates select="ancestor::part" | |
200 mode="label.markup"/> | |
201 </xsl:variable> | |
202 <xsl:if test="$part.label != ''"> | |
203 <xsl:value-of select="$part.label"/> | |
204 <xsl:apply-templates select="ancestor::part" | |
205 mode="intralabel.punctuation"/> | |
206 </xsl:if> | |
207 </xsl:if> | |
208 <xsl:variable name="format"> | |
209 <xsl:call-template name="autolabel.format"> | |
210 <xsl:with-param name="format" select="$reference.autolabel"/> | |
211 </xsl:call-template> | |
212 </xsl:variable> | |
213 <xsl:choose> | |
214 <xsl:when test="$label.from.part != 0 and ancestor::part"> | |
215 <xsl:number from="part" count="reference" format="{$format}" level="an
y"/> | |
216 </xsl:when> | |
217 <xsl:otherwise> | |
218 <xsl:number from="book" count="reference" format="{$format}" level="an
y"/> | |
219 </xsl:otherwise> | |
220 </xsl:choose> | |
221 </xsl:when> | |
222 </xsl:choose> | |
223 </xsl:template> | |
224 | |
225 <xsl:template match="refentry" mode="label.markup"> | |
226 <xsl:if test="@label"> | |
227 <xsl:value-of select="@label"/> | |
228 </xsl:if> | |
229 </xsl:template> | |
230 | |
231 <xsl:template match="section" mode="label.markup"> | |
232 <!-- if this is a nested section, label the parent --> | |
233 <xsl:if test="local-name(..) = 'section'"> | |
234 <xsl:variable name="parent.section.label"> | |
235 <xsl:call-template name="label.this.section"> | |
236 <xsl:with-param name="section" select=".."/> | |
237 </xsl:call-template> | |
238 </xsl:variable> | |
239 <xsl:if test="$parent.section.label != '0'"> | |
240 <xsl:apply-templates select=".." mode="label.markup"/> | |
241 <xsl:apply-templates select=".." mode="intralabel.punctuation"/> | |
242 </xsl:if> | |
243 </xsl:if> | |
244 | |
245 <!-- if the parent is a component, maybe label that too --> | |
246 <xsl:variable name="parent.is.component"> | |
247 <xsl:call-template name="is.component"> | |
248 <xsl:with-param name="node" select=".."/> | |
249 </xsl:call-template> | |
250 </xsl:variable> | |
251 | |
252 <!-- does this section get labelled? --> | |
253 <xsl:variable name="label"> | |
254 <xsl:call-template name="label.this.section"> | |
255 <xsl:with-param name="section" select="."/> | |
256 </xsl:call-template> | |
257 </xsl:variable> | |
258 | |
259 <xsl:if test="$section.label.includes.component.label != 0 | |
260 and $parent.is.component != 0"> | |
261 <xsl:variable name="parent.label"> | |
262 <xsl:apply-templates select=".." mode="label.markup"/> | |
263 </xsl:variable> | |
264 <xsl:if test="$parent.label != ''"> | |
265 <xsl:apply-templates select=".." mode="label.markup"/> | |
266 <xsl:apply-templates select=".." mode="intralabel.punctuation"/> | |
267 </xsl:if> | |
268 </xsl:if> | |
269 | |
270 <!-- | |
271 <xsl:message> | |
272 test: <xsl:value-of select="$label"/>, <xsl:number count="section"/> | |
273 </xsl:message> | |
274 --> | |
275 | |
276 <xsl:choose> | |
277 <xsl:when test="@label"> | |
278 <xsl:value-of select="@label"/> | |
279 </xsl:when> | |
280 <xsl:when test="$label != 0"> | |
281 <xsl:variable name="format"> | |
282 <xsl:call-template name="autolabel.format"> | |
283 <xsl:with-param name="format" select="$section.autolabel"/> | |
284 </xsl:call-template> | |
285 </xsl:variable> | |
286 <xsl:number format="{$format}" count="section"/> | |
287 </xsl:when> | |
288 </xsl:choose> | |
289 </xsl:template> | |
290 | |
291 <xsl:template match="sect1" mode="label.markup"> | |
292 <!-- if the parent is a component, maybe label that too --> | |
293 <xsl:variable name="parent.is.component"> | |
294 <xsl:call-template name="is.component"> | |
295 <xsl:with-param name="node" select=".."/> | |
296 </xsl:call-template> | |
297 </xsl:variable> | |
298 | |
299 <xsl:variable name="component.label"> | |
300 <xsl:if test="$section.label.includes.component.label != 0 | |
301 and $parent.is.component != 0"> | |
302 <xsl:variable name="parent.label"> | |
303 <xsl:apply-templates select=".." mode="label.markup"/> | |
304 </xsl:variable> | |
305 <xsl:if test="$parent.label != ''"> | |
306 <xsl:apply-templates select=".." mode="label.markup"/> | |
307 <xsl:apply-templates select=".." mode="intralabel.punctuation"/> | |
308 </xsl:if> | |
309 </xsl:if> | |
310 </xsl:variable> | |
311 | |
312 | |
313 <xsl:variable name="is.numbered"> | |
314 <xsl:call-template name="label.this.section"/> | |
315 </xsl:variable> | |
316 | |
317 <xsl:choose> | |
318 <xsl:when test="@label"> | |
319 <xsl:value-of select="@label"/> | |
320 </xsl:when> | |
321 <xsl:when test="$is.numbered != 0"> | |
322 <xsl:variable name="format"> | |
323 <xsl:call-template name="autolabel.format"> | |
324 <xsl:with-param name="format" select="$section.autolabel"/> | |
325 </xsl:call-template> | |
326 </xsl:variable> | |
327 <xsl:copy-of select="$component.label"/> | |
328 <xsl:number format="{$format}" count="sect1"/> | |
329 </xsl:when> | |
330 </xsl:choose> | |
331 </xsl:template> | |
332 | |
333 <xsl:template match="sect2|sect3|sect4|sect5" mode="label.markup"> | |
334 <!-- label the parent --> | |
335 <xsl:variable name="parent.section.label"> | |
336 <xsl:call-template name="label.this.section"> | |
337 <xsl:with-param name="section" select=".."/> | |
338 </xsl:call-template> | |
339 </xsl:variable> | |
340 <xsl:if test="$parent.section.label != '0'"> | |
341 <xsl:apply-templates select=".." mode="label.markup"/> | |
342 <xsl:apply-templates select=".." mode="intralabel.punctuation"/> | |
343 </xsl:if> | |
344 | |
345 <xsl:variable name="is.numbered"> | |
346 <xsl:call-template name="label.this.section"/> | |
347 </xsl:variable> | |
348 | |
349 <xsl:choose> | |
350 <xsl:when test="@label"> | |
351 <xsl:value-of select="@label"/> | |
352 </xsl:when> | |
353 <xsl:when test="$is.numbered != 0"> | |
354 <xsl:variable name="format"> | |
355 <xsl:call-template name="autolabel.format"> | |
356 <xsl:with-param name="format" select="$section.autolabel"/> | |
357 </xsl:call-template> | |
358 </xsl:variable> | |
359 <xsl:choose> | |
360 <xsl:when test="local-name(.) = 'sect2'"> | |
361 <xsl:number format="{$format}" count="sect2"/> | |
362 </xsl:when> | |
363 <xsl:when test="local-name(.) = 'sect3'"> | |
364 <xsl:number format="{$format}" count="sect3"/> | |
365 </xsl:when> | |
366 <xsl:when test="local-name(.) = 'sect4'"> | |
367 <xsl:number format="{$format}" count="sect4"/> | |
368 </xsl:when> | |
369 <xsl:when test="local-name(.) = 'sect5'"> | |
370 <xsl:number format="{$format}" count="sect5"/> | |
371 </xsl:when> | |
372 <xsl:otherwise> | |
373 <xsl:message>label.markup: this can't happen!</xsl:message> | |
374 </xsl:otherwise> | |
375 </xsl:choose> | |
376 </xsl:when> | |
377 </xsl:choose> | |
378 </xsl:template> | |
379 | |
380 <xsl:template match="bridgehead" mode="label.markup"> | |
381 <!-- FIXME: could we do a better job here? --> | |
382 <xsl:variable name="contsec" | |
383 select="(ancestor::section | |
384 |ancestor::simplesect | |
385 |ancestor::topic | |
386 |ancestor::sect1 | |
387 |ancestor::sect2 | |
388 |ancestor::sect3 | |
389 |ancestor::sect4 | |
390 |ancestor::sect5 | |
391 |ancestor::refsect1 | |
392 |ancestor::refsect2 | |
393 |ancestor::refsect3 | |
394 |ancestor::chapter | |
395 |ancestor::appendix | |
396 |ancestor::preface)[last()]"/> | |
397 | |
398 <xsl:apply-templates select="$contsec" mode="label.markup"/> | |
399 </xsl:template> | |
400 | |
401 <xsl:template match="refsect1" mode="label.markup"> | |
402 <xsl:choose> | |
403 <xsl:when test="@label"> | |
404 <xsl:value-of select="@label"/> | |
405 </xsl:when> | |
406 <xsl:when test="$section.autolabel != 0"> | |
407 <xsl:variable name="format"> | |
408 <xsl:call-template name="autolabel.format"> | |
409 <xsl:with-param name="format" select="$section.autolabel"/> | |
410 </xsl:call-template> | |
411 </xsl:variable> | |
412 <xsl:number count="refsect1" format="{$format}"/> | |
413 </xsl:when> | |
414 </xsl:choose> | |
415 </xsl:template> | |
416 | |
417 <xsl:template match="refsect2|refsect3" mode="label.markup"> | |
418 <!-- label the parent --> | |
419 <xsl:variable name="parent.label"> | |
420 <xsl:apply-templates select=".." mode="label.markup"/> | |
421 </xsl:variable> | |
422 <xsl:if test="$parent.label != ''"> | |
423 <xsl:apply-templates select=".." mode="label.markup"/> | |
424 <xsl:apply-templates select=".." mode="intralabel.punctuation"/> | |
425 </xsl:if> | |
426 | |
427 <xsl:choose> | |
428 <xsl:when test="@label"> | |
429 <xsl:value-of select="@label"/> | |
430 </xsl:when> | |
431 <xsl:when test="$section.autolabel != 0"> | |
432 <xsl:variable name="format"> | |
433 <xsl:call-template name="autolabel.format"> | |
434 <xsl:with-param name="format" select="$section.autolabel"/> | |
435 </xsl:call-template> | |
436 </xsl:variable> | |
437 <xsl:choose> | |
438 <xsl:when test="local-name(.) = 'refsect2'"> | |
439 <xsl:number count="refsect2" format="{$format}"/> | |
440 </xsl:when> | |
441 <xsl:otherwise> | |
442 <xsl:number count="refsect3" format="{$format}"/> | |
443 </xsl:otherwise> | |
444 </xsl:choose> | |
445 </xsl:when> | |
446 </xsl:choose> | |
447 </xsl:template> | |
448 | |
449 <xsl:template match="simplesect" mode="label.markup"> | |
450 <!-- if this is a nested section, label the parent --> | |
451 <xsl:if test="local-name(..) = 'section' | |
452 or local-name(..) = 'sect1' | |
453 or local-name(..) = 'sect2' | |
454 or local-name(..) = 'sect3' | |
455 or local-name(..) = 'sect4' | |
456 or local-name(..) = 'sect5'"> | |
457 <xsl:variable name="parent.section.label"> | |
458 <xsl:apply-templates select=".." mode="label.markup"/> | |
459 </xsl:variable> | |
460 <xsl:if test="$parent.section.label != ''"> | |
461 <xsl:apply-templates select=".." mode="label.markup"/> | |
462 <xsl:apply-templates select=".." mode="intralabel.punctuation"/> | |
463 </xsl:if> | |
464 </xsl:if> | |
465 | |
466 <!-- if the parent is a component, maybe label that too --> | |
467 <xsl:variable name="parent.is.component"> | |
468 <xsl:call-template name="is.component"> | |
469 <xsl:with-param name="node" select=".."/> | |
470 </xsl:call-template> | |
471 </xsl:variable> | |
472 | |
473 <!-- does this section get labelled? --> | |
474 <xsl:variable name="label"> | |
475 <xsl:call-template name="label.this.section"> | |
476 <xsl:with-param name="section" select="."/> | |
477 </xsl:call-template> | |
478 </xsl:variable> | |
479 | |
480 <xsl:if test="$section.label.includes.component.label != 0 | |
481 and $parent.is.component != 0"> | |
482 <xsl:variable name="parent.label"> | |
483 <xsl:apply-templates select=".." mode="label.markup"/> | |
484 </xsl:variable> | |
485 <xsl:if test="$parent.label != ''"> | |
486 <xsl:apply-templates select=".." mode="label.markup"/> | |
487 <xsl:apply-templates select=".." mode="intralabel.punctuation"/> | |
488 </xsl:if> | |
489 </xsl:if> | |
490 | |
491 <xsl:choose> | |
492 <xsl:when test="@label"> | |
493 <xsl:value-of select="@label"/> | |
494 </xsl:when> | |
495 <xsl:when test="$label != 0"> | |
496 <xsl:variable name="format"> | |
497 <xsl:call-template name="autolabel.format"> | |
498 <xsl:with-param name="format" select="$section.autolabel"/> | |
499 </xsl:call-template> | |
500 </xsl:variable> | |
501 <xsl:number format="{$format}" count="simplesect"/> | |
502 </xsl:when> | |
503 </xsl:choose> | |
504 </xsl:template> | |
505 | |
506 <xsl:template match="topic" mode="label.markup"> | |
507 <!-- topics are not numbered by default --> | |
508 </xsl:template> | |
509 | |
510 <xsl:template match="qandadiv" mode="label.markup"> | |
511 <xsl:variable name="lparent" select="(ancestor::set | |
512 |ancestor::book | |
513 |ancestor::chapter | |
514 |ancestor::appendix | |
515 |ancestor::preface | |
516 |ancestor::section | |
517 |ancestor::simplesect | |
518 |ancestor::sect1 | |
519 |ancestor::sect2 | |
520 |ancestor::sect3 | |
521 |ancestor::sect4 | |
522 |ancestor::sect5 | |
523 |ancestor::refsect1 | |
524 |ancestor::refsect2 | |
525 |ancestor::refsect3)[last()]"/> | |
526 | |
527 <xsl:variable name="lparent.prefix"> | |
528 <xsl:apply-templates select="$lparent" mode="label.markup"/> | |
529 </xsl:variable> | |
530 | |
531 <xsl:variable name="prefix"> | |
532 <xsl:if test="$qanda.inherit.numeration != 0"> | |
533 <xsl:if test="$lparent.prefix != ''"> | |
534 <xsl:apply-templates select="$lparent" mode="label.markup"/> | |
535 <xsl:apply-templates select="$lparent" mode="intralabel.punctuation"/> | |
536 </xsl:if> | |
537 </xsl:if> | |
538 </xsl:variable> | |
539 | |
540 <xsl:choose> | |
541 <xsl:when test="$qandadiv.autolabel != 0"> | |
542 <xsl:variable name="format"> | |
543 <xsl:call-template name="autolabel.format"> | |
544 <xsl:with-param name="format" select="$qandadiv.autolabel"/> | |
545 </xsl:call-template> | |
546 </xsl:variable> | |
547 <xsl:value-of select="$prefix"/> | |
548 <xsl:number level="multiple" count="qandadiv" format="{$format}"/> | |
549 </xsl:when> | |
550 </xsl:choose> | |
551 </xsl:template> | |
552 | |
553 <xsl:template match="question|answer" mode="label.markup"> | |
554 <xsl:variable name="lparent" select="(ancestor::set | |
555 |ancestor::book | |
556 |ancestor::chapter | |
557 |ancestor::appendix | |
558 |ancestor::preface | |
559 |ancestor::section | |
560 |ancestor::simplesect | |
561 |ancestor::sect1 | |
562 |ancestor::sect2 | |
563 |ancestor::sect3 | |
564 |ancestor::sect4 | |
565 |ancestor::sect5 | |
566 |ancestor::refsect1 | |
567 |ancestor::refsect2 | |
568 |ancestor::refsect3)[last()]"/> | |
569 | |
570 <xsl:variable name="lparent.prefix"> | |
571 <xsl:apply-templates select="$lparent" mode="label.markup"/> | |
572 </xsl:variable> | |
573 | |
574 <xsl:variable name="prefix"> | |
575 <xsl:if test="$qanda.inherit.numeration != 0"> | |
576 <xsl:choose> | |
577 <xsl:when test="ancestor::qandadiv"> | |
578 <xsl:variable name="div.label"> | |
579 <xsl:apply-templates select="ancestor::qandadiv[1]" mode="label.mark
up"/> | |
580 </xsl:variable> | |
581 <xsl:if test="string-length($div.label) != 0"> | |
582 <xsl:copy-of select="$div.label"/> | |
583 <xsl:apply-templates select="ancestor::qandadiv[1]" | |
584 mode="intralabel.punctuation"/> | |
585 </xsl:if> | |
586 </xsl:when> | |
587 <xsl:when test="$lparent.prefix != ''"> | |
588 <xsl:apply-templates select="$lparent" mode="label.markup"/> | |
589 <xsl:apply-templates select="$lparent" mode="intralabel.punctuation"/> | |
590 </xsl:when> | |
591 </xsl:choose> | |
592 </xsl:if> | |
593 </xsl:variable> | |
594 | |
595 <xsl:variable name="inhlabel" | |
596 select="ancestor-or-self::qandaset/@defaultlabel[1]"/> | |
597 | |
598 <xsl:variable name="deflabel"> | |
599 <xsl:choose> | |
600 <xsl:when test="$inhlabel != ''"> | |
601 <xsl:value-of select="$inhlabel"/> | |
602 </xsl:when> | |
603 <xsl:otherwise> | |
604 <xsl:value-of select="$qanda.defaultlabel"/> | |
605 </xsl:otherwise> | |
606 </xsl:choose> | |
607 </xsl:variable> | |
608 | |
609 <xsl:variable name="label" select="label"/> | |
610 | |
611 <xsl:choose> | |
612 <xsl:when test="count($label)>0"> | |
613 <xsl:apply-templates select="$label"/> | |
614 </xsl:when> | |
615 | |
616 <xsl:when test="$deflabel = 'qanda' and self::question"> | |
617 <xsl:call-template name="gentext"> | |
618 <xsl:with-param name="key" select="'Question'"/> | |
619 </xsl:call-template> | |
620 </xsl:when> | |
621 | |
622 <xsl:when test="$deflabel = 'qanda' and self::answer"> | |
623 <xsl:call-template name="gentext"> | |
624 <xsl:with-param name="key" select="'Answer'"/> | |
625 </xsl:call-template> | |
626 </xsl:when> | |
627 | |
628 <xsl:when test="($deflabel = 'qnumber' or | |
629 $deflabel = 'qnumberanda') and self::question"> | |
630 <xsl:call-template name="gentext"> | |
631 <xsl:with-param name="key" select="'Question'"/> | |
632 </xsl:call-template> | |
633 <xsl:text> </xsl:text> | |
634 <xsl:value-of select="$prefix"/> | |
635 <xsl:number level="multiple" count="qandaentry" format="1"/> | |
636 </xsl:when> | |
637 | |
638 <xsl:when test="$deflabel = 'qnumberanda' and self::answer"> | |
639 <xsl:call-template name="gentext"> | |
640 <xsl:with-param name="key" select="'Answer'"/> | |
641 </xsl:call-template> | |
642 </xsl:when> | |
643 | |
644 <xsl:when test="$deflabel = 'number' and self::question"> | |
645 <xsl:value-of select="$prefix"/> | |
646 <xsl:number level="multiple" count="qandaentry" format="1"/> | |
647 </xsl:when> | |
648 </xsl:choose> | |
649 </xsl:template> | |
650 | |
651 <xsl:template match="bibliography|glossary| | |
652 qandaset|index|setindex" mode="label.markup"> | |
653 <xsl:if test="@label"> | |
654 <xsl:value-of select="@label"/> | |
655 </xsl:if> | |
656 </xsl:template> | |
657 | |
658 <xsl:template match="figure|table|example" mode="label.markup"> | |
659 <xsl:variable name="pchap" | |
660 select="(ancestor::chapter | |
661 |ancestor::appendix | |
662 |ancestor::article[ancestor::book])[last()]"/> | |
663 | |
664 <xsl:variable name="prefix"> | |
665 <xsl:if test="count($pchap) > 0"> | |
666 <xsl:apply-templates select="$pchap" mode="label.markup"/> | |
667 </xsl:if> | |
668 </xsl:variable> | |
669 | |
670 <xsl:choose> | |
671 <xsl:when test="@label"> | |
672 <xsl:value-of select="@label"/> | |
673 </xsl:when> | |
674 <xsl:otherwise> | |
675 <xsl:choose> | |
676 <xsl:when test="$prefix != ''"> | |
677 <xsl:apply-templates select="$pchap" mode="label.markup"/> | |
678 <xsl:apply-templates select="$pchap" mode="intralabel.punctuation"/> | |
679 <xsl:number format="1" from="chapter|appendix" level="any"/> | |
680 </xsl:when> | |
681 <xsl:otherwise> | |
682 <xsl:number format="1" from="book|article" level="any"/> | |
683 </xsl:otherwise> | |
684 </xsl:choose> | |
685 </xsl:otherwise> | |
686 </xsl:choose> | |
687 </xsl:template> | |
688 | |
689 <xsl:template match="procedure" mode="label.markup"> | |
690 <xsl:variable name="pchap" | |
691 select="ancestor::chapter | |
692 |ancestor::appendix | |
693 |ancestor::article[ancestor::book]"/> | |
694 | |
695 <xsl:variable name="prefix"> | |
696 <xsl:if test="count($pchap) > 0"> | |
697 <xsl:apply-templates select="$pchap" mode="label.markup"/> | |
698 </xsl:if> | |
699 </xsl:variable> | |
700 | |
701 <xsl:choose> | |
702 <xsl:when test="@label"> | |
703 <xsl:value-of select="@label"/> | |
704 </xsl:when> | |
705 <xsl:when test="$formal.procedures = 0"> | |
706 <!-- No label --> | |
707 </xsl:when> | |
708 <xsl:otherwise> | |
709 <xsl:choose> | |
710 <xsl:when test="count($pchap)>0"> | |
711 <xsl:if test="$prefix != ''"> | |
712 <xsl:apply-templates select="$pchap" mode="label.markup"/> | |
713 <xsl:apply-templates select="$pchap" mode="intralabel.punctuation"/> | |
714 </xsl:if> | |
715 <xsl:number count="procedure[title]" format="1" | |
716 from="chapter|appendix" level="any"/> | |
717 </xsl:when> | |
718 <xsl:otherwise> | |
719 <xsl:number count="procedure[title]" format="1" | |
720 from="book|article" level="any"/> | |
721 </xsl:otherwise> | |
722 </xsl:choose> | |
723 </xsl:otherwise> | |
724 </xsl:choose> | |
725 </xsl:template> | |
726 | |
727 <xsl:template match="equation" mode="label.markup"> | |
728 <xsl:variable name="pchap" | |
729 select="ancestor::chapter | |
730 |ancestor::appendix | |
731 |ancestor::article[ancestor::book]"/> | |
732 | |
733 <xsl:variable name="prefix"> | |
734 <xsl:if test="count($pchap) > 0"> | |
735 <xsl:apply-templates select="$pchap" mode="label.markup"/> | |
736 </xsl:if> | |
737 </xsl:variable> | |
738 | |
739 <xsl:choose> | |
740 <xsl:when test="@label"> | |
741 <xsl:value-of select="@label"/> | |
742 </xsl:when> | |
743 <xsl:otherwise> | |
744 <xsl:choose> | |
745 <xsl:when test="count($pchap)>0"> | |
746 <xsl:if test="$prefix != ''"> | |
747 <xsl:apply-templates select="$pchap" mode="label.markup"/> | |
748 <xsl:apply-templates select="$pchap" mode="intralabel.punctuation"/> | |
749 </xsl:if> | |
750 <xsl:number format="1" count="equation" | |
751 from="chapter|appendix" level="any"/> | |
752 </xsl:when> | |
753 <xsl:otherwise> | |
754 <xsl:number format="1" count="equation" | |
755 from="book|article" level="any"/> | |
756 </xsl:otherwise> | |
757 </xsl:choose> | |
758 </xsl:otherwise> | |
759 </xsl:choose> | |
760 </xsl:template> | |
761 | |
762 <xsl:template match="orderedlist/listitem" mode="label.markup"> | |
763 <xsl:variable name="numeration"> | |
764 <xsl:call-template name="list.numeration"> | |
765 <xsl:with-param name="node" select="parent::orderedlist"/> | |
766 </xsl:call-template> | |
767 </xsl:variable> | |
768 | |
769 <xsl:variable name="type"> | |
770 <xsl:choose> | |
771 <xsl:when test="$numeration='arabic'">1</xsl:when> | |
772 <xsl:when test="$numeration='loweralpha'">a</xsl:when> | |
773 <xsl:when test="$numeration='lowerroman'">i</xsl:when> | |
774 <xsl:when test="$numeration='upperalpha'">A</xsl:when> | |
775 <xsl:when test="$numeration='upperroman'">I</xsl:when> | |
776 <!-- What!? This should never happen --> | |
777 <xsl:otherwise> | |
778 <xsl:message> | |
779 <xsl:text>Unexpected numeration: </xsl:text> | |
780 <xsl:value-of select="$numeration"/> | |
781 </xsl:message> | |
782 <xsl:value-of select="1."/> | |
783 </xsl:otherwise> | |
784 </xsl:choose> | |
785 </xsl:variable> | |
786 | |
787 <xsl:variable name="item-number"> | |
788 <xsl:call-template name="orderedlist-item-number"/> | |
789 </xsl:variable> | |
790 | |
791 <xsl:number value="$item-number" format="{$type}"/> | |
792 </xsl:template> | |
793 | |
794 <xsl:template match="production" mode="label.markup"> | |
795 <xsl:number count="production" level="any"/> | |
796 </xsl:template> | |
797 | |
798 <xsl:template match="abstract" mode="label.markup"> | |
799 <!-- nop --> | |
800 </xsl:template> | |
801 | |
802 <xsl:template match="sidebar" mode="label.markup"> | |
803 <!-- nop --> | |
804 </xsl:template> | |
805 | |
806 <xsl:template match="glossdiv|glosslist" mode="label.markup"> | |
807 <!-- nop --> | |
808 </xsl:template> | |
809 | |
810 <xsl:template match="glossentry" mode="label.markup"> | |
811 <!-- nop --> | |
812 </xsl:template> | |
813 | |
814 <!-- ============================================================ --> | |
815 | |
816 <xsl:template name="label.this.section"> | |
817 <xsl:param name="section" select="."/> | |
818 | |
819 <xsl:variable name="level"> | |
820 <xsl:call-template name="section.level"/> | |
821 </xsl:variable> | |
822 | |
823 <xsl:choose> | |
824 <xsl:when test="$level <= $section.autolabel.max.depth"> | |
825 <xsl:value-of select="$section.autolabel"/> | |
826 </xsl:when> | |
827 <xsl:otherwise>0</xsl:otherwise> | |
828 </xsl:choose> | |
829 </xsl:template> | |
830 | |
831 <doc:template name="label.this.section" xmlns=""> | |
832 <refpurpose>Returns true if $section should be labelled</refpurpose> | |
833 <refdescription id="label.this.section-desc"> | |
834 <para>Returns true if the specified section should be labelled. | |
835 By default, this template returns zero unless | |
836 the section level is less than or equal to the value of the | |
837 <literal>$section.autolabel.max.depth</literal> parameter, in | |
838 which case it returns | |
839 <literal>$section.autolabel</literal>. | |
840 Custom stylesheets may override it to get more selective behavior.</para> | |
841 </refdescription> | |
842 </doc:template> | |
843 | |
844 <!-- ============================================================ --> | |
845 | |
846 <xsl:template name="default.autolabel.format"> | |
847 <xsl:param name="context" select="."/> | |
848 <xsl:choose> | |
849 <xsl:when test="local-name($context) = 'appendix'"> | |
850 <xsl:value-of select="'A'"/> | |
851 </xsl:when> | |
852 <xsl:when test="local-name($context) = 'part'"> | |
853 <xsl:value-of select="'I'"/> | |
854 </xsl:when> | |
855 <xsl:otherwise>1</xsl:otherwise> | |
856 </xsl:choose> | |
857 </xsl:template> | |
858 | |
859 <xsl:template name="autolabel.format"> | |
860 <xsl:param name="context" select="."/> | |
861 <xsl:param name="format"/> | |
862 | |
863 <xsl:choose> | |
864 <xsl:when test="string($format) != 0"> | |
865 <xsl:choose> | |
866 <xsl:when test="string($format)='arabic' or $format='1'">1</xsl:when> | |
867 <xsl:when test="$format='loweralpha' or $format='a'"> | |
868 <xsl:value-of select="'a'"/> | |
869 </xsl:when> | |
870 <xsl:when test="$format='lowerroman' or $format='i'"> | |
871 <xsl:value-of select="'i'"/> | |
872 </xsl:when> | |
873 <xsl:when test="$format='upperalpha' or $format='A'"> | |
874 <xsl:value-of select="'A'"/> | |
875 </xsl:when> | |
876 <xsl:when test="$format='upperroman' or $format='I'"> | |
877 <xsl:value-of select="'I'"/> | |
878 </xsl:when> | |
879 <xsl:when test="$format='arabicindic' or $format='١'"> | |
880 <xsl:value-of select="'١'"/> | |
881 </xsl:when> | |
882 <xsl:otherwise> | |
883 <xsl:message> | |
884 <xsl:text>Unexpected </xsl:text><xsl:value-of select="local-name(.)"
/><xsl:text>.autolabel value: </xsl:text> | |
885 <xsl:value-of select="$format"/><xsl:text>; using default.</xsl:text
> | |
886 </xsl:message> | |
887 <xsl:call-template name="default.autolabel.format"/> | |
888 </xsl:otherwise> | |
889 </xsl:choose> | |
890 </xsl:when> | |
891 </xsl:choose> | |
892 </xsl:template> | |
893 | |
894 <doc:template name="autolabel.format" xmlns=""> | |
895 <refpurpose>Returns format for autolabel parameters</refpurpose> | |
896 <refdescription id="autolabel.format-desc"> | |
897 <para>Returns format passed as parameter if non zero. Supported | |
898 format are 'arabic' or '1', 'loweralpha' or 'a', 'lowerroman' or 'i', | |
899 'upperlapha' or 'A', 'upperroman' or 'I', 'arabicindic' or '١'. | |
900 If its not one of these then | |
901 returns the default format.</para> | |
902 </refdescription> | |
903 </doc:template> | |
904 | |
905 <!-- ============================================================ --> | |
906 | |
907 </xsl:stylesheet> | |
OLD | NEW |