source: xslt/vendor/current/tests/docbook/fo/sections.xsl@ 372

Last change on this file since 372 was 372, checked in by Yuri Dario, 13 years ago

xslt: initial vendor import of xslt 1.1.26.

File size: 12.1 KB
Line 
1<?xml version='1.0'?>
2<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3 xmlns:fo="http://www.w3.org/1999/XSL/Format"
4 version='1.0'>
5
6<!-- ********************************************************************
7 $Id$
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="id">
20 <xsl:call-template name="object.id"/>
21 </xsl:variable>
22
23 <fo:block id="{$id}">
24 <xsl:call-template name="section.titlepage"/>
25 <xsl:apply-templates/>
26 </fo:block>
27</xsl:template>
28
29<xsl:template match="/section">
30 <xsl:variable name="id">
31 <xsl:call-template name="object.id">
32 <xsl:with-param name="object" select="ancestor::reference"/>
33 </xsl:call-template>
34 </xsl:variable>
35 <xsl:variable name="master-name">
36 <xsl:call-template name="select.pagemaster"/>
37 </xsl:variable>
38
39 <fo:page-sequence id="{$id}"
40 hyphenate="{$hyphenate}"
41 master-name="{$master-name}">
42 <xsl:attribute name="language">
43 <xsl:call-template name="l10n.language"/>
44 </xsl:attribute>
45 <xsl:if test="$double.sided != 0">
46 <xsl:attribute name="force-page-count">end-on-even</xsl:attribute>
47 </xsl:if>
48
49 <xsl:apply-templates select="." mode="running.head.mode">
50 <xsl:with-param name="master-name" select="$master-name"/>
51 </xsl:apply-templates>
52 <xsl:apply-templates select="." mode="running.foot.mode">
53 <xsl:with-param name="master-name" select="$master-name"/>
54 </xsl:apply-templates>
55
56 <fo:flow flow-name="xsl-region-body">
57 <xsl:call-template name="section.titlepage"/>
58 <xsl:apply-templates/>
59 </fo:flow>
60 </fo:page-sequence>
61</xsl:template>
62
63<xsl:template match="title" mode="section.titlepage.recto.mode">
64 <xsl:variable name="section" select="(ancestor::section
65 |ancestor::simplesect
66 |ancestor::sect1
67 |ancestor::sect2
68 |ancestor::sect3
69 |ancestor::sect4
70 |ancestor::sect5)[last()]"/>
71 <fo:block keep-with-next.within-column="always">
72 <xsl:variable name="id">
73 <xsl:call-template name="object.id">
74 <xsl:with-param name="object" select="$section"/>
75 </xsl:call-template>
76 </xsl:variable>
77
78 <xsl:variable name="level">
79 <xsl:call-template name="section.level">
80 <xsl:with-param name="node" select="$section"/>
81 </xsl:call-template>
82 </xsl:variable>
83
84 <xsl:variable name="title">
85 <xsl:apply-templates select="$section" mode="object.title.markup"/>
86 </xsl:variable>
87
88 <xsl:if test="$passivetex.extensions != 0">
89 <fotex:bookmark xmlns:fotex="http://www.tug.org/fotex"
90 fotex-bookmark-level="{$level + 1}"
91 fotex-bookmark-label="{$id}">
92 <xsl:value-of select="$title"/>
93 </fotex:bookmark>
94 </xsl:if>
95
96 <xsl:call-template name="section.heading">
97 <xsl:with-param name="level" select="$level"/>
98 <xsl:with-param name="title" select="$title"/>
99 </xsl:call-template>
100 </fo:block>
101</xsl:template>
102
103<xsl:template match="sect1">
104 <xsl:variable name="id">
105 <xsl:call-template name="object.id"/>
106 </xsl:variable>
107
108 <fo:block id="{$id}">
109 <xsl:call-template name="sect1.titlepage"/>
110 <xsl:apply-templates/>
111 </fo:block>
112</xsl:template>
113
114<xsl:template match="/sect1">
115 <xsl:variable name="id">
116 <xsl:call-template name="object.id">
117 <xsl:with-param name="object" select="ancestor::reference"/>
118 </xsl:call-template>
119 </xsl:variable>
120 <xsl:variable name="master-name">
121 <xsl:call-template name="select.pagemaster"/>
122 </xsl:variable>
123
124 <fo:page-sequence id="{$id}"
125 hyphenate="{$hyphenate}"
126 master-name="{$master-name}">
127 <xsl:attribute name="language">
128 <xsl:call-template name="l10n.language"/>
129 </xsl:attribute>
130 <xsl:if test="$double.sided != 0">
131 <xsl:attribute name="force-page-count">end-on-even</xsl:attribute>
132 </xsl:if>
133
134 <xsl:apply-templates select="." mode="running.head.mode">
135 <xsl:with-param name="master-name" select="$master-name"/>
136 </xsl:apply-templates>
137 <xsl:apply-templates select="." mode="running.foot.mode">
138 <xsl:with-param name="master-name" select="$master-name"/>
139 </xsl:apply-templates>
140
141 <fo:flow flow-name="xsl-region-body">
142 <xsl:call-template name="sect1.titlepage"/>
143 <xsl:apply-templates/>
144 </fo:flow>
145 </fo:page-sequence>
146</xsl:template>
147
148<xsl:template match="title" mode="sect1.titlepage.recto.mode">
149 <xsl:apply-templates select="." mode="section.titlepage.recto.mode"/>
150</xsl:template>
151
152<xsl:template match="sect2">
153 <xsl:variable name="id">
154 <xsl:call-template name="object.id"/>
155 </xsl:variable>
156
157 <fo:block id="{$id}">
158 <xsl:call-template name="sect2.titlepage"/>
159 <xsl:apply-templates/>
160 </fo:block>
161</xsl:template>
162
163<xsl:template match="title" mode="sect2.titlepage.recto.mode">
164 <xsl:apply-templates select="." mode="section.titlepage.recto.mode"/>
165</xsl:template>
166
167<xsl:template match="sect3">
168 <xsl:variable name="id">
169 <xsl:call-template name="object.id"/>
170 </xsl:variable>
171
172 <fo:block id="{$id}">
173 <xsl:call-template name="sect3.titlepage"/>
174 <xsl:apply-templates/>
175 </fo:block>
176</xsl:template>
177
178<xsl:template match="title" mode="sect3.titlepage.recto.mode">
179 <xsl:apply-templates select="." mode="section.titlepage.recto.mode"/>
180</xsl:template>
181
182<xsl:template match="sect4">
183 <xsl:variable name="id">
184 <xsl:call-template name="object.id"/>
185 </xsl:variable>
186
187 <fo:block id="{$id}">
188 <xsl:call-template name="sect4.titlepage"/>
189 <xsl:apply-templates/>
190 </fo:block>
191</xsl:template>
192
193<xsl:template match="title" mode="sect4.titlepage.recto.mode">
194 <xsl:apply-templates select="." mode="section.titlepage.recto.mode"/>
195</xsl:template>
196
197<xsl:template match="sect5">
198 <xsl:variable name="id">
199 <xsl:call-template name="object.id"/>
200 </xsl:variable>
201
202 <fo:block id="{$id}">
203 <xsl:call-template name="sect5.titlepage"/>
204 <xsl:apply-templates/>
205 </fo:block>
206</xsl:template>
207
208<xsl:template match="title" mode="sect5.titlepage.recto.mode">
209 <xsl:apply-templates select="." mode="section.titlepage.recto.mode"/>
210</xsl:template>
211
212<xsl:template match="simplesect">
213 <xsl:variable name="id">
214 <xsl:call-template name="object.id"/>
215 </xsl:variable>
216
217 <fo:block id="{$id}">
218 <xsl:call-template name="simplesect.titlepage"/>
219 <xsl:apply-templates/>
220 </fo:block>
221</xsl:template>
222
223<xsl:template match="title" mode="simplesect.titlepage.recto.mode">
224 <xsl:apply-templates select="." mode="section.titlepage.recto.mode"/>
225</xsl:template>
226
227<xsl:template match="section/subtitle"></xsl:template>
228<xsl:template match="section/title"></xsl:template>
229<xsl:template match="sectioninfo"></xsl:template>
230
231<xsl:template match="sect1/title"></xsl:template>
232<xsl:template match="sect1/subtitle"></xsl:template>
233<xsl:template match="sect1info"></xsl:template>
234
235<xsl:template match="sect2/title"></xsl:template>
236<xsl:template match="sect2/subtitle"></xsl:template>
237<xsl:template match="sect2info"></xsl:template>
238
239<xsl:template match="sect3/title"></xsl:template>
240<xsl:template match="sect3/subtitle"></xsl:template>
241<xsl:template match="sect3info"></xsl:template>
242
243<xsl:template match="sect4/title"></xsl:template>
244<xsl:template match="sect4/subtitle"></xsl:template>
245<xsl:template match="sect4info"></xsl:template>
246
247<xsl:template match="sect5/title"></xsl:template>
248<xsl:template match="sect5/subtitle"></xsl:template>
249<xsl:template match="sect5info"></xsl:template>
250
251<xsl:template match="simplesect/title"></xsl:template>
252<xsl:template match="simplesect/subtitle"></xsl:template>
253
254<!-- ==================================================================== -->
255
256<xsl:template name="section.heading">
257 <xsl:param name="level">1</xsl:param>
258 <xsl:param name="title"></xsl:param>
259 <xsl:variable name="fsize">
260 <xsl:choose>
261 <xsl:when test="$level=1">18</xsl:when>
262 <xsl:when test="$level=2">16</xsl:when>
263 <xsl:when test="$level=3">14</xsl:when>
264 <xsl:when test="$level=4">12</xsl:when>
265 <xsl:when test="$level=5">12</xsl:when>
266 <xsl:otherwise>10</xsl:otherwise>
267 </xsl:choose>
268 </xsl:variable>
269 <fo:block font-size="{$fsize}pt"
270 font-weight="bold"
271 font-family="{$title.font.family}"
272 space-before.minimum="1em"
273 space-before.optimum="1.5em"
274 space-before.maximum="2em">
275 <xsl:copy-of select="$title"/>
276 </fo:block>
277</xsl:template>
278
279<!-- ==================================================================== -->
280
281<xsl:template match="bridgehead">
282 <xsl:variable name="container"
283 select="(ancestor::appendix
284 |ancestor::article
285 |ancestor::bibliography
286 |ancestor::chapter
287 |ancestor::glossary
288 |ancestor::glossdiv
289 |ancestor::index
290 |ancestor::partintro
291 |ancestor::preface
292 |ancestor::refsect1
293 |ancestor::refsect2
294 |ancestor::refsect3
295 |ancestor::sect1
296 |ancestor::sect2
297 |ancestor::sect3
298 |ancestor::sect4
299 |ancestor::sect5
300 |ancestor::section
301 |ancestor::setindex
302 |ancestor::simplesect)[last()]"/>
303
304 <xsl:variable name="clevel">
305 <xsl:choose>
306 <xsl:when test="local-name($container) = 'appendix'
307 or local-name($container) = 'chapter'
308 or local-name($container) = 'article'
309 or local-name($container) = 'bibliography'
310 or local-name($container) = 'glossary'
311 or local-name($container) = 'index'
312 or local-name($container) = 'partintro'
313 or local-name($container) = 'preface'
314 or local-name($container) = 'setindex'">2</xsl:when>
315 <xsl:when test="local-name($container) = 'glossdiv'">
316 <xsl:value-of select="count(ancestor::glossdiv)+2"/>
317 </xsl:when>
318 <xsl:when test="local-name($container) = 'sect1'
319 or local-name($container) = 'sect2'
320 or local-name($container) = 'sect3'
321 or local-name($container) = 'sect4'
322 or local-name($container) = 'sect5'
323 or local-name($container) = 'refsect1'
324 or local-name($container) = 'refsect2'
325 or local-name($container) = 'refsect3'
326 or local-name($container) = 'section'
327 or local-name($container) = 'simplesect'">
328 <xsl:variable name="slevel">
329 <xsl:call-template name="section.level">
330 <xsl:with-param name="node" select="$container"/>
331 </xsl:call-template>
332 </xsl:variable>
333 <xsl:value-of select="$slevel + 1"/>
334 </xsl:when>
335 <xsl:otherwise>2</xsl:otherwise>
336 </xsl:choose>
337 </xsl:variable>
338
339 <xsl:variable name="level">
340 <xsl:choose>
341 <xsl:when test="@renderas = 'sect1'">2</xsl:when>
342 <xsl:when test="@renderas = 'sect2'">3</xsl:when>
343 <xsl:when test="@renderas = 'sect3'">4</xsl:when>
344 <xsl:when test="@renderas = 'sect4'">5</xsl:when>
345 <xsl:when test="@renderas = 'sect5'">6</xsl:when>
346 <xsl:otherwise>
347 <xsl:value-of select="$clevel"/>
348 </xsl:otherwise>
349 </xsl:choose>
350 </xsl:variable>
351
352 <xsl:call-template name="section.heading">
353 <xsl:with-param name="level" select="$level"/>
354 <xsl:with-param name="title">
355 <xsl:apply-templates/>
356 </xsl:with-param>
357 </xsl:call-template>
358</xsl:template>
359
360</xsl:stylesheet>
361
Note: See TracBrowser for help on using the repository browser.