source: clfs-embedded/BOOK/stylesheets/xhtml/lfs-sections.xsl@ 8520e58

Last change on this file since 8520e58 was a9e389d, checked in by Jim Gifford <clfs@…>, 18 years ago

Initial Import of CLFS 3.0

  • Property mode set to 100644
File size: 4.9 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 <!-- Use lowercase roman numbers for sect1 in preface -->
57 <xsl:template match="sect1" mode="label.markup">
58 <!-- if the parent is a component, maybe label that too -->
59 <xsl:variable name="parent.is.component">
60 <xsl:call-template name="is.component">
61 <xsl:with-param name="node" select=".."/>
62 </xsl:call-template>
63 </xsl:variable>
64 <xsl:variable name="component.label">
65 <xsl:if test="$section.label.includes.component.label != 0
66 and $parent.is.component != 0">
67 <xsl:variable name="parent.label">
68 <xsl:apply-templates select=".." mode="label.markup"/>
69 </xsl:variable>
70 <xsl:if test="$parent.label != ''">
71 <xsl:apply-templates select=".." mode="label.markup"/>
72 <xsl:apply-templates select=".." mode="intralabel.punctuation"/>
73 </xsl:if>
74 </xsl:if>
75 </xsl:variable>
76 <xsl:choose>
77 <xsl:when test="@label">
78 <xsl:value-of select="@label"/>
79 </xsl:when>
80 <xsl:when test="$section.autolabel != 0">
81 <xsl:copy-of select="$component.label"/>
82 <xsl:choose>
83 <xsl:when test="ancestor::preface">
84 <xsl:number format="i" count="sect1"/>
85 </xsl:when>
86 <xsl:otherwise>
87 <xsl:number format="1" count="sect1"/>
88 </xsl:otherwise>
89 </xsl:choose>
90 </xsl:when>
91 </xsl:choose>
92 </xsl:template>
93
94 <!-- Skip numeration for sect2 with empty title -->
95 <xsl:template match="sect2|sect3|sect4|sect5" mode="label.markup">
96 <xsl:if test="string-length(title) > 0">
97 <!-- label the parent -->
98 <xsl:variable name="parent.label">
99 <xsl:apply-templates select=".." mode="label.markup"/>
100 </xsl:variable>
101 <xsl:if test="$parent.label != ''">
102 <xsl:apply-templates select=".." mode="label.markup"/>
103 <xsl:apply-templates select=".." mode="intralabel.punctuation"/>
104 </xsl:if>
105 <xsl:choose>
106 <xsl:when test="@label">
107 <xsl:value-of select="@label"/>
108 </xsl:when>
109 <xsl:when test="$section.autolabel != 0">
110 <xsl:choose>
111 <xsl:when test="local-name(.) = 'sect2'">
112 <xsl:choose>
113 <!-- If the first sect2 isn't numbered, renumber the remainig sections -->
114 <xsl:when test="string-length(../sect2[1]/title) = 0">
115 <xsl:variable name="totalsect2">
116 <xsl:number count="sect2"/>
117 </xsl:variable>
118 <xsl:number value="$totalsect2 - 1"/>
119 </xsl:when>
120 <xsl:otherwise>
121 <xsl:number count="sect2"/>
122 </xsl:otherwise>
123 </xsl:choose>
124 </xsl:when>
125 <xsl:when test="local-name(.) = 'sect3'">
126 <xsl:number count="sect3"/>
127 </xsl:when>
128 <xsl:when test="local-name(.) = 'sect4'">
129 <xsl:number count="sect4"/>
130 </xsl:when>
131 <xsl:when test="local-name(.) = 'sect5'">
132 <xsl:number count="sect5"/>
133 </xsl:when>
134 <xsl:otherwise>
135 <xsl:message>label.markup: this can't happen!</xsl:message>
136 </xsl:otherwise>
137 </xsl:choose>
138 </xsl:when>
139 </xsl:choose>
140 </xsl:if>
141 </xsl:template>
142
143</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.