Fixing bugs found by running test files from docutils.
[docutils/kirr.git] / sandbox / paultremblay / xsl_fo / body_directives.xsl
blobd86791f021bcceb95ce44f20d3e7cda713018a7f
1 <xsl:stylesheet
2 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3 xmlns:fo="http://www.w3.org/1999/XSL/Format"
4 xmlns:ml = "http://www.w3.org/1998/Math/MathML"
5 version="1.1"
7 <!-- $Id: body_directives.xsl 7131 2011-09-26 19:27:15Z paultremblay $ -->
9 <xsl:attribute-set name="topic-block">
10 <xsl:attribute name="space-after">12pt</xsl:attribute>
11 <xsl:attribute name="space-before">12pt</xsl:attribute>
12 </xsl:attribute-set>
14 <xsl:attribute-set name="topic-title-block">
15 <xsl:attribute name="font-weight">bold</xsl:attribute>
16 <xsl:attribute name="space-after">12pt</xsl:attribute>
17 </xsl:attribute-set>
19 <xsl:attribute-set name="topic-paragraph-block">
20 <xsl:attribute name="space-before">12pt</xsl:attribute>
21 <xsl:attribute name="space-after">0pt</xsl:attribute>
22 </xsl:attribute-set>
24 <xsl:attribute-set name="topic-first-paragraph-block" use-attribute-sets="topic-paragraph-block">
25 </xsl:attribute-set>
27 <xsl:attribute-set name="sidebar-block">
28 <xsl:attribute name="space-after">12pt</xsl:attribute>
29 <xsl:attribute name="space-before">12pt</xsl:attribute>
30 <xsl:attribute name="background-color">#FFFFF0</xsl:attribute>
31 <xsl:attribute name="padding">6pt</xsl:attribute>
32 <xsl:attribute name="start-indent">10mm</xsl:attribute>
33 <xsl:attribute name="end-indent">40mm</xsl:attribute>
34 </xsl:attribute-set>
36 <xsl:attribute-set name="sidebar-title-block">
37 <xsl:attribute name="font-weight">bold</xsl:attribute>
38 <xsl:attribute name="space-after">12pt</xsl:attribute>
39 </xsl:attribute-set>
41 <xsl:attribute-set name="sidebar-subtitle-block">
42 <xsl:attribute name="font-weight">bold</xsl:attribute>
43 <xsl:attribute name="space-after">12pt</xsl:attribute>
44 </xsl:attribute-set>
47 <xsl:attribute-set name="sidebar-paragraph-block">
48 <xsl:attribute name="space-before">12pt</xsl:attribute>
49 </xsl:attribute-set>
51 <xsl:attribute-set name="sidebar-first-paragraph-block" use-attribute-sets="sidebar-paragraph-block">
52 <xsl:attribute name="space-after">0pt</xsl:attribute>
53 </xsl:attribute-set>
55 <xsl:attribute-set name="rubric-block">
56 <xsl:attribute name="text-align">center</xsl:attribute>
57 <xsl:attribute name="font-size">larger</xsl:attribute>
58 <xsl:attribute name="color">red</xsl:attribute>
59 </xsl:attribute-set>
61 <!--epigraph-->
62 <xsl:attribute-set name="epigraph-outer-block">
63 <xsl:attribute name="start-indent">20mm</xsl:attribute>
64 <xsl:attribute name="end-indent">20mm</xsl:attribute>
65 <xsl:attribute name="space-after">12pt</xsl:attribute>
66 <xsl:attribute name="space-before">12pt</xsl:attribute>
67 <xsl:attribute name="text-align">right</xsl:attribute>
68 <xsl:attribute name="font-style">italic</xsl:attribute>
69 </xsl:attribute-set>
71 <xsl:attribute-set name="epigraph-paragraph-block">
72 <xsl:attribute name="start-indent">inherit</xsl:attribute>
73 <xsl:attribute name="end-indent">inherit</xsl:attribute>
74 <xsl:attribute name="space-before">12pt</xsl:attribute>
75 </xsl:attribute-set>
77 <xsl:attribute-set name="epigraph-first-paragraph-block" use-attribute-sets="block-quote-paragraph-block">
78 <xsl:attribute name="space-before">0pt</xsl:attribute>
79 </xsl:attribute-set>
82 <xsl:attribute-set name="epigraph-attribution-block">
83 <xsl:attribute name="text-align">right</xsl:attribute>
84 </xsl:attribute-set>
86 <!--highlights-->
87 <xsl:attribute-set name="highlights-outer-block">
88 <xsl:attribute name="start-indent">20mm</xsl:attribute>
89 <xsl:attribute name="end-indent">20mm</xsl:attribute>
90 <xsl:attribute name="space-after">12pt</xsl:attribute>
91 <xsl:attribute name="space-before">12pt</xsl:attribute>
92 </xsl:attribute-set>
94 <xsl:attribute-set name="highlights-paragraph-block">
95 <xsl:attribute name="start-indent">inherit</xsl:attribute>
96 <xsl:attribute name="end-indent">inherit</xsl:attribute>
97 <xsl:attribute name="space-before">12pt</xsl:attribute>
98 </xsl:attribute-set>
100 <xsl:attribute-set name="highlights-first-paragraph-block" use-attribute-sets="block-quote-paragraph-block">
101 <xsl:attribute name="space-before">0pt</xsl:attribute>
102 </xsl:attribute-set>
104 <!--pull-quote-->
105 <xsl:attribute-set name="pull-quote-outer-block">
106 <xsl:attribute name="start-indent">20mm</xsl:attribute>
107 <xsl:attribute name="end-indent">20mm</xsl:attribute>
108 <xsl:attribute name="space-after">12pt</xsl:attribute>
109 <xsl:attribute name="space-before">12pt</xsl:attribute>
110 </xsl:attribute-set>
112 <xsl:attribute-set name="pull-quote-paragraph-block">
113 <xsl:attribute name="start-indent">inherit</xsl:attribute>
114 <xsl:attribute name="end-indent">inherit</xsl:attribute>
115 <xsl:attribute name="space-before">12pt</xsl:attribute>
116 </xsl:attribute-set>
118 <xsl:attribute-set name="pull-quote-first-paragraph-block" use-attribute-sets="block-quote-paragraph-block">
119 <xsl:attribute name="space-before">0pt</xsl:attribute>
120 </xsl:attribute-set>
122 <xsl:attribute-set name="pull-quote-attribution-block">
123 <xsl:attribute name="text-align">right</xsl:attribute>
124 </xsl:attribute-set>
126 <!--container-->
127 <xsl:attribute-set name="container-outer-block">
128 <xsl:attribute name="space-after">12pt</xsl:attribute>
129 <xsl:attribute name="space-before">12pt</xsl:attribute>
130 </xsl:attribute-set>
132 <xsl:attribute-set name="container-paragraph-block">
133 <xsl:attribute name="space-before">12pt</xsl:attribute>
134 </xsl:attribute-set>
136 <xsl:attribute-set name="container-first-paragraph-block" use-attribute-sets="block-quote-paragraph-block">
137 <xsl:attribute name="space-before">0pt</xsl:attribute>
138 </xsl:attribute-set>
140 <xsl:attribute-set name="mathml-block">
141 <xsl:attribute name="space-before">12pt</xsl:attribute>
142 <xsl:attribute name="space-after">12pt</xsl:attribute>
143 </xsl:attribute-set>
146 <!--END OF ATTRIBUTE SETS-->
148 <!--TOPIC-->
149 <xsl:template match="topic[not(@classes)]">
150 <fo:block xsl:use-attribute-sets="topic-block" role="topic">
151 <xsl:apply-templates/>
152 </fo:block>
153 </xsl:template>
155 <xsl:template match="topic[not(@classes)]/title">
156 <fo:block role="title" xsl:use-attribute-sets = "topic-title-block">
157 <xsl:apply-templates/>
158 </fo:block>
159 </xsl:template>
161 <xsl:template match="topic[not(@classes)]/paragraph[1]" priority="2">
162 <fo:block role="topic-paragraph" xsl:use-attribute-sets="topic-first-paragraph-block">
163 <xsl:apply-templates/>
164 </fo:block>
165 </xsl:template>
167 <xsl:template match="topic[not(@classes)]/paragraph">
168 <fo:block role="topic-paragraph" xsl:use-attribute-sets="topic-paragraph-block">
169 <xsl:apply-templates/>
170 </fo:block>
171 </xsl:template>
173 <!--SIDEBAR-->
174 <!--SHOULD I generate a warning that FOP can't do sidebars instead?-->
175 <xsl:template match="sidebar">
176 <fo:block xsl:use-attribute-sets="sidebar-block" role="sidebar">
177 <xsl:apply-templates/>
178 </fo:block>
179 </xsl:template>
181 <xsl:template match="sidebar/title">
182 <fo:block role="title" xsl:use-attribute-sets = "sidebar-title-block">
183 <xsl:apply-templates/>
184 </fo:block>
185 </xsl:template>
187 <xsl:template match="sidebar/subtitle">
188 <fo:block role="subtitle" xsl:use-attribute-sets = "sidebar-subtitle-block">
189 <xsl:apply-templates/>
190 </fo:block>
191 </xsl:template>
193 <xsl:template match="sidebar/paragraph[1]" priority="2">
194 <fo:block role="sidebar-paragraph" xsl:use-attribute-sets="sidebar-first-paragraph-block">
195 <xsl:apply-templates/>
196 </fo:block>
197 </xsl:template>
199 <xsl:template match="sidebar/paragraph">
200 <fo:block role="sidebar-paragraph" xsl:use-attribute-sets="sidebar-paragraph-block">
201 <xsl:apply-templates/>
202 </fo:block>
203 </xsl:template>
205 <!--RUBRIC-->
206 <xsl:template match="rubric[not(@classes)]">
207 <fo:block role="rubric" xsl:use-attribute-sets="rubric-block">
208 <xsl:apply-templates/>
209 </fo:block>
210 </xsl:template>
212 <!--EPIGRAPH-->
213 <xsl:template match="block_quote[@classes='epigraph']">
214 <fo:block role="epigraph" xsl:use-attribute-sets = "epigraph-outer-block">
215 <xsl:apply-templates/>
216 </fo:block>
217 </xsl:template>
219 <xsl:template match="block_quote[@classes='epigraph']/paragraph">
220 <fo:block role="epigraph-paragraph" xsl:use-attribute-sets = "epigraph-paragraph-block">
221 <xsl:apply-templates/>
222 </fo:block>
223 </xsl:template>
225 <xsl:template match="block_quote[@classes='epigraph']/paragraph[1]" priority="2">
226 <fo:block role="epigraph-paragraph" xsl:use-attribute-sets = "epigraph-first-paragraph-block">
227 <xsl:apply-templates/>
228 </fo:block>
229 </xsl:template>
231 <xsl:template match="block_quote[@classes='epigraph']/attribution">
232 <fo:block role="epigraph-attribution" xsl:use-attribute-sets = "epigraph-attribution-block">
233 <xsl:value-of select="$text-before-epigraph-attribution"/>
234 <xsl:apply-templates/>
235 </fo:block>
236 </xsl:template>
238 <!--HIGHLIGHTS-->
239 <xsl:template match="block_quote[@classes='highlights']">
240 <fo:block role="highlights" xsl:use-attribute-sets = "highlights-outer-block">
241 <xsl:apply-templates/>
242 </fo:block>
243 </xsl:template>
245 <xsl:template match="block_quote[@classes='highlights']/paragraph">
246 <fo:block role="highlights-paragraph" xsl:use-attribute-sets = "highlights-paragraph-block">
247 <xsl:apply-templates/>
248 </fo:block>
249 </xsl:template>
251 <xsl:template match="block_quote[@classes='highlights']/paragraph[1]" priority="2">
252 <fo:block role="highlights-paragraph" xsl:use-attribute-sets = "highlights-first-paragraph-block">
253 <xsl:apply-templates/>
254 </fo:block>
255 </xsl:template>
257 <!--PULL-QUOTE-->
258 <xsl:template match="block_quote[@classes='pull-quote']">
259 <fo:block role="pull-quote" xsl:use-attribute-sets = "pull-quote-outer-block">
260 <xsl:apply-templates/>
261 </fo:block>
262 </xsl:template>
264 <xsl:template match="block_quote[@classes='pull-quote']/paragraph">
265 <fo:block role="pull-quote-paragraph" xsl:use-attribute-sets = "pull-quote-paragraph-block">
266 <xsl:apply-templates/>
267 </fo:block>
268 </xsl:template>
270 <xsl:template match="block_quote[@classes='pull-quote']/paragraph[1]" priority="2">
271 <fo:block role="pull-quote-paragraph" xsl:use-attribute-sets = "pull-quote-first-paragraph-block">
272 <xsl:apply-templates/>
273 </fo:block>
274 </xsl:template>
276 <xsl:template match="block_quote[@classes='pull-quote']/attribution">
277 <fo:block role="pull-quote-attribution" xsl:use-attribute-sets = "pull-quote-attribution-block">
278 <xsl:value-of select="$text-before-pull-quote-attribution"/>
279 <xsl:apply-templates/>
280 </fo:block>
281 </xsl:template>
283 <!--CONTAINER-->
284 <xsl:template match="container">
285 <fo:block role="container" xsl:use-attribute-sets = "container-outer-block">
286 <xsl:apply-templates/>
287 </fo:block>
288 </xsl:template>
290 <xsl:template match="container/paragraph">
291 <fo:block role="container-paragraph" xsl:use-attribute-sets = "container-paragraph-block">
292 <xsl:apply-templates/>
293 </fo:block>
294 </xsl:template>
296 <xsl:template match="container/paragraph[1]" priority="2">
297 <fo:block role="container-paragraph" xsl:use-attribute-sets = "container-first-paragraph-block">
298 <xsl:apply-templates/>
299 </fo:block>
300 </xsl:template>
302 <xsl:template match="compound">
303 <xsl:apply-templates/>
304 </xsl:template>
306 <xsl:template match="math_block">
307 <xsl:choose>
308 <xsl:when test="descendant::ml:math">
309 <fo:block xsl:use-attribute-sets="mathml-block">
310 <fo:instream-foreign-object>
311 <xsl:copy-of select="ml:math"/>
312 </fo:instream-foreign-object>
313 </fo:block>
314 </xsl:when>
315 <xsl:otherwise>
316 <fo:block xsl:use-attribute-sets="literal-block">
317 <xsl:apply-templates/>
318 </fo:block>
319 </xsl:otherwise>
320 </xsl:choose>
322 </xsl:template>
326 </xsl:stylesheet>