source: stylesheets/xhtml/lfs-sections.xsl@ 37eabe3

Last change on this file since 37eabe3 was a988510, checked in by Manuel Canales Esparcia <manuel@…>, 20 years ago

Numbered sections for HTML output.

git-svn-id: http://svn.linuxfromscratch.org/LFS/branches/testing/BOOK@4090 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

  • Property mode set to 100644
File size: 3.5 KB
Line 
1<?xml version='1.0' encoding='ISO-8859-1'?>
2
3<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4 xmlns="http://www.w3.org/1999/xhtml"
5 version="1.0">
6
7
8 <!-- Sect1 attributes -->
9 <xsl:template match="sect1">
10 <div>
11 <xsl:choose>
12 <xsl:when test="@role">
13 <xsl:attribute name="class">
14 <xsl:value-of select="@role"/>
15 </xsl:attribute>
16 </xsl:when>
17 <xsl:otherwise>
18 <xsl:attribute name="class">
19 <xsl:value-of select="name(.)"/>
20 </xsl:attribute>
21 </xsl:otherwise>
22 </xsl:choose>
23 <xsl:call-template name="language.attribute"/>
24 <xsl:call-template name="sect1.titlepage"/>
25 <xsl:apply-templates/>
26 <xsl:call-template name="process.chunk.footnotes"/>
27 </div>
28 </xsl:template>
29
30 <!-- Sect2 attributes -->
31 <xsl:template match="sect2">
32 <div>
33 <xsl:choose>
34 <xsl:when test="@role">
35 <xsl:attribute name="class">
36 <xsl:value-of select="@role"/>
37 </xsl:attribute>
38 </xsl:when>
39 <xsl:otherwise>
40 <xsl:attribute name="class">
41 <xsl:value-of select="name(.)"/>
42 </xsl:attribute>
43 </xsl:otherwise>
44 </xsl:choose>
45 <xsl:call-template name="language.attribute"/>
46 <xsl:call-template name="sect2.titlepage"/>
47 <xsl:apply-templates/>
48 <xsl:call-template name="process.chunk.footnotes"/>
49 </div>
50 </xsl:template>
51
52 <!-- Sections numbering -->
53 <xsl:param name="section.autolabel" select="1"/>
54 <xsl:param name="section.label.includes.component.label" select="1"/>
55
56 <!-- Skip numeraration for sections with empty title -->
57 <xsl:template match="sect2|sect3|sect4|sect5" mode="label.markup">
58 <xsl:if test="string-length(title) > 0">
59 <!-- label the parent -->
60 <xsl:variable name="parent.label">
61 <xsl:apply-templates select=".." mode="label.markup"/>
62 </xsl:variable>
63 <xsl:if test="$parent.label != ''">
64 <xsl:apply-templates select=".." mode="label.markup"/>
65 <xsl:apply-templates select=".." mode="intralabel.punctuation"/>
66 </xsl:if>
67 <xsl:choose>
68 <xsl:when test="@label">
69 <xsl:value-of select="@label"/>
70 </xsl:when>
71 <xsl:when test="$section.autolabel != 0">
72 <xsl:choose>
73 <xsl:when test="local-name(.) = 'sect2'">
74 <xsl:choose>
75 <!-- If the first sect2 isn't numbered, renumber the remainig sections -->
76 <xsl:when test="string-length(../sect2[1]/title) = 0">
77 <xsl:variable name="totalsect2">
78 <xsl:number count="sect2"/>
79 </xsl:variable>
80 <xsl:number value="$totalsect2 - 1"/>
81 </xsl:when>
82 <xsl:otherwise>
83 <xsl:number count="sect2"/>
84 </xsl:otherwise>
85 </xsl:choose>
86 </xsl:when>
87 <xsl:when test="local-name(.) = 'sect3'">
88 <xsl:number count="sect3"/>
89 </xsl:when>
90 <xsl:when test="local-name(.) = 'sect4'">
91 <xsl:number count="sect4"/>
92 </xsl:when>
93 <xsl:when test="local-name(.) = 'sect5'">
94 <xsl:number count="sect5"/>
95 </xsl:when>
96 <xsl:otherwise>
97 <xsl:message>label.markup: this can't happen!</xsl:message>
98 </xsl:otherwise>
99 </xsl:choose>
100 </xsl:when>
101 </xsl:choose>
102 </xsl:if>
103 </xsl:template>
104
105</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.