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