source: stylesheets/lfs-xsl/docbook-xsl-snapshot/common/labels.xsl@ 65b2904

10.0 10.1 11.0 11.1 11.2 11.3 12.0 12.1 6.3 6.3-rc1 6.3-rc2 6.3-rc3 7.10 7.4 7.5 7.6 7.6-blfs 7.6-systemd 7.7 7.8 7.9 8.0 8.1 8.2 8.3 8.4 9.0 9.1 basic bdubbs/svn elogind gnome kde5-13430 kde5-14269 kde5-14686 kea ken/TL2024 ken/inkscape-core-mods ken/tuningfonts krejzi/svn lazarus lxqt nosym perl-modules plabs/newcss plabs/python-mods python3.11 qt5new rahul/power-profiles-daemon renodr/vulkan-addition systemd-11177 systemd-13485 trunk upgradedb xry111/intltool xry111/llvm18 xry111/soup3 xry111/test-20220226 xry111/xf86-video-removal
Last change on this file since 65b2904 was 65b2904, checked in by Manuel Canales Esparcia <manuel@…>, 17 years ago

Added LFS-XSL Stylesheets files.

git-svn-id: svn://svn.linuxfromscratch.org/BLFS/trunk/BOOK@6840 af4574ff-66df-0310-9fd7-8a98e5e911e0

  • Property mode set to 100644
File size: 29.0 KB
Line 
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$
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
26element 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:variable name="format">
197 <xsl:call-template name="autolabel.format">
198 <xsl:with-param name="format" select="$reference.autolabel"/>
199 </xsl:call-template>
200 </xsl:variable>
201 <xsl:number from="book" count="reference" format="{$format}" level="any"/>
202 </xsl:when>
203 </xsl:choose>
204</xsl:template>
205
206<xsl:template match="refentry" mode="label.markup">
207 <xsl:if test="@label">
208 <xsl:value-of select="@label"/>
209 </xsl:if>
210</xsl:template>
211
212<xsl:template match="section" mode="label.markup">
213 <!-- if this is a nested section, label the parent -->
214 <xsl:if test="local-name(..) = 'section'">
215 <xsl:variable name="parent.section.label">
216 <xsl:call-template name="label.this.section">
217 <xsl:with-param name="section" select=".."/>
218 </xsl:call-template>
219 </xsl:variable>
220 <xsl:if test="$parent.section.label != '0'">
221 <xsl:apply-templates select=".." mode="label.markup"/>
222 <xsl:apply-templates select=".." mode="intralabel.punctuation"/>
223 </xsl:if>
224 </xsl:if>
225
226 <!-- if the parent is a component, maybe label that too -->
227 <xsl:variable name="parent.is.component">
228 <xsl:call-template name="is.component">
229 <xsl:with-param name="node" select=".."/>
230 </xsl:call-template>
231 </xsl:variable>
232
233 <!-- does this section get labelled? -->
234 <xsl:variable name="label">
235 <xsl:call-template name="label.this.section">
236 <xsl:with-param name="section" select="."/>
237 </xsl:call-template>
238 </xsl:variable>
239
240 <xsl:if test="$section.label.includes.component.label != 0
241 and $parent.is.component != 0">
242 <xsl:variable name="parent.label">
243 <xsl:apply-templates select=".." mode="label.markup"/>
244 </xsl:variable>
245 <xsl:if test="$parent.label != ''">
246 <xsl:apply-templates select=".." mode="label.markup"/>
247 <xsl:apply-templates select=".." mode="intralabel.punctuation"/>
248 </xsl:if>
249 </xsl:if>
250
251<!--
252 <xsl:message>
253 test: <xsl:value-of select="$label"/>, <xsl:number count="section"/>
254 </xsl:message>
255-->
256
257 <xsl:choose>
258 <xsl:when test="@label">
259 <xsl:value-of select="@label"/>
260 </xsl:when>
261 <xsl:when test="$label != 0">
262 <xsl:variable name="format">
263 <xsl:call-template name="autolabel.format">
264 <xsl:with-param name="format" select="$section.autolabel"/>
265 </xsl:call-template>
266 </xsl:variable>
267 <xsl:number format="{$format}" count="section"/>
268 </xsl:when>
269 </xsl:choose>
270</xsl:template>
271
272<xsl:template match="sect1" mode="label.markup">
273 <!-- if the parent is a component, maybe label that too -->
274 <xsl:variable name="parent.is.component">
275 <xsl:call-template name="is.component">
276 <xsl:with-param name="node" select=".."/>
277 </xsl:call-template>
278 </xsl:variable>
279
280 <xsl:variable name="component.label">
281 <xsl:if test="$section.label.includes.component.label != 0
282 and $parent.is.component != 0">
283 <xsl:variable name="parent.label">
284 <xsl:apply-templates select=".." mode="label.markup"/>
285 </xsl:variable>
286 <xsl:if test="$parent.label != ''">
287 <xsl:apply-templates select=".." mode="label.markup"/>
288 <xsl:apply-templates select=".." mode="intralabel.punctuation"/>
289 </xsl:if>
290 </xsl:if>
291 </xsl:variable>
292
293
294 <xsl:variable name="is.numbered">
295 <xsl:call-template name="label.this.section"/>
296 </xsl:variable>
297
298 <xsl:choose>
299 <xsl:when test="@label">
300 <xsl:value-of select="@label"/>
301 </xsl:when>
302 <xsl:when test="$is.numbered != 0">
303 <xsl:variable name="format">
304 <xsl:call-template name="autolabel.format">
305 <xsl:with-param name="format" select="$section.autolabel"/>
306 </xsl:call-template>
307 </xsl:variable>
308 <xsl:copy-of select="$component.label"/>
309 <xsl:number format="{$format}" count="sect1"/>
310 </xsl:when>
311 </xsl:choose>
312</xsl:template>
313
314<xsl:template match="sect2|sect3|sect4|sect5" mode="label.markup">
315 <!-- label the parent -->
316 <xsl:variable name="parent.section.label">
317 <xsl:call-template name="label.this.section">
318 <xsl:with-param name="section" select=".."/>
319 </xsl:call-template>
320 </xsl:variable>
321 <xsl:if test="$parent.section.label != '0'">
322 <xsl:apply-templates select=".." mode="label.markup"/>
323 <xsl:apply-templates select=".." mode="intralabel.punctuation"/>
324 </xsl:if>
325
326 <xsl:variable name="is.numbered">
327 <xsl:call-template name="label.this.section"/>
328 </xsl:variable>
329
330 <xsl:choose>
331 <xsl:when test="@label">
332 <xsl:value-of select="@label"/>
333 </xsl:when>
334 <xsl:when test="$is.numbered != 0">
335 <xsl:variable name="format">
336 <xsl:call-template name="autolabel.format">
337 <xsl:with-param name="format" select="$section.autolabel"/>
338 </xsl:call-template>
339 </xsl:variable>
340 <xsl:choose>
341 <xsl:when test="local-name(.) = 'sect2'">
342 <xsl:number format="{$format}" count="sect2"/>
343 </xsl:when>
344 <xsl:when test="local-name(.) = 'sect3'">
345 <xsl:number format="{$format}" count="sect3"/>
346 </xsl:when>
347 <xsl:when test="local-name(.) = 'sect4'">
348 <xsl:number format="{$format}" count="sect4"/>
349 </xsl:when>
350 <xsl:when test="local-name(.) = 'sect5'">
351 <xsl:number format="{$format}" count="sect5"/>
352 </xsl:when>
353 <xsl:otherwise>
354 <xsl:message>label.markup: this can't happen!</xsl:message>
355 </xsl:otherwise>
356 </xsl:choose>
357 </xsl:when>
358 </xsl:choose>
359</xsl:template>
360
361<xsl:template match="bridgehead" mode="label.markup">
362 <!-- FIXME: could we do a better job here? -->
363 <xsl:variable name="contsec"
364 select="(ancestor::section
365 |ancestor::simplesect
366 |ancestor::sect1
367 |ancestor::sect2
368 |ancestor::sect3
369 |ancestor::sect4
370 |ancestor::sect5
371 |ancestor::refsect1
372 |ancestor::refsect2
373 |ancestor::refsect3
374 |ancestor::chapter
375 |ancestor::appendix
376 |ancestor::preface)[last()]"/>
377
378 <xsl:apply-templates select="$contsec" mode="label.markup"/>
379</xsl:template>
380
381<xsl:template match="refsect1" mode="label.markup">
382 <xsl:choose>
383 <xsl:when test="@label">
384 <xsl:value-of select="@label"/>
385 </xsl:when>
386 <xsl:when test="$section.autolabel != 0">
387 <xsl:variable name="format">
388 <xsl:call-template name="autolabel.format">
389 <xsl:with-param name="format" select="$section.autolabel"/>
390 </xsl:call-template>
391 </xsl:variable>
392 <xsl:number count="refsect1" format="{$format}"/>
393 </xsl:when>
394 </xsl:choose>
395</xsl:template>
396
397<xsl:template match="refsect2|refsect3" mode="label.markup">
398 <!-- label the parent -->
399 <xsl:variable name="parent.label">
400 <xsl:apply-templates select=".." mode="label.markup"/>
401 </xsl:variable>
402 <xsl:if test="$parent.label != ''">
403 <xsl:apply-templates select=".." mode="label.markup"/>
404 <xsl:apply-templates select=".." mode="intralabel.punctuation"/>
405 </xsl:if>
406
407 <xsl:choose>
408 <xsl:when test="@label">
409 <xsl:value-of select="@label"/>
410 </xsl:when>
411 <xsl:when test="$section.autolabel != 0">
412 <xsl:variable name="format">
413 <xsl:call-template name="autolabel.format">
414 <xsl:with-param name="format" select="$section.autolabel"/>
415 </xsl:call-template>
416 </xsl:variable>
417 <xsl:choose>
418 <xsl:when test="local-name(.) = 'refsect2'">
419 <xsl:number count="refsect2" format="{$format}"/>
420 </xsl:when>
421 <xsl:otherwise>
422 <xsl:number count="refsect3" format="{$format}"/>
423 </xsl:otherwise>
424 </xsl:choose>
425 </xsl:when>
426 </xsl:choose>
427</xsl:template>
428
429<xsl:template match="simplesect" mode="label.markup">
430 <!-- if this is a nested section, label the parent -->
431 <xsl:if test="local-name(..) = 'section'
432 or local-name(..) = 'sect1'
433 or local-name(..) = 'sect2'
434 or local-name(..) = 'sect3'
435 or local-name(..) = 'sect4'
436 or local-name(..) = 'sect5'">
437 <xsl:variable name="parent.section.label">
438 <xsl:apply-templates select=".." mode="label.markup"/>
439 </xsl:variable>
440 <xsl:if test="$parent.section.label != ''">
441 <xsl:apply-templates select=".." mode="label.markup"/>
442 <xsl:apply-templates select=".." mode="intralabel.punctuation"/>
443 </xsl:if>
444 </xsl:if>
445
446 <!-- if the parent is a component, maybe label that too -->
447 <xsl:variable name="parent.is.component">
448 <xsl:call-template name="is.component">
449 <xsl:with-param name="node" select=".."/>
450 </xsl:call-template>
451 </xsl:variable>
452
453 <!-- does this section get labelled? -->
454 <xsl:variable name="label">
455 <xsl:call-template name="label.this.section">
456 <xsl:with-param name="section" select="."/>
457 </xsl:call-template>
458 </xsl:variable>
459
460 <xsl:if test="$section.label.includes.component.label != 0
461 and $parent.is.component != 0">
462 <xsl:variable name="parent.label">
463 <xsl:apply-templates select=".." mode="label.markup"/>
464 </xsl:variable>
465 <xsl:if test="$parent.label != ''">
466 <xsl:apply-templates select=".." mode="label.markup"/>
467 <xsl:apply-templates select=".." mode="intralabel.punctuation"/>
468 </xsl:if>
469 </xsl:if>
470
471 <xsl:choose>
472 <xsl:when test="@label">
473 <xsl:value-of select="@label"/>
474 </xsl:when>
475 <xsl:when test="$label != 0">
476 <xsl:variable name="format">
477 <xsl:call-template name="autolabel.format">
478 <xsl:with-param name="format" select="$section.autolabel"/>
479 </xsl:call-template>
480 </xsl:variable>
481 <xsl:number format="{$format}" count="simplesect"/>
482 </xsl:when>
483 </xsl:choose>
484</xsl:template>
485
486<xsl:template match="qandadiv" mode="label.markup">
487 <xsl:variable name="lparent" select="(ancestor::set
488 |ancestor::book
489 |ancestor::chapter
490 |ancestor::appendix
491 |ancestor::preface
492 |ancestor::section
493 |ancestor::simplesect
494 |ancestor::sect1
495 |ancestor::sect2
496 |ancestor::sect3
497 |ancestor::sect4
498 |ancestor::sect5
499 |ancestor::refsect1
500 |ancestor::refsect2
501 |ancestor::refsect3)[last()]"/>
502
503 <xsl:variable name="lparent.prefix">
504 <xsl:apply-templates select="$lparent" mode="label.markup"/>
505 </xsl:variable>
506
507 <xsl:variable name="prefix">
508 <xsl:if test="$qanda.inherit.numeration != 0">
509 <xsl:if test="$lparent.prefix != ''">
510 <xsl:apply-templates select="$lparent" mode="label.markup"/>
511 <xsl:apply-templates select="$lparent" mode="intralabel.punctuation"/>
512 </xsl:if>
513 </xsl:if>
514 </xsl:variable>
515
516 <xsl:choose>
517 <xsl:when test="$qandadiv.autolabel != 0">
518 <xsl:variable name="format">
519 <xsl:call-template name="autolabel.format">
520 <xsl:with-param name="format" select="$qandadiv.autolabel"/>
521 </xsl:call-template>
522 </xsl:variable>
523 <xsl:value-of select="$prefix"/>
524 <xsl:number level="multiple" count="qandadiv" format="{$format}"/>
525 </xsl:when>
526 </xsl:choose>
527</xsl:template>
528
529<xsl:template match="question|answer" mode="label.markup">
530 <xsl:variable name="lparent" select="(ancestor::set
531 |ancestor::book
532 |ancestor::chapter
533 |ancestor::appendix
534 |ancestor::preface
535 |ancestor::section
536 |ancestor::simplesect
537 |ancestor::sect1
538 |ancestor::sect2
539 |ancestor::sect3
540 |ancestor::sect4
541 |ancestor::sect5
542 |ancestor::refsect1
543 |ancestor::refsect2
544 |ancestor::refsect3)[last()]"/>
545
546 <xsl:variable name="lparent.prefix">
547 <xsl:apply-templates select="$lparent" mode="label.markup"/>
548 </xsl:variable>
549
550 <xsl:variable name="prefix">
551 <xsl:if test="$qanda.inherit.numeration != 0">
552 <xsl:choose>
553 <xsl:when test="ancestor::qandadiv">
554 <xsl:apply-templates select="ancestor::qandadiv[1]" mode="label.markup"/>
555 <xsl:apply-templates select="ancestor::qandadiv[1]"
556 mode="intralabel.punctuation"/>
557 </xsl:when>
558 <xsl:when test="$lparent.prefix != ''">
559 <xsl:apply-templates select="$lparent" mode="label.markup"/>
560 <xsl:apply-templates select="$lparent" mode="intralabel.punctuation"/>
561 </xsl:when>
562 </xsl:choose>
563 </xsl:if>
564 </xsl:variable>
565
566 <xsl:variable name="inhlabel"
567 select="ancestor-or-self::qandaset/@defaultlabel[1]"/>
568
569 <xsl:variable name="deflabel">
570 <xsl:choose>
571 <xsl:when test="$inhlabel != ''">
572 <xsl:value-of select="$inhlabel"/>
573 </xsl:when>
574 <xsl:otherwise>
575 <xsl:value-of select="$qanda.defaultlabel"/>
576 </xsl:otherwise>
577 </xsl:choose>
578 </xsl:variable>
579
580 <xsl:variable name="label" select="label"/>
581
582 <xsl:choose>
583 <xsl:when test="count($label)>0">
584 <xsl:apply-templates select="$label"/>
585 </xsl:when>
586
587 <xsl:when test="$deflabel = 'qanda' and local-name(.) = 'question'">
588 <xsl:call-template name="gentext">
589 <xsl:with-param name="key" select="'Question'"/>
590 </xsl:call-template>
591 </xsl:when>
592
593 <xsl:when test="$deflabel = 'qanda' and local-name(.) = 'answer'">
594 <xsl:call-template name="gentext">
595 <xsl:with-param name="key" select="'Answer'"/>
596 </xsl:call-template>
597 </xsl:when>
598
599 <xsl:when test="$deflabel = 'number' and local-name(.) = 'question'">
600 <xsl:value-of select="$prefix"/>
601 <xsl:number level="multiple" count="qandaentry" format="1"/>
602 </xsl:when>
603 </xsl:choose>
604</xsl:template>
605
606<xsl:template match="bibliography|glossary|
607 qandaset|index|setindex" mode="label.markup">
608 <xsl:if test="@label">
609 <xsl:value-of select="@label"/>
610 </xsl:if>
611</xsl:template>
612
613<xsl:template match="figure|table|example" mode="label.markup">
614 <xsl:variable name="pchap"
615 select="ancestor::chapter
616 |ancestor::appendix
617 |ancestor::article[ancestor::book]"/>
618
619 <xsl:variable name="prefix">
620 <xsl:if test="count($pchap) &gt; 0">
621 <xsl:apply-templates select="$pchap" mode="label.markup"/>
622 </xsl:if>
623 </xsl:variable>
624
625 <xsl:choose>
626 <xsl:when test="@label">
627 <xsl:value-of select="@label"/>
628 </xsl:when>
629 <xsl:otherwise>
630 <xsl:choose>
631 <xsl:when test="$prefix != ''">
632 <xsl:apply-templates select="$pchap" mode="label.markup"/>
633 <xsl:apply-templates select="$pchap" mode="intralabel.punctuation"/>
634 <xsl:number format="1" from="chapter|appendix" level="any"/>
635 </xsl:when>
636 <xsl:otherwise>
637 <xsl:number format="1" from="book|article" level="any"/>
638 </xsl:otherwise>
639 </xsl:choose>
640 </xsl:otherwise>
641 </xsl:choose>
642</xsl:template>
643
644<xsl:template match="procedure" mode="label.markup">
645 <xsl:variable name="pchap"
646 select="ancestor::chapter
647 |ancestor::appendix
648 |ancestor::article[ancestor::book]"/>
649
650 <xsl:variable name="prefix">
651 <xsl:if test="count($pchap) &gt; 0">
652 <xsl:apply-templates select="$pchap" mode="label.markup"/>
653 </xsl:if>
654 </xsl:variable>
655
656 <xsl:choose>
657 <xsl:when test="@label">
658 <xsl:value-of select="@label"/>
659 </xsl:when>
660 <xsl:when test="$formal.procedures = 0">
661 <!-- No label -->
662 </xsl:when>
663 <xsl:otherwise>
664 <xsl:choose>
665 <xsl:when test="count($pchap)>0">
666 <xsl:if test="$prefix != ''">
667 <xsl:apply-templates select="$pchap" mode="label.markup"/>
668 <xsl:apply-templates select="$pchap" mode="intralabel.punctuation"/>
669 </xsl:if>
670 <xsl:number count="procedure[title]" format="1"
671 from="chapter|appendix" level="any"/>
672 </xsl:when>
673 <xsl:otherwise>
674 <xsl:number count="procedure[title]" format="1"
675 from="book|article" level="any"/>
676 </xsl:otherwise>
677 </xsl:choose>
678 </xsl:otherwise>
679 </xsl:choose>
680</xsl:template>
681
682<xsl:template match="equation" mode="label.markup">
683 <xsl:variable name="pchap"
684 select="ancestor::chapter
685 |ancestor::appendix
686 |ancestor::article[ancestor::book]"/>
687
688 <xsl:variable name="prefix">
689 <xsl:if test="count($pchap) &gt; 0">
690 <xsl:apply-templates select="$pchap" mode="label.markup"/>
691 </xsl:if>
692 </xsl:variable>
693
694 <xsl:choose>
695 <xsl:when test="@label">
696 <xsl:value-of select="@label"/>
697 </xsl:when>
698 <xsl:otherwise>
699 <xsl:choose>
700 <xsl:when test="count($pchap)>0">
701 <xsl:if test="$prefix != ''">
702 <xsl:apply-templates select="$pchap" mode="label.markup"/>
703 <xsl:apply-templates select="$pchap" mode="intralabel.punctuation"/>
704 </xsl:if>
705 <xsl:number format="1" count="equation[title or info/title]"
706 from="chapter|appendix" level="any"/>
707 </xsl:when>
708 <xsl:otherwise>
709 <xsl:number format="1" count="equation[title or info/title]"
710 from="book|article" level="any"/>
711 </xsl:otherwise>
712 </xsl:choose>
713 </xsl:otherwise>
714 </xsl:choose>
715</xsl:template>
716
717<xsl:template match="orderedlist/listitem" mode="label.markup">
718 <xsl:variable name="numeration">
719 <xsl:call-template name="list.numeration">
720 <xsl:with-param name="node" select="parent::orderedlist"/>
721 </xsl:call-template>
722 </xsl:variable>
723
724 <xsl:variable name="type">
725 <xsl:choose>
726 <xsl:when test="$numeration='arabic'">1</xsl:when>
727 <xsl:when test="$numeration='loweralpha'">a</xsl:when>
728 <xsl:when test="$numeration='lowerroman'">i</xsl:when>
729 <xsl:when test="$numeration='upperalpha'">A</xsl:when>
730 <xsl:when test="$numeration='upperroman'">I</xsl:when>
731 <!-- What!? This should never happen -->
732 <xsl:otherwise>
733 <xsl:message>
734 <xsl:text>Unexpected numeration: </xsl:text>
735 <xsl:value-of select="$numeration"/>
736 </xsl:message>
737 <xsl:value-of select="1."/>
738 </xsl:otherwise>
739 </xsl:choose>
740 </xsl:variable>
741
742 <xsl:variable name="item-number">
743 <xsl:call-template name="orderedlist-item-number"/>
744 </xsl:variable>
745
746 <xsl:number value="$item-number" format="{$type}"/>
747</xsl:template>
748
749<xsl:template match="abstract" mode="label.markup">
750 <!-- nop -->
751</xsl:template>
752
753<xsl:template match="sidebar" mode="label.markup">
754 <!-- nop -->
755</xsl:template>
756
757<!-- ============================================================ -->
758
759<xsl:template name="label.this.section">
760 <xsl:param name="section" select="."/>
761
762 <xsl:variable name="level">
763 <xsl:call-template name="section.level"/>
764 </xsl:variable>
765
766 <xsl:choose>
767 <xsl:when test="$level &lt;= $section.autolabel.max.depth">
768 <xsl:value-of select="$section.autolabel"/>
769 </xsl:when>
770 <xsl:otherwise>0</xsl:otherwise>
771 </xsl:choose>
772</xsl:template>
773
774<doc:template name="label.this.section" xmlns="">
775<refpurpose>Returns true if $section should be labelled</refpurpose>
776<refdescription id="label.this.section-desc">
777<para>Returns true if the specified section should be labelled.
778By default, this template returns zero unless
779the section level is less than or equal to the value of the
780<literal>$section.autolabel.max.depth</literal> parameter, in
781which case it returns
782<literal>$section.autolabel</literal>.
783Custom stylesheets may override it to get more selective behavior.</para>
784</refdescription>
785</doc:template>
786
787<!-- ============================================================ -->
788
789<xsl:template name="default.autolabel.format">
790 <xsl:param name="context" select="."/>
791 <xsl:choose>
792 <xsl:when test="local-name($context) = 'appendix'">
793 <xsl:value-of select="'A'"/>
794 </xsl:when>
795 <xsl:when test="local-name($context) = 'part'">
796 <xsl:value-of select="'I'"/>
797 </xsl:when>
798 <xsl:otherwise>1</xsl:otherwise>
799 </xsl:choose>
800</xsl:template>
801
802<xsl:template name="autolabel.format">
803 <xsl:param name="context" select="."/>
804 <xsl:param name="format"/>
805
806 <xsl:choose>
807 <xsl:when test="string($format) != 0">
808 <xsl:choose>
809 <xsl:when test="string($format)='arabic' or $format='1'">1</xsl:when>
810 <xsl:when test="$format='loweralpha' or $format='a'">
811 <xsl:value-of select="'a'"/>
812 </xsl:when>
813 <xsl:when test="$format='lowerroman' or $format='i'">
814 <xsl:value-of select="'i'"/>
815 </xsl:when>
816 <xsl:when test="$format='upperalpha' or $format='A'">
817 <xsl:value-of select="'A'"/>
818 </xsl:when>
819 <xsl:when test="$format='upperroman' or $format='I'">
820 <xsl:value-of select="'I'"/>
821 </xsl:when>
822 <xsl:when test="$format='arabicindic' or $format='&#x661;'">
823 <xsl:value-of select="'&#x661;'"/>
824 </xsl:when>
825 <xsl:otherwise>
826 <xsl:message>
827 <xsl:text>Unexpected </xsl:text><xsl:value-of select="local-name(.)"/><xsl:text>.autolabel value: </xsl:text>
828 <xsl:value-of select="$format"/><xsl:text>; using default.</xsl:text>
829 </xsl:message>
830 <xsl:call-template name="default.autolabel.format"/>
831 </xsl:otherwise>
832 </xsl:choose>
833 </xsl:when>
834 </xsl:choose>
835</xsl:template>
836
837<doc:template name="autolabel.format" xmlns="">
838<refpurpose>Returns format for autolabel parameters</refpurpose>
839<refdescription id="autolabel.format-desc">
840<para>Returns format passed as parameter if non zero. Supported
841 format are 'arabic' or '1', 'loweralpha' or 'a', 'lowerroman' or 'i',
842 'upperlapha' or 'A', 'upperroman' or 'I', 'arabicindic' or '&#x661;'.
843 If its not one of these then
844 returns the default format.</para>
845</refdescription>
846</doc:template>
847
848<!-- ============================================================ -->
849
850</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.