source: stylesheets/lfs-xsl/xhtml/lfs-sections.xsl

trunk
Last change on this file was a9d1a93, checked in by Pierre Labastie <pierre.labastie@…>, 3 months ago

Fix webkit bug 2:

Add two templates (part and appendix) to lfs-sections.xsl, so it is
possible to output the title before the containing div

  • Property mode set to 100644
File size: 9.1 KB
Line 
1<?xml version='1.0' encoding='UTF-8'?>
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 <!-- This stylesheet controls how preface, chapter, and sections are handled -->
8
9 <!-- Chunk the first top-level section? 1 = yes, 0 = no
10 If preface and chapters TOC are generated, this must be 1. -->
11 <xsl:param name="chunk.first.sections" select="1"/>
12
13 <!-- preface:
14 Output non sect1 child elements before the TOC
15 Output title outside of the <div> because we want to be able to
16 use it at a fixed position -->
17 <!-- The original template is in {docbook-xsl}/xhtml/components.xsl -->
18 <xsl:template match="preface">
19 <xsl:call-template name="id.warning"/>
20 <xsl:call-template name="preface.titlepage"/>
21 <xsl:call-template name="component.separator"/>
22 <div>
23 <xsl:apply-templates select="." mode="class.attribute"/>
24 <xsl:call-template name="dir">
25 <xsl:with-param name="inherit" select="1"/>
26 </xsl:call-template>
27 <xsl:call-template name="language.attribute"/>
28 <xsl:if test="$generate.id.attributes != 0">
29 <xsl:attribute name="id">
30 <xsl:call-template name="object.id"/>
31 </xsl:attribute>
32 </xsl:if>
33 <xsl:apply-templates/>
34 <xsl:variable name="toc.params">
35 <xsl:call-template name="find.path.params">
36 <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
37 </xsl:call-template>
38 </xsl:variable>
39 <xsl:if test="contains($toc.params, 'toc')">
40 <xsl:call-template name="component.toc">
41 <xsl:with-param name="toc.title.p" select="contains($toc.params, 'title')"/>
42 </xsl:call-template>
43 <xsl:call-template name="component.toc.separator"/>
44 </xsl:if>
45 <xsl:call-template name="process.footnotes"/>
46 </div>
47 </xsl:template>
48
49 <!-- part:
50 Output non sect1 child elements before the TOC
51 Output title outside of the <div> because we want to be able to
52 use it at a fixed position -->
53 <!-- The original template is in {docbook-xsl}/xhtml/divisions.xsl -->
54 <xsl:template match="part">
55 <xsl:call-template name="id.warning"/>
56
57 <xsl:call-template name="part.titlepage"/>
58
59 <div>
60 <xsl:apply-templates select="." mode="common.html.attributes"/>
61 <xsl:call-template name="id.attribute">
62 <xsl:with-param name="conditional" select="0"/>
63 </xsl:call-template>
64
65 <xsl:apply-templates/>
66 <xsl:variable name="toc.params">
67 <xsl:call-template name="find.path.params">
68 <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
69 </xsl:call-template>
70 </xsl:variable>
71 <xsl:if test="not(partintro) and contains($toc.params, 'toc')">
72 <xsl:call-template name="division.toc"/>
73 </xsl:if>
74 </div>
75 </xsl:template>
76
77 <!-- chapter:
78 Output non sect1 child elements before the TOC
79 Output title before div to be able to fix the title position -->
80 <!-- The original template is in {docbook-xsl}/xhtml/components.xsl -->
81 <xsl:template match="chapter">
82 <xsl:call-template name="id.warning"/>
83 <xsl:call-template name="chapter.titlepage"/>
84 <xsl:call-template name="component.separator"/>
85 <div>
86 <xsl:apply-templates select="." mode="class.attribute"/>
87 <xsl:call-template name="dir">
88 <xsl:with-param name="inherit" select="1"/>
89 </xsl:call-template>
90 <xsl:call-template name="language.attribute"/>
91 <xsl:if test="$generate.id.attributes != 0">
92 <xsl:attribute name="id">
93 <xsl:call-template name="object.id"/>
94 </xsl:attribute>
95 </xsl:if>
96 <xsl:apply-templates/>
97 <xsl:variable name="toc.params">
98 <xsl:call-template name="find.path.params">
99 <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
100 </xsl:call-template>
101 </xsl:variable>
102 <xsl:if test="contains($toc.params, 'toc')">
103 <xsl:call-template name="component.toc">
104 <xsl:with-param name="toc.title.p" select="contains($toc.params, 'title')"/>
105 </xsl:call-template>
106 <xsl:call-template name="component.toc.separator"/>
107 </xsl:if>
108 <xsl:call-template name="process.footnotes"/>
109 </div>
110 </xsl:template>
111
112 <!-- appendix:
113 Output non sect1 child elements before the TOC
114 Output title before div to be able to fix the title position -->
115 <!-- The original template is in {docbook-xsl}/xhtml/components.xsl -->
116 <xsl:template match="appendix">
117
118 <xsl:call-template name="id.warning"/>
119
120 <xsl:call-template name="appendix.titlepage"/>
121
122 <xsl:element name="div" namespace="http://www.w3.org/1999/xhtml">
123 <xsl:call-template name="common.html.attributes">
124 <xsl:with-param name="inherit" select="1"/>
125 </xsl:call-template>
126 <xsl:call-template name="id.attribute">
127 <xsl:with-param name="conditional" select="0"/>
128 </xsl:call-template>
129
130 <xsl:apply-templates/>
131
132 <xsl:variable name="toc.params">
133 <xsl:call-template name="find.path.params">
134 <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
135 </xsl:call-template>
136 </xsl:variable>
137
138 <xsl:if test="contains($toc.params, 'toc')">
139 <xsl:call-template name="component.toc">
140 <xsl:with-param name="toc.title.p" select="contains($toc.params, 'title')"/>
141 </xsl:call-template>
142 </xsl:if>
143
144 </xsl:element>
145 </xsl:template>
146
147 <!-- sect1:
148 When there is a role attibute, use it as the class value.
149 Process the SVN keywords found in sect1info as a footnote.
150 Output title before the containing <div> so that the title
151 can be at a fixed position.
152 Removed unused code. -->
153 <!-- The original template is in {docbook-xsl}/xhtml/sections.xsl -->
154 <xsl:template match="sect1">
155 <xsl:call-template name="sect1.titlepage"/>
156 <div>
157 <xsl:choose>
158 <xsl:when test="@role">
159 <xsl:attribute name="class">
160 <xsl:value-of select="@role"/>
161 </xsl:attribute>
162 </xsl:when>
163 <xsl:otherwise>
164 <xsl:apply-templates select="." mode="class.attribute"/>
165 </xsl:otherwise>
166 </xsl:choose>
167 <xsl:call-template name="language.attribute"/>
168 <xsl:apply-templates/>
169 <xsl:apply-templates select="sect1info" mode="svn-keys"/>
170 </div>
171 </xsl:template>
172
173 <!-- sect2:
174 When there is a role attibute, use it as the class value.
175 Removed unused code. -->
176 <!-- The original template is in {docbook-xsl}/xhtml/sections.xsl -->
177 <xsl:template match="sect2">
178 <div>
179 <xsl:choose>
180 <xsl:when test="@role">
181 <xsl:attribute name="class">
182 <xsl:value-of select="@role"/>
183 </xsl:attribute>
184 </xsl:when>
185 <xsl:otherwise>
186 <xsl:attribute name="class">
187 <xsl:value-of select="name(.)"/>
188 </xsl:attribute>
189 </xsl:otherwise>
190 </xsl:choose>
191 <xsl:call-template name="language.attribute"/>
192 <xsl:call-template name="sect2.titlepage"/>
193 <xsl:apply-templates/>
194 </div>
195 </xsl:template>
196
197 <!-- sect3: treat as sect2 (for Python and Perl modules
198 When there is a role attibute, use it as the class value.
199 Removed unused code. -->
200 <!-- The original template is in {docbook-xsl}/xhtml/sections.xsl -->
201 <xsl:template match="sect3">
202 <div>
203 <xsl:choose>
204 <xsl:when test="@role">
205 <xsl:attribute name="class">
206 <xsl:value-of select="@role"/>
207 </xsl:attribute>
208 </xsl:when>
209 <xsl:otherwise>
210 <xsl:attribute name="class">
211 <xsl:value-of select="name(.)"/>
212 </xsl:attribute>
213 </xsl:otherwise>
214 </xsl:choose>
215 <xsl:call-template name="language.attribute"/>
216 <xsl:call-template name="sect3.titlepage"/>
217 <xsl:apply-templates/>
218 </div>
219 </xsl:template>
220
221 <!-- sect1info mode svn-keys:
222 Self-made template to process SVN keywords found in sect1info. -->
223 <xsl:template match="sect1info" mode="svn-keys">
224 <!-- <p class="updated">Last updated --><!-- by
225 <xsl:apply-templates select="othername" mode="svn-keys"/> -->
226 <!-- on
227 <xsl:apply-templates select="date" mode="svn-keys"/>
228 </p> -->
229 </xsl:template>
230
231 <!-- othername mode svn-keys:
232 Self-made template to process the $LastChangedBy SVN keyword. -->
233 <xsl:template match="othername" mode="svn-keys">
234 <xsl:variable name="author">
235 <xsl:value-of select="."/>
236 </xsl:variable>
237 <xsl:variable name="nameonly">
238 <xsl:value-of select="substring($author,16)"/>
239 </xsl:variable>
240 <xsl:value-of select="substring-before($nameonly,'$')"/>
241 </xsl:template>
242
243 <!-- date mode svn-keys:
244 Self-made template to process the $Date SVN keyword. -->
245 <xsl:template match="date" mode="svn-keys">
246 <xsl:variable name="date">
247 <xsl:value-of select="."/>
248 </xsl:variable>
249 <xsl:value-of select="substring($date,7,26)"/>
250 </xsl:template>
251
252</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.