source: trunk/Distribution/XSL/xhtml/sections.xsl@ 2

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