source: trunk/Distribution/XSL/html/sections.xsl@ 3

Last change on this file since 3 was 2, checked in by jkacer, 18 years ago

Added all DocBook Framework stuff:

  • DocBook DTD
  • Transformation software FOP 0.20.5 and Saxon 6
  • XSL styles
  • Rexx scripts

Also added some WarpIN-related stuff for creation of WarpIN installation packages.
This state corresponds to version 1.0.0 from November 2005, just slightly modified to carry versioning information (Rexx scripts).

File size: 19.7 KB
Line 
1<?xml version='1.0'?>
2<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3 version='1.0'>
4
5<!-- ********************************************************************
6 $Id: sections.xsl,v 1.28 2004/11/23 10:22:21 xmldoc Exp $
7 ********************************************************************
8
9 This file is part of the XSL DocBook Stylesheet distribution.
10 See ../README or http://nwalsh.com/docbook/xsl/ for copyright
11 and other information.
12
13 ******************************************************************** -->
14
15<!-- ==================================================================== -->
16
17<xsl:template match="section">
18 <xsl:variable name="depth" select="count(ancestor::section)+1"/>
19
20 <div class="{name(.)}">
21 <xsl:call-template name="language.attribute"/>
22 <xsl:call-template name="section.titlepage"/>
23
24 <xsl:variable name="toc.params">
25 <xsl:call-template name="find.path.params">
26 <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
27 </xsl:call-template>
28 </xsl:variable>
29
30 <xsl:if test="contains($toc.params, 'toc')
31 and $depth &lt;= $generate.section.toc.level">
32 <xsl:call-template name="section.toc">
33 <xsl:with-param name="toc.title.p" select="contains($toc.params, 'title')"/>
34 </xsl:call-template>
35 <xsl:call-template name="section.toc.separator"/>
36 </xsl:if>
37 <xsl:apply-templates/>
38 <xsl:call-template name="process.chunk.footnotes"/>
39 </div>
40</xsl:template>
41
42<xsl:template name="section.title">
43 <!-- the context node should be the title of a section when called -->
44 <xsl:variable name="section" select="(ancestor::section
45 |ancestor::simplesect
46 |ancestor::sect1
47 |ancestor::sect2
48 |ancestor::sect3
49 |ancestor::sect4
50 |ancestor::sect5)[last()]"/>
51
52 <xsl:variable name="renderas">
53 <xsl:choose>
54 <xsl:when test="$section/@renderas = 'sect1'">1</xsl:when>
55 <xsl:when test="$section/@renderas = 'sect2'">2</xsl:when>
56 <xsl:when test="$section/@renderas = 'sect3'">3</xsl:when>
57 <xsl:when test="$section/@renderas = 'sect4'">4</xsl:when>
58 <xsl:when test="$section/@renderas = 'sect5'">5</xsl:when>
59 <xsl:otherwise><xsl:value-of select="''"/></xsl:otherwise>
60 </xsl:choose>
61 </xsl:variable>
62
63 <xsl:variable name="level">
64 <xsl:choose>
65 <xsl:when test="$renderas != ''">
66 <xsl:value-of select="$renderas"/>
67 </xsl:when>
68 <xsl:otherwise>
69 <xsl:call-template name="section.level">
70 <xsl:with-param name="node" select="$section"/>
71 </xsl:call-template>
72 </xsl:otherwise>
73 </xsl:choose>
74 </xsl:variable>
75
76 <xsl:call-template name="section.heading">
77 <xsl:with-param name="section" select=".."/>
78 <xsl:with-param name="level" select="$level"/>
79 <xsl:with-param name="title">
80 <xsl:apply-templates select="$section" mode="object.title.markup">
81 <xsl:with-param name="allow-anchors" select="1"/>
82 </xsl:apply-templates>
83 </xsl:with-param>
84 </xsl:call-template>
85</xsl:template>
86
87<xsl:template match="section/title" mode="titlepage.mode" priority="2">
88 <xsl:call-template name="section.title"/>
89</xsl:template>
90
91<xsl:template match="sect1">
92 <div class="{name(.)}">
93 <xsl:call-template name="language.attribute"/>
94
95 <xsl:choose>
96 <xsl:when test="@renderas = 'sect2'">
97 <xsl:call-template name="sect2.titlepage"/>
98 </xsl:when>
99 <xsl:when test="@renderas = 'sect3'">
100 <xsl:call-template name="sect3.titlepage"/>
101 </xsl:when>
102 <xsl:when test="@renderas = 'sect4'">
103 <xsl:call-template name="sect4.titlepage"/>
104 </xsl:when>
105 <xsl:when test="@renderas = 'sect5'">
106 <xsl:call-template name="sect5.titlepage"/>
107 </xsl:when>
108 <xsl:otherwise>
109 <xsl:call-template name="sect1.titlepage"/>
110 </xsl:otherwise>
111 </xsl:choose>
112
113 <xsl:variable name="toc.params">
114 <xsl:call-template name="find.path.params">
115 <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
116 </xsl:call-template>
117 </xsl:variable>
118
119 <xsl:if test="contains($toc.params, 'toc')
120 and $generate.section.toc.level &gt;= 1">
121 <xsl:call-template name="section.toc">
122 <xsl:with-param name="toc.title.p" select="contains($toc.params, 'title')"/>
123 </xsl:call-template>
124 <xsl:call-template name="section.toc.separator"/>
125 </xsl:if>
126 <xsl:apply-templates/>
127 <xsl:call-template name="process.chunk.footnotes"/>
128 </div>
129</xsl:template>
130
131<xsl:template match="sect1/title" mode="titlepage.mode" priority="2">
132 <xsl:call-template name="section.title"/>
133</xsl:template>
134
135<xsl:template match="sect2">
136 <div class="{name(.)}">
137 <xsl:call-template name="language.attribute"/>
138
139 <xsl:choose>
140 <xsl:when test="@renderas = 'sect1'">
141 <xsl:call-template name="sect1.titlepage"/>
142 </xsl:when>
143 <xsl:when test="@renderas = 'sect3'">
144 <xsl:call-template name="sect3.titlepage"/>
145 </xsl:when>
146 <xsl:when test="@renderas = 'sect4'">
147 <xsl:call-template name="sect4.titlepage"/>
148 </xsl:when>
149 <xsl:when test="@renderas = 'sect5'">
150 <xsl:call-template name="sect5.titlepage"/>
151 </xsl:when>
152 <xsl:otherwise>
153 <xsl:call-template name="sect2.titlepage"/>
154 </xsl:otherwise>
155 </xsl:choose>
156
157 <xsl:variable name="toc.params">
158 <xsl:call-template name="find.path.params">
159 <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
160 </xsl:call-template>
161 </xsl:variable>
162
163 <xsl:if test="contains($toc.params, 'toc')
164 and $generate.section.toc.level &gt;= 2">
165 <xsl:call-template name="section.toc">
166 <xsl:with-param name="toc.title.p" select="contains($toc.params, 'title')"/>
167 </xsl:call-template>
168 <xsl:call-template name="section.toc.separator"/>
169 </xsl:if>
170 <xsl:apply-templates/>
171 <xsl:call-template name="process.chunk.footnotes"/>
172 </div>
173</xsl:template>
174
175<xsl:template match="sect2/title" mode="titlepage.mode" priority="2">
176 <xsl:call-template name="section.title"/>
177</xsl:template>
178
179<xsl:template match="sect3">
180 <div class="{name(.)}">
181 <xsl:call-template name="language.attribute"/>
182
183 <xsl:choose>
184 <xsl:when test="@renderas = 'sect1'">
185 <xsl:call-template name="sect1.titlepage"/>
186 </xsl:when>
187 <xsl:when test="@renderas = 'sect2'">
188 <xsl:call-template name="sect2.titlepage"/>
189 </xsl:when>
190 <xsl:when test="@renderas = 'sect4'">
191 <xsl:call-template name="sect4.titlepage"/>
192 </xsl:when>
193 <xsl:when test="@renderas = 'sect5'">
194 <xsl:call-template name="sect5.titlepage"/>
195 </xsl:when>
196 <xsl:otherwise>
197 <xsl:call-template name="sect3.titlepage"/>
198 </xsl:otherwise>
199 </xsl:choose>
200
201 <xsl:variable name="toc.params">
202 <xsl:call-template name="find.path.params">
203 <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
204 </xsl:call-template>
205 </xsl:variable>
206
207 <xsl:if test="contains($toc.params, 'toc')
208 and $generate.section.toc.level &gt;= 3">
209 <xsl:call-template name="section.toc">
210 <xsl:with-param name="toc.title.p" select="contains($toc.params, 'title')"/>
211 </xsl:call-template>
212 <xsl:call-template name="section.toc.separator"/>
213 </xsl:if>
214 <xsl:apply-templates/>
215 <xsl:call-template name="process.chunk.footnotes"/>
216 </div>
217</xsl:template>
218
219<xsl:template match="sect3/title" mode="titlepage.mode" priority="2">
220 <xsl:call-template name="section.title"/>
221</xsl:template>
222
223<xsl:template match="sect4">
224 <div class="{name(.)}">
225 <xsl:call-template name="language.attribute"/>
226
227 <xsl:choose>
228 <xsl:when test="@renderas = 'sect1'">
229 <xsl:call-template name="sect1.titlepage"/>
230 </xsl:when>
231 <xsl:when test="@renderas = 'sect2'">
232 <xsl:call-template name="sect2.titlepage"/>
233 </xsl:when>
234 <xsl:when test="@renderas = 'sect3'">
235 <xsl:call-template name="sect3.titlepage"/>
236 </xsl:when>
237 <xsl:when test="@renderas = 'sect5'">
238 <xsl:call-template name="sect5.titlepage"/>
239 </xsl:when>
240 <xsl:otherwise>
241 <xsl:call-template name="sect4.titlepage"/>
242 </xsl:otherwise>
243 </xsl:choose>
244
245 <xsl:variable name="toc.params">
246 <xsl:call-template name="find.path.params">
247 <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
248 </xsl:call-template>
249 </xsl:variable>
250
251 <xsl:if test="contains($toc.params, 'toc')
252 and $generate.section.toc.level &gt;= 4">
253 <xsl:call-template name="section.toc">
254 <xsl:with-param name="toc.title.p" select="contains($toc.params, 'title')"/>
255 </xsl:call-template>
256 <xsl:call-template name="section.toc.separator"/>
257 </xsl:if>
258 <xsl:apply-templates/>
259 <xsl:call-template name="process.chunk.footnotes"/>
260 </div>
261</xsl:template>
262
263<xsl:template match="sect4/title" mode="titlepage.mode" priority="2">
264 <xsl:call-template name="section.title"/>
265</xsl:template>
266
267<xsl:template match="sect5">
268 <div class="{name(.)}">
269 <xsl:call-template name="language.attribute"/>
270
271 <xsl:choose>
272 <xsl:when test="@renderas = 'sect1'">
273 <xsl:call-template name="sect1.titlepage"/>
274 </xsl:when>
275 <xsl:when test="@renderas = 'sect2'">
276 <xsl:call-template name="sect2.titlepage"/>
277 </xsl:when>
278 <xsl:when test="@renderas = 'sect3'">
279 <xsl:call-template name="sect3.titlepage"/>
280 </xsl:when>
281 <xsl:when test="@renderas = 'sect4'">
282 <xsl:call-template name="sect4.titlepage"/>
283 </xsl:when>
284 <xsl:otherwise>
285 <xsl:call-template name="sect5.titlepage"/>
286 </xsl:otherwise>
287 </xsl:choose>
288
289 <xsl:variable name="toc.params">
290 <xsl:call-template name="find.path.params">
291 <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
292 </xsl:call-template>
293 </xsl:variable>
294
295 <xsl:if test="contains($toc.params, 'toc')
296 and $generate.section.toc.level &gt;= 5">
297 <xsl:call-template name="section.toc">
298 <xsl:with-param name="toc.title.p" select="contains($toc.params, 'title')"/>
299 </xsl:call-template>
300 <xsl:call-template name="section.toc.separator"/>
301 </xsl:if>
302 <xsl:apply-templates/>
303 <xsl:call-template name="process.chunk.footnotes"/>
304 </div>
305</xsl:template>
306
307<xsl:template match="sect5/title" mode="titlepage.mode" priority="2">
308 <xsl:call-template name="section.title"/>
309</xsl:template>
310
311<xsl:template match="simplesect">
312 <div class="{name(.)}">
313 <xsl:call-template name="language.attribute"/>
314 <xsl:call-template name="simplesect.titlepage"/>
315 <xsl:apply-templates/>
316 </div>
317</xsl:template>
318
319<xsl:template match="simplesect/title" mode="titlepage.mode" priority="2">
320 <xsl:call-template name="section.title"/>
321</xsl:template>
322
323<xsl:template match="section/title"></xsl:template>
324<xsl:template match="section/titleabbrev"></xsl:template>
325<xsl:template match="section/subtitle"></xsl:template>
326<xsl:template match="sectioninfo"></xsl:template>
327
328<xsl:template match="sect1/title"></xsl:template>
329<xsl:template match="sect1/titleabbrev"></xsl:template>
330<xsl:template match="sect1/subtitle"></xsl:template>
331<xsl:template match="sect1info"></xsl:template>
332
333<xsl:template match="sect2/title"></xsl:template>
334<xsl:template match="sect2/subtitle"></xsl:template>
335<xsl:template match="sect2/titleabbrev"></xsl:template>
336<xsl:template match="sect2info"></xsl:template>
337
338<xsl:template match="sect3/title"></xsl:template>
339<xsl:template match="sect3/subtitle"></xsl:template>
340<xsl:template match="sect3/titleabbrev"></xsl:template>
341<xsl:template match="sect3info"></xsl:template>
342
343<xsl:template match="sect4/title"></xsl:template>
344<xsl:template match="sect4/subtitle"></xsl:template>
345<xsl:template match="sect4/titleabbrev"></xsl:template>
346<xsl:template match="sect4info"></xsl:template>
347
348<xsl:template match="sect5/title"></xsl:template>
349<xsl:template match="sect5/subtitle"></xsl:template>
350<xsl:template match="sect5/titleabbrev"></xsl:template>
351<xsl:template match="sect5info"></xsl:template>
352
353<xsl:template match="simplesect/title"></xsl:template>
354<xsl:template match="simplesect/subtitle"></xsl:template>
355<xsl:template match="simplesect/titleabbrev"></xsl:template>
356
357<!-- ==================================================================== -->
358
359<xsl:template name="section.heading">
360 <xsl:param name="section" select="."/>
361 <xsl:param name="level" select="1"/>
362 <xsl:param name="allow-anchors" select="1"/>
363 <xsl:param name="title"/>
364 <xsl:param name="class" select="'title'"/>
365
366 <xsl:variable name="id">
367 <xsl:choose>
368 <!-- if title is in an *info wrapper, get the grandparent -->
369 <xsl:when test="contains(local-name(..), 'info')">
370 <xsl:call-template name="object.id">
371 <xsl:with-param name="object" select="../.."/>
372 </xsl:call-template>
373 </xsl:when>
374 <xsl:otherwise>
375 <xsl:call-template name="object.id">
376 <xsl:with-param name="object" select=".."/>
377 </xsl:call-template>
378 </xsl:otherwise>
379 </xsl:choose>
380 </xsl:variable>
381
382 <!-- HTML H level is one higher than section level -->
383 <xsl:variable name="hlevel">
384 <xsl:choose>
385 <!-- highest valid HTML H level is H6; so anything nested deeper
386 than 5 levels down just becomes H6 -->
387 <xsl:when test="$level &gt; 5">6</xsl:when>
388 <xsl:otherwise>
389 <xsl:value-of select="$level + 1"/>
390 </xsl:otherwise>
391 </xsl:choose>
392 </xsl:variable>
393 <xsl:element name="h{$hlevel}">
394 <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute>
395 <xsl:if test="$css.decoration != '0'">
396 <xsl:if test="$hlevel&lt;3">
397 <xsl:attribute name="style">clear: both</xsl:attribute>
398 </xsl:if>
399 </xsl:if>
400 <xsl:if test="$allow-anchors != 0">
401 <xsl:call-template name="anchor">
402 <xsl:with-param name="node" select="$section"/>
403 <xsl:with-param name="conditional" select="0"/>
404 </xsl:call-template>
405 </xsl:if>
406 <xsl:copy-of select="$title"/>
407 </xsl:element>
408</xsl:template>
409
410<!-- ==================================================================== -->
411
412<xsl:template match="bridgehead">
413 <xsl:variable name="container"
414 select="(ancestor::appendix
415 |ancestor::article
416 |ancestor::bibliography
417 |ancestor::chapter
418 |ancestor::glossary
419 |ancestor::glossdiv
420 |ancestor::index
421 |ancestor::partintro
422 |ancestor::preface
423 |ancestor::refsect1
424 |ancestor::refsect2
425 |ancestor::refsect3
426 |ancestor::sect1
427 |ancestor::sect2
428 |ancestor::sect3
429 |ancestor::sect4
430 |ancestor::sect5
431 |ancestor::section
432 |ancestor::setindex
433 |ancestor::simplesect)[last()]"/>
434
435 <xsl:variable name="clevel">
436 <xsl:choose>
437 <xsl:when test="local-name($container) = 'appendix'
438 or local-name($container) = 'chapter'
439 or local-name($container) = 'article'
440 or local-name($container) = 'bibliography'
441 or local-name($container) = 'glossary'
442 or local-name($container) = 'index'
443 or local-name($container) = 'partintro'
444 or local-name($container) = 'preface'
445 or local-name($container) = 'setindex'">1</xsl:when>
446 <xsl:when test="local-name($container) = 'glossdiv'">
447 <xsl:value-of select="count(ancestor::glossdiv)+1"/>
448 </xsl:when>
449 <xsl:when test="local-name($container) = 'sect1'
450 or local-name($container) = 'sect2'
451 or local-name($container) = 'sect3'
452 or local-name($container) = 'sect4'
453 or local-name($container) = 'sect5'
454 or local-name($container) = 'refsect1'
455 or local-name($container) = 'refsect2'
456 or local-name($container) = 'refsect3'
457 or local-name($container) = 'section'
458 or local-name($container) = 'simplesect'">
459 <xsl:variable name="slevel">
460 <xsl:call-template name="section.level">
461 <xsl:with-param name="node" select="$container"/>
462 </xsl:call-template>
463 </xsl:variable>
464 <xsl:value-of select="$slevel + 1"/>
465 </xsl:when>
466 <xsl:otherwise>1</xsl:otherwise>
467 </xsl:choose>
468 </xsl:variable>
469
470 <!-- HTML H level is one higher than section level -->
471 <xsl:variable name="hlevel">
472 <xsl:choose>
473 <xsl:when test="@renderas = 'sect1'">1</xsl:when>
474 <xsl:when test="@renderas = 'sect2'">2</xsl:when>
475 <xsl:when test="@renderas = 'sect3'">3</xsl:when>
476 <xsl:when test="@renderas = 'sect4'">4</xsl:when>
477 <xsl:when test="@renderas = 'sect5'">5</xsl:when>
478 <xsl:otherwise>
479 <xsl:value-of select="$clevel + 1"/>
480 </xsl:otherwise>
481 </xsl:choose>
482 </xsl:variable>
483
484 <xsl:element name="h{$hlevel}">
485 <xsl:call-template name="anchor">
486 <xsl:with-param name="conditional" select="0"/>
487 </xsl:call-template>
488 <xsl:apply-templates/>
489 </xsl:element>
490</xsl:template>
491
492<xsl:template match="section/subtitle" mode="titlepage.mode" priority="2">
493 <xsl:call-template name="section.subtitle"/>
494</xsl:template>
495
496<xsl:template match="simplesect/subtitle" mode="titlepage.mode" priority="2">
497 <xsl:call-template name="section.subtitle"/>
498</xsl:template>
499
500<xsl:template match="sect1/subtitle" mode="titlepage.mode" priority="2">
501 <xsl:call-template name="section.subtitle"/>
502</xsl:template>
503
504<xsl:template match="sect2/subtitle" mode="titlepage.mode" priority="2">
505 <xsl:call-template name="section.subtitle"/>
506</xsl:template>
507
508<xsl:template match="sect3/subtitle" mode="titlepage.mode" priority="2">
509 <xsl:call-template name="section.subtitle"/>
510</xsl:template>
511
512<xsl:template match="sect4/subtitle" mode="titlepage.mode" priority="2">
513 <xsl:call-template name="section.subtitle"/>
514</xsl:template>
515
516<xsl:template match="sect5/subtitle" mode="titlepage.mode" priority="2">
517 <xsl:call-template name="section.subtitle"/>
518</xsl:template>
519
520<xsl:template name="section.subtitle">
521 <!-- the context node should be the subtitle of a section when called -->
522 <xsl:variable name="section" select="(ancestor::section
523 |ancestor::simplesect
524 |ancestor::sect1
525 |ancestor::sect2
526 |ancestor::sect3
527 |ancestor::sect4
528 |ancestor::sect5)[last()]"/>
529
530 <xsl:variable name="level">
531 <xsl:call-template name="section.level">
532 <xsl:with-param name="node" select="$section"/>
533 </xsl:call-template>
534 </xsl:variable>
535
536 <xsl:call-template name="section.heading">
537 <xsl:with-param name="section" select=".."/>
538 <xsl:with-param name="allow-anchors" select="0"/>
539 <!-- subtitle heading level one higher than section level -->
540 <xsl:with-param name="level" select="$level + 1"/>
541 <xsl:with-param name="class" select="'subtitle'"/>
542 <xsl:with-param name="title">
543 <xsl:apply-templates select="$section" mode="object.subtitle.markup">
544 <xsl:with-param name="allow-anchors" select="0"/>
545 </xsl:apply-templates>
546 </xsl:with-param>
547 </xsl:call-template>
548</xsl:template>
549
550</xsl:stylesheet>
551
Note: See TracBrowser for help on using the repository browser.