propaganda 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1829 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+
4
+ Copyright Antenna House, Inc. (http://www.antennahouse.com) 2001, 2002.
5
+
6
+ Since this stylesheet is originally developed by Antenna House to be used with XSL Formatter, it may not be compatible with another XSL-FO processors.
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, provided that the above copyright notice(s) and this permission notice appear in all copies of the Software and that both the above copyright notice(s) and this permission notice appear in supporting documentation.
9
+
10
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
11
+
12
+ -->
13
+
14
+ <xsl:stylesheet version="1.0"
15
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
16
+ xmlns:fo="http://www.w3.org/1999/XSL/Format"
17
+ xmlns:html="http://www.w3.org/1999/xhtml">
18
+
19
+ <xsl:output method="xml"
20
+ version="1.0"
21
+ encoding="UTF-8"
22
+ indent="yes"/>
23
+
24
+ <!--======================================================================
25
+ Parameters
26
+ =======================================================================-->
27
+
28
+ <!-- page size -->
29
+ <xsl:param name="page-width">auto</xsl:param>
30
+ <xsl:param name="page-height">auto</xsl:param>
31
+ <xsl:param name="page-margin-top">1in</xsl:param>
32
+ <xsl:param name="page-margin-bottom">1in</xsl:param>
33
+ <xsl:param name="page-margin-left">1in</xsl:param>
34
+ <xsl:param name="page-margin-right">1in</xsl:param>
35
+
36
+ <!-- page header and footer -->
37
+ <xsl:param name="page-header-margin">0.5in</xsl:param>
38
+ <xsl:param name="page-footer-margin">0.5in</xsl:param>
39
+ <xsl:param name="title-print-in-header">true</xsl:param>
40
+ <xsl:param name="page-number-print-in-footer">true</xsl:param>
41
+
42
+ <!-- multi column -->
43
+ <xsl:param name="column-count">1</xsl:param>
44
+ <xsl:param name="column-gap">12pt</xsl:param>
45
+
46
+ <!-- writing-mode: lr-tb | rl-tb | tb-rl -->
47
+ <xsl:param name="writing-mode">lr-tb</xsl:param>
48
+
49
+ <!-- text-align: justify | start -->
50
+ <xsl:param name="text-align">start</xsl:param>
51
+
52
+ <!-- hyphenate: true | false -->
53
+ <xsl:param name="hyphenate">false</xsl:param>
54
+
55
+
56
+ <!--======================================================================
57
+ Attribute Sets
58
+ =======================================================================-->
59
+
60
+
61
+ <!--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
62
+ Classes
63
+ =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-->
64
+
65
+ <xsl:template name="class-template">
66
+ <xsl:param name="class"/>
67
+ <xsl:choose>
68
+ <xsl:when test="$class = 'odd'">
69
+ <xsl:attribute name="background-color">#EEE</xsl:attribute>
70
+ </xsl:when>
71
+ <xsl:when test="$class = 'numeric'">
72
+ <xsl:attribute name="text-align">right</xsl:attribute>
73
+ </xsl:when>
74
+ <xsl:when test="$class = 'line'">
75
+ <xsl:attribute name="border-top">1px dotted #AAA</xsl:attribute>
76
+ </xsl:when>
77
+ </xsl:choose>
78
+ </xsl:template>
79
+
80
+ <!--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
81
+ Root
82
+ =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-->
83
+
84
+ <xsl:attribute-set name="root">
85
+ <xsl:attribute name="writing-mode"><xsl:value-of select="$writing-mode"/></xsl:attribute>
86
+ <xsl:attribute name="hyphenate"><xsl:value-of select="$hyphenate"/></xsl:attribute>
87
+ <xsl:attribute name="text-align"><xsl:value-of select="$text-align"/></xsl:attribute>
88
+ <!-- specified on fo:root to change the properties' initial values -->
89
+ </xsl:attribute-set>
90
+
91
+ <xsl:attribute-set name="page">
92
+ <xsl:attribute name="page-width"><xsl:value-of select="$page-width"/></xsl:attribute>
93
+ <xsl:attribute name="page-height"><xsl:value-of select="$page-height"/></xsl:attribute>
94
+ <!-- specified on fo:simple-page-master -->
95
+ </xsl:attribute-set>
96
+
97
+ <xsl:attribute-set name="body">
98
+ <!-- specified on fo:flow's only child fo:block -->
99
+ </xsl:attribute-set>
100
+
101
+ <xsl:attribute-set name="page-header">
102
+ <!-- specified on (page-header)fo:static-content's only child fo:block -->
103
+ <xsl:attribute name="font-size">small</xsl:attribute>
104
+ <xsl:attribute name="text-align">center</xsl:attribute>
105
+ </xsl:attribute-set>
106
+
107
+ <xsl:attribute-set name="page-footer">
108
+ <!-- specified on (page-footer)fo:static-content's only child fo:block -->
109
+ <xsl:attribute name="font-size">small</xsl:attribute>
110
+ <xsl:attribute name="text-align">center</xsl:attribute>
111
+ </xsl:attribute-set>
112
+
113
+ <!--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
114
+ Block-level
115
+ =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-->
116
+
117
+ <xsl:attribute-set name="h1">
118
+ <xsl:attribute name="font-size">2em</xsl:attribute>
119
+ <xsl:attribute name="font-weight">700</xsl:attribute>
120
+ <xsl:attribute name="space-before">0.67em</xsl:attribute>
121
+ <xsl:attribute name="space-after">0.67em</xsl:attribute>
122
+ <xsl:attribute name="keep-with-next.within-column">always</xsl:attribute>
123
+ <xsl:attribute name="keep-together.within-column">always</xsl:attribute>
124
+ </xsl:attribute-set>
125
+
126
+ <xsl:attribute-set name="h2">
127
+ <xsl:attribute name="font-size">1.5em</xsl:attribute>
128
+ <xsl:attribute name="font-weight">700</xsl:attribute>
129
+ <xsl:attribute name="space-before">0.83em</xsl:attribute>
130
+ <xsl:attribute name="space-after">0.83em</xsl:attribute>
131
+ <xsl:attribute name="keep-with-next.within-column">always</xsl:attribute>
132
+ <xsl:attribute name="keep-together.within-column">always</xsl:attribute>
133
+ </xsl:attribute-set>
134
+
135
+ <xsl:attribute-set name="h3">
136
+ <xsl:attribute name="font-size">1.17em</xsl:attribute>
137
+ <xsl:attribute name="font-weight">700</xsl:attribute>
138
+ <xsl:attribute name="space-before">1em</xsl:attribute>
139
+ <xsl:attribute name="space-after">1em</xsl:attribute>
140
+ <xsl:attribute name="keep-with-next.within-column">always</xsl:attribute>
141
+ <xsl:attribute name="keep-together.within-column">always</xsl:attribute>
142
+ </xsl:attribute-set>
143
+
144
+ <xsl:attribute-set name="h4">
145
+ <xsl:attribute name="font-size">1em</xsl:attribute>
146
+ <xsl:attribute name="font-weight">700</xsl:attribute>
147
+ <xsl:attribute name="space-before">1.17em</xsl:attribute>
148
+ <xsl:attribute name="space-after">1.17em</xsl:attribute>
149
+ <xsl:attribute name="keep-with-next.within-column">always</xsl:attribute>
150
+ <xsl:attribute name="keep-together.within-column">always</xsl:attribute>
151
+ </xsl:attribute-set>
152
+
153
+ <xsl:attribute-set name="h5">
154
+ <xsl:attribute name="font-size">0.83em</xsl:attribute>
155
+ <xsl:attribute name="font-weight">700</xsl:attribute>
156
+ <xsl:attribute name="space-before">1.33em</xsl:attribute>
157
+ <xsl:attribute name="space-after">1.33em</xsl:attribute>
158
+ <xsl:attribute name="keep-with-next.within-column">always</xsl:attribute>
159
+ <xsl:attribute name="keep-together.within-column">always</xsl:attribute>
160
+ </xsl:attribute-set>
161
+
162
+ <xsl:attribute-set name="h6">
163
+ <xsl:attribute name="font-size">0.67em</xsl:attribute>
164
+ <xsl:attribute name="font-weight">700</xsl:attribute>
165
+ <xsl:attribute name="space-before">1.67em</xsl:attribute>
166
+ <xsl:attribute name="space-after">1.67em</xsl:attribute>
167
+ <xsl:attribute name="keep-with-next.within-column">always</xsl:attribute>
168
+ <xsl:attribute name="keep-together.within-column">always</xsl:attribute>
169
+ </xsl:attribute-set>
170
+
171
+ <xsl:attribute-set name="p">
172
+ <xsl:attribute name="space-before">1em</xsl:attribute>
173
+ <xsl:attribute name="space-after">1em</xsl:attribute>
174
+ <!-- e.g.,
175
+ <xsl:attribute name="text-indent">1em</xsl:attribute>
176
+ -->
177
+ </xsl:attribute-set>
178
+
179
+ <xsl:attribute-set name="p-initial" use-attribute-sets="p">
180
+ <!-- initial paragraph, preceded by h1..6 or div -->
181
+ <!-- e.g.,
182
+ <xsl:attribute name="text-indent">0em</xsl:attribute>
183
+ -->
184
+ </xsl:attribute-set>
185
+
186
+ <xsl:attribute-set name="p-initial-first" use-attribute-sets="p-initial">
187
+ <!-- initial paragraph, first child of div, body or td -->
188
+ </xsl:attribute-set>
189
+
190
+ <xsl:attribute-set name="blockquote">
191
+ <xsl:attribute name="start-indent">inherited-property-value(start-indent) + 24pt</xsl:attribute>
192
+ <xsl:attribute name="end-indent">inherited-property-value(end-indent) + 24pt</xsl:attribute>
193
+ <xsl:attribute name="space-before">1em</xsl:attribute>
194
+ <xsl:attribute name="space-after">1em</xsl:attribute>
195
+ </xsl:attribute-set>
196
+
197
+ <xsl:attribute-set name="pre">
198
+ <xsl:attribute name="font-size">0.83em</xsl:attribute>
199
+ <xsl:attribute name="font-family">monospace</xsl:attribute>
200
+ <xsl:attribute name="white-space">pre</xsl:attribute>
201
+ <xsl:attribute name="space-before">1em</xsl:attribute>
202
+ <xsl:attribute name="space-after">1em</xsl:attribute>
203
+ </xsl:attribute-set>
204
+
205
+ <xsl:attribute-set name="address">
206
+ <xsl:attribute name="font-style">italic</xsl:attribute>
207
+ </xsl:attribute-set>
208
+
209
+ <xsl:attribute-set name="hr">
210
+ <xsl:attribute name="border">1px inset</xsl:attribute>
211
+ <xsl:attribute name="space-before">0.67em</xsl:attribute>
212
+ <xsl:attribute name="space-after">0.67em</xsl:attribute>
213
+ </xsl:attribute-set>
214
+
215
+ <!--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
216
+ List
217
+ =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-->
218
+
219
+ <xsl:attribute-set name="ul">
220
+ <xsl:attribute name="space-before">1em</xsl:attribute>
221
+ <xsl:attribute name="space-after">1em</xsl:attribute>
222
+ </xsl:attribute-set>
223
+
224
+ <xsl:attribute-set name="ul-nested">
225
+ <xsl:attribute name="space-before">0pt</xsl:attribute>
226
+ <xsl:attribute name="space-after">0pt</xsl:attribute>
227
+ </xsl:attribute-set>
228
+
229
+ <xsl:attribute-set name="ol">
230
+ <xsl:attribute name="space-before">1em</xsl:attribute>
231
+ <xsl:attribute name="space-after">1em</xsl:attribute>
232
+ </xsl:attribute-set>
233
+
234
+ <xsl:attribute-set name="ol-nested">
235
+ <xsl:attribute name="space-before">0pt</xsl:attribute>
236
+ <xsl:attribute name="space-after">0pt</xsl:attribute>
237
+ </xsl:attribute-set>
238
+
239
+ <xsl:attribute-set name="ul-li">
240
+ <!-- for (unordered)fo:list-item -->
241
+ <xsl:attribute name="relative-align">baseline</xsl:attribute>
242
+ </xsl:attribute-set>
243
+
244
+ <xsl:attribute-set name="ol-li">
245
+ <!-- for (ordered)fo:list-item -->
246
+ <xsl:attribute name="relative-align">baseline</xsl:attribute>
247
+ </xsl:attribute-set>
248
+
249
+ <xsl:attribute-set name="dl">
250
+ <xsl:attribute name="space-before">1em</xsl:attribute>
251
+ <xsl:attribute name="space-after">1em</xsl:attribute>
252
+ </xsl:attribute-set>
253
+
254
+ <xsl:attribute-set name="dt">
255
+ <xsl:attribute name="keep-with-next.within-column">always</xsl:attribute>
256
+ <xsl:attribute name="keep-together.within-column">always</xsl:attribute>
257
+ </xsl:attribute-set>
258
+
259
+ <xsl:attribute-set name="dd">
260
+ <xsl:attribute name="start-indent">inherited-property-value(start-indent) + 24pt</xsl:attribute>
261
+ </xsl:attribute-set>
262
+
263
+ <!-- list-item-label format for each nesting level -->
264
+
265
+ <xsl:param name="ul-label-1">&#x2022;</xsl:param>
266
+ <xsl:attribute-set name="ul-label-1">
267
+ <xsl:attribute name="font">1em serif</xsl:attribute>
268
+ </xsl:attribute-set>
269
+
270
+ <xsl:param name="ul-label-2">o</xsl:param>
271
+ <xsl:attribute-set name="ul-label-2">
272
+ <xsl:attribute name="font">0.67em monospace</xsl:attribute>
273
+ <xsl:attribute name="baseline-shift">0.25em</xsl:attribute>
274
+ </xsl:attribute-set>
275
+
276
+ <xsl:param name="ul-label-3">-</xsl:param>
277
+ <xsl:attribute-set name="ul-label-3">
278
+ <xsl:attribute name="font-weight">700</xsl:attribute>
279
+ <xsl:attribute name="font-size">0.9em</xsl:attribute>
280
+ <xsl:attribute name="font-family">sans-serif</xsl:attribute>
281
+ <xsl:attribute name="baseline-shift">0.05em</xsl:attribute>
282
+ </xsl:attribute-set>
283
+
284
+ <xsl:param name="ol-label-1">1.</xsl:param>
285
+ <xsl:attribute-set name="ol-label-1"/>
286
+
287
+ <xsl:param name="ol-label-2">a.</xsl:param>
288
+ <xsl:attribute-set name="ol-label-2"/>
289
+
290
+ <xsl:param name="ol-label-3">i.</xsl:param>
291
+ <xsl:attribute-set name="ol-label-3"/>
292
+
293
+ <!--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
294
+ Table
295
+ =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-->
296
+
297
+ <xsl:attribute-set name="inside-table">
298
+ <!-- prevent unwanted inheritance -->
299
+ <xsl:attribute name="start-indent">0pt</xsl:attribute>
300
+ <xsl:attribute name="end-indent">0pt</xsl:attribute>
301
+ <xsl:attribute name="text-indent">0pt</xsl:attribute>
302
+ <xsl:attribute name="last-line-end-indent">0pt</xsl:attribute>
303
+ <xsl:attribute name="text-align">start</xsl:attribute>
304
+ <xsl:attribute name="text-align-last">relative</xsl:attribute>
305
+ </xsl:attribute-set>
306
+
307
+ <xsl:attribute-set name="table-and-caption" >
308
+ <!-- horizontal alignment of table itself
309
+ <xsl:attribute name="text-align">center</xsl:attribute>
310
+ -->
311
+ <!-- vertical alignment in table-cell -->
312
+ <xsl:attribute name="display-align">center</xsl:attribute>
313
+ </xsl:attribute-set>
314
+
315
+ <xsl:attribute-set name="table">
316
+ <xsl:attribute name="table-layout">fixed</xsl:attribute>
317
+ <xsl:attribute name="width">100%</xsl:attribute>
318
+ <xsl:attribute name="border">1px solid black</xsl:attribute>
319
+ <!--
320
+ <xsl:attribute name="border-collapse">separate</xsl:attribute>
321
+ <xsl:attribute name="border-spacing">2px</xsl:attribute>
322
+ <xsl:attribute name="border-style">outset</xsl:attribute>
323
+ -->
324
+ </xsl:attribute-set>
325
+
326
+ <xsl:attribute-set name="table-caption" use-attribute-sets="inside-table">
327
+ <xsl:attribute name="font-size">smaller</xsl:attribute>
328
+ <xsl:attribute name="font-style">italic</xsl:attribute>
329
+ <xsl:attribute name="text-align">center</xsl:attribute>
330
+ </xsl:attribute-set>
331
+
332
+ <xsl:attribute-set name="table-column">
333
+ </xsl:attribute-set>
334
+
335
+ <xsl:attribute-set name="thead" use-attribute-sets="inside-table">
336
+ </xsl:attribute-set>
337
+
338
+ <xsl:attribute-set name="tfoot" use-attribute-sets="inside-table">
339
+ </xsl:attribute-set>
340
+
341
+ <xsl:attribute-set name="tbody" use-attribute-sets="inside-table">
342
+ </xsl:attribute-set>
343
+
344
+ <xsl:attribute-set name="tr">
345
+ </xsl:attribute-set>
346
+
347
+ <xsl:attribute-set name="th">
348
+ <xsl:attribute name="font-weight">700</xsl:attribute>
349
+ <xsl:attribute name="text-align">center</xsl:attribute>
350
+ <!--
351
+ <xsl:attribute name="border">1px</xsl:attribute>
352
+ <xsl:attribute name="border-style">inset</xsl:attribute>
353
+ -->
354
+ <xsl:attribute name="padding">1px</xsl:attribute>
355
+ </xsl:attribute-set>
356
+
357
+ <xsl:attribute-set name="td">
358
+ <xsl:attribute name="border-top">1px solid black</xsl:attribute>
359
+ <!--
360
+ <xsl:attribute name="border-style">inset</xsl:attribute>
361
+ -->
362
+ <xsl:attribute name="padding">1px</xsl:attribute>
363
+ </xsl:attribute-set>
364
+
365
+ <!--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
366
+ Inline-level
367
+ =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-->
368
+
369
+ <xsl:attribute-set name="b">
370
+ <xsl:attribute name="font-weight">700</xsl:attribute>
371
+ </xsl:attribute-set>
372
+ <xsl:attribute-set name="strong">
373
+ <xsl:attribute name="font-weight">700</xsl:attribute>
374
+ </xsl:attribute-set>
375
+
376
+ <xsl:attribute-set name="strong-em">
377
+ <xsl:attribute name="font-weight">700</xsl:attribute>
378
+ <xsl:attribute name="font-style">italic</xsl:attribute>
379
+ </xsl:attribute-set>
380
+
381
+ <xsl:attribute-set name="i">
382
+ <xsl:attribute name="font-style">italic</xsl:attribute>
383
+ </xsl:attribute-set>
384
+ <xsl:attribute-set name="cite">
385
+ <xsl:attribute name="font-style">italic</xsl:attribute>
386
+ </xsl:attribute-set>
387
+ <xsl:attribute-set name="em">
388
+ <xsl:attribute name="font-style">italic</xsl:attribute>
389
+ </xsl:attribute-set>
390
+ <xsl:attribute-set name="var">
391
+ <xsl:attribute name="font-style">italic</xsl:attribute>
392
+ </xsl:attribute-set>
393
+ <xsl:attribute-set name="dfn">
394
+ <xsl:attribute name="font-style">italic</xsl:attribute>
395
+ </xsl:attribute-set>
396
+
397
+ <xsl:attribute-set name="tt">
398
+ <xsl:attribute name="font-family">monospace</xsl:attribute>
399
+ </xsl:attribute-set>
400
+ <xsl:attribute-set name="code">
401
+ <xsl:attribute name="font-family">monospace</xsl:attribute>
402
+ </xsl:attribute-set>
403
+ <xsl:attribute-set name="kbd">
404
+ <xsl:attribute name="font-family">monospace</xsl:attribute>
405
+ </xsl:attribute-set>
406
+ <xsl:attribute-set name="samp">
407
+ <xsl:attribute name="font-family">monospace</xsl:attribute>
408
+ </xsl:attribute-set>
409
+
410
+ <xsl:attribute-set name="big">
411
+ <xsl:attribute name="font-size">larger</xsl:attribute>
412
+ </xsl:attribute-set>
413
+ <xsl:attribute-set name="small">
414
+ <xsl:attribute name="font-size">smaller</xsl:attribute>
415
+ </xsl:attribute-set>
416
+
417
+ <xsl:attribute-set name="sub">
418
+ <xsl:attribute name="baseline-shift">sub</xsl:attribute>
419
+ <xsl:attribute name="font-size">smaller</xsl:attribute>
420
+ </xsl:attribute-set>
421
+ <xsl:attribute-set name="sup">
422
+ <xsl:attribute name="baseline-shift">super</xsl:attribute>
423
+ <xsl:attribute name="font-size">smaller</xsl:attribute>
424
+ </xsl:attribute-set>
425
+
426
+ <xsl:attribute-set name="s">
427
+ <xsl:attribute name="text-decoration">line-through</xsl:attribute>
428
+ </xsl:attribute-set>
429
+ <xsl:attribute-set name="strike">
430
+ <xsl:attribute name="text-decoration">line-through</xsl:attribute>
431
+ </xsl:attribute-set>
432
+ <xsl:attribute-set name="del">
433
+ <xsl:attribute name="text-decoration">line-through</xsl:attribute>
434
+ </xsl:attribute-set>
435
+
436
+ <xsl:attribute-set name="u">
437
+ <xsl:attribute name="text-decoration">underline</xsl:attribute>
438
+ </xsl:attribute-set>
439
+ <xsl:attribute-set name="ins">
440
+ <xsl:attribute name="text-decoration">underline</xsl:attribute>
441
+ </xsl:attribute-set>
442
+
443
+ <xsl:attribute-set name="abbr">
444
+ <!-- e.g.,
445
+ <xsl:attribute name="font-variant">small-caps</xsl:attribute>
446
+ <xsl:attribute name="letter-spacing">0.1em</xsl:attribute>
447
+ -->
448
+ </xsl:attribute-set>
449
+
450
+ <xsl:attribute-set name="acronym">
451
+ <!-- e.g.,
452
+ <xsl:attribute name="font-variant">small-caps</xsl:attribute>
453
+ <xsl:attribute name="letter-spacing">0.1em</xsl:attribute>
454
+ -->
455
+ </xsl:attribute-set>
456
+
457
+ <xsl:attribute-set name="q"/>
458
+ <xsl:attribute-set name="q-nested"/>
459
+
460
+ <!--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
461
+ Image
462
+ =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-->
463
+
464
+ <xsl:attribute-set name="img">
465
+ </xsl:attribute-set>
466
+
467
+ <xsl:attribute-set name="img-link">
468
+ <xsl:attribute name="border">2px solid</xsl:attribute>
469
+ </xsl:attribute-set>
470
+
471
+ <!--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
472
+ Link
473
+ =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-->
474
+
475
+ <xsl:attribute-set name="a-link">
476
+ <xsl:attribute name="text-decoration">underline</xsl:attribute>
477
+ <xsl:attribute name="color">blue</xsl:attribute>
478
+ </xsl:attribute-set>
479
+
480
+
481
+ <!--======================================================================
482
+ Templates
483
+ =======================================================================-->
484
+
485
+ <!--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
486
+ Root
487
+ =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-->
488
+
489
+ <xsl:template match="html:html">
490
+ <fo:root xsl:use-attribute-sets="root">
491
+ <xsl:call-template name="process-common-attributes"/>
492
+ <xsl:call-template name="make-layout-master-set"/>
493
+ <xsl:apply-templates/>
494
+ </fo:root>
495
+ </xsl:template>
496
+
497
+ <xsl:template name="make-layout-master-set">
498
+ <fo:layout-master-set>
499
+ <fo:simple-page-master master-name="all-pages"
500
+ xsl:use-attribute-sets="page">
501
+ <fo:region-body margin-top="{$page-margin-top}"
502
+ margin-right="{$page-margin-right}"
503
+ margin-bottom="{$page-margin-bottom}"
504
+ margin-left="{$page-margin-left}"
505
+ column-count="{$column-count}"
506
+ column-gap="{$column-gap}"/>
507
+ <xsl:choose>
508
+ <xsl:when test="$writing-mode = 'tb-rl'">
509
+ <fo:region-before extent="{$page-margin-right}"
510
+ precedence="true"/>
511
+ <fo:region-after extent="{$page-margin-left}"
512
+ precedence="true"/>
513
+ <fo:region-start region-name="page-header"
514
+ extent="{$page-margin-top}"
515
+ writing-mode="lr-tb"
516
+ display-align="before"/>
517
+ <fo:region-end region-name="page-footer"
518
+ extent="{$page-margin-bottom}"
519
+ writing-mode="lr-tb"
520
+ display-align="after"/>
521
+ </xsl:when>
522
+ <xsl:when test="$writing-mode = 'rl-tb'">
523
+ <fo:region-before region-name="page-header"
524
+ extent="{$page-margin-top}"
525
+ display-align="before"/>
526
+ <fo:region-after region-name="page-footer"
527
+ extent="{$page-margin-bottom}"
528
+ display-align="after"/>
529
+ <fo:region-start extent="{$page-margin-right}"/>
530
+ <fo:region-end extent="{$page-margin-left}"/>
531
+ </xsl:when>
532
+ <xsl:otherwise><!-- $writing-mode = 'lr-tb' -->
533
+ <fo:region-before region-name="page-header"
534
+ extent="{$page-margin-top}"
535
+ display-align="before"/>
536
+ <fo:region-after region-name="page-footer"
537
+ extent="{$page-margin-bottom}"
538
+ display-align="after"/>
539
+ <fo:region-start extent="{$page-margin-left}"/>
540
+ <fo:region-end extent="{$page-margin-bottom}"/>
541
+ </xsl:otherwise>
542
+ </xsl:choose>
543
+ </fo:simple-page-master>
544
+ </fo:layout-master-set>
545
+ </xsl:template>
546
+
547
+ <xsl:template match="html:head | html:script"/>
548
+
549
+ <xsl:template match="html:body">
550
+ <fo:page-sequence master-reference="all-pages">
551
+ <fo:title>
552
+ <xsl:value-of select="/html:html/html:head/html:title"/>
553
+ </fo:title>
554
+ <fo:static-content flow-name="page-header">
555
+ <fo:block space-before.conditionality="retain"
556
+ space-before="{$page-header-margin}"
557
+ xsl:use-attribute-sets="page-header">
558
+ <xsl:if test="$title-print-in-header = 'true'">
559
+ <xsl:value-of select="/html:html/html:head/html:title"/>
560
+ </xsl:if>
561
+ </fo:block>
562
+ </fo:static-content>
563
+ <fo:static-content flow-name="page-footer">
564
+ <fo:block space-after.conditionality="retain"
565
+ space-after="{$page-footer-margin}"
566
+ xsl:use-attribute-sets="page-footer">
567
+ <xsl:if test="$page-number-print-in-footer = 'true'">
568
+ <xsl:text>- </xsl:text>
569
+ <fo:page-number/>
570
+ <xsl:text> -</xsl:text>
571
+ </xsl:if>
572
+ </fo:block>
573
+ </fo:static-content>
574
+ <fo:flow flow-name="xsl-region-body">
575
+ <fo:block xsl:use-attribute-sets="body">
576
+ <xsl:call-template name="process-common-attributes"/>
577
+ <xsl:apply-templates/>
578
+ </fo:block>
579
+ </fo:flow>
580
+ </fo:page-sequence>
581
+ </xsl:template>
582
+
583
+ <!--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
584
+ process common attributes and children
585
+ =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-->
586
+
587
+ <xsl:template name="process-common-attributes-and-children">
588
+ <xsl:call-template name="process-common-attributes"/>
589
+ <xsl:apply-templates/>
590
+ </xsl:template>
591
+
592
+ <xsl:template name="process-common-attributes">
593
+ <xsl:attribute name="role">
594
+ <xsl:value-of select="concat('html:', local-name())"/>
595
+ </xsl:attribute>
596
+
597
+ <xsl:choose>
598
+ <xsl:when test="@xml:lang">
599
+ <xsl:attribute name="xml:lang">
600
+ <xsl:value-of select="@xml:lang"/>
601
+ </xsl:attribute>
602
+ </xsl:when>
603
+ <xsl:when test="@lang">
604
+ <xsl:attribute name="xml:lang">
605
+ <xsl:value-of select="@lang"/>
606
+ </xsl:attribute>
607
+ </xsl:when>
608
+ </xsl:choose>
609
+
610
+ <xsl:choose>
611
+ <xsl:when test="@id">
612
+ <xsl:attribute name="id">
613
+ <xsl:value-of select="@id"/>
614
+ </xsl:attribute>
615
+ </xsl:when>
616
+ <xsl:when test="self::html:a/@name">
617
+ <xsl:attribute name="id">
618
+ <xsl:value-of select="@name"/>
619
+ </xsl:attribute>
620
+ </xsl:when>
621
+ </xsl:choose>
622
+
623
+ <xsl:if test="@align">
624
+ <xsl:choose>
625
+ <xsl:when test="self::html:caption">
626
+ </xsl:when>
627
+ <xsl:when test="self::html:img or self::html:object">
628
+ <xsl:if test="@align = 'bottom' or @align = 'middle' or @align = 'top'">
629
+ <xsl:attribute name="vertical-align">
630
+ <xsl:value-of select="@align"/>
631
+ </xsl:attribute>
632
+ </xsl:if>
633
+ </xsl:when>
634
+ <xsl:otherwise>
635
+ <xsl:call-template name="process-cell-align">
636
+ <xsl:with-param name="align" select="@align"/>
637
+ </xsl:call-template>
638
+ </xsl:otherwise>
639
+ </xsl:choose>
640
+ </xsl:if>
641
+ <xsl:if test="@valign">
642
+ <xsl:call-template name="process-cell-valign">
643
+ <xsl:with-param name="valign" select="@valign"/>
644
+ </xsl:call-template>
645
+ </xsl:if>
646
+
647
+ <xsl:if test="@style">
648
+ <xsl:call-template name="process-style">
649
+ <xsl:with-param name="style" select="@style"/>
650
+ </xsl:call-template>
651
+ </xsl:if>
652
+
653
+ <xsl:if test="@class">
654
+ <xsl:call-template name="process-class">
655
+ <xsl:with-param name="class" select="@class"/>
656
+ </xsl:call-template>
657
+ </xsl:if>
658
+
659
+ </xsl:template>
660
+
661
+ <xsl:template name="process-style">
662
+ <xsl:param name="style"/>
663
+ <!-- e.g., style="text-align: center; color: red"
664
+ converted to text-align="center" color="red" -->
665
+ <xsl:variable name="name"
666
+ select="normalize-space(substring-before($style, ':'))"/>
667
+ <xsl:if test="$name">
668
+ <xsl:variable name="value-and-rest"
669
+ select="normalize-space(substring-after($style, ':'))"/>
670
+ <xsl:variable name="value">
671
+ <xsl:choose>
672
+ <xsl:when test="contains($value-and-rest, ';')">
673
+ <xsl:value-of select="normalize-space(substring-before(
674
+ $value-and-rest, ';'))"/>
675
+ </xsl:when>
676
+ <xsl:otherwise>
677
+ <xsl:value-of select="$value-and-rest"/>
678
+ </xsl:otherwise>
679
+ </xsl:choose>
680
+ </xsl:variable>
681
+ <xsl:choose>
682
+ <xsl:when test="$name = 'width' and (self::html:col or self::html:colgroup)">
683
+ <xsl:attribute name="column-width">
684
+ <xsl:value-of select="$value"/>
685
+ </xsl:attribute>
686
+ </xsl:when>
687
+ <xsl:when test="$name = 'vertical-align' and (
688
+ self::html:table or self::html:caption or
689
+ self::html:thead or self::html:tfoot or
690
+ self::html:tbody or self::html:colgroup or
691
+ self::html:col or self::html:tr or
692
+ self::html:th or self::html:td)">
693
+ <xsl:choose>
694
+ <xsl:when test="$value = 'top'">
695
+ <xsl:attribute name="display-align">before</xsl:attribute>
696
+ </xsl:when>
697
+ <xsl:when test="$value = 'bottom'">
698
+ <xsl:attribute name="display-align">after</xsl:attribute>
699
+ </xsl:when>
700
+ <xsl:when test="$value = 'middle'">
701
+ <xsl:attribute name="display-align">center</xsl:attribute>
702
+ </xsl:when>
703
+ <xsl:otherwise>
704
+ <xsl:attribute name="display-align">auto</xsl:attribute>
705
+ <xsl:attribute name="relative-align">baseline</xsl:attribute>
706
+ </xsl:otherwise>
707
+ </xsl:choose>
708
+ </xsl:when>
709
+ <xsl:otherwise>
710
+ <xsl:attribute name="{$name}">
711
+ <xsl:value-of select="$value"/>
712
+ </xsl:attribute>
713
+ </xsl:otherwise>
714
+ </xsl:choose>
715
+ </xsl:if>
716
+ <xsl:variable name="rest"
717
+ select="normalize-space(substring-after($style, ';'))"/>
718
+ <xsl:if test="$rest">
719
+ <xsl:call-template name="process-style">
720
+ <xsl:with-param name="style" select="$rest"/>
721
+ </xsl:call-template>
722
+ </xsl:if>
723
+ </xsl:template>
724
+
725
+ <xsl:template name="process-class">
726
+ <xsl:param name="class"/>
727
+ <!-- e.g., Breaking logic (for table cells and block level objects) 'break-before'
728
+ and 'break-after' converted to break-before="<context>" or break-after="<context>"
729
+ where <context> is column if it is within a table otherwise page -->
730
+
731
+ <!-- e.g., Keeping logic (for table cells and block level objects) 'keep-together'
732
+ and 'keep-with-next' and 'keep-with-previous' and converted to
733
+ keep-together.within-<context>="always" etc. where <context> is line if
734
+ the declaration is found on an inline level element, column if within a
735
+ table cell otherwise page -->
736
+
737
+ <xsl:variable name="name" select="normalize-space(substring-before(concat($class, ' '), ' '))" />
738
+ <xsl:if test="$name">
739
+ <xsl:choose>
740
+ <xsl:when test="($name = 'break-before' or $name = 'break-after') and
741
+ (self::html:col or
742
+ self::html:colgroup or
743
+ self::html:th or
744
+ self::html:td)">
745
+ <xsl:attribute name="{$name}">column</xsl:attribute>
746
+ </xsl:when>
747
+
748
+ <xsl:when test="($name = 'keep-together' or $name = 'keep-with-next' or $name = 'keep-with-previous') and
749
+ (self::html:a or
750
+ self::html:abbr or
751
+ self::html:acronym or
752
+ self::html:b or
753
+ self::html:basefont or
754
+ self::html:bdo or
755
+ self::html:big or
756
+ self::html:br or
757
+ self::html:cite or
758
+ self::html:code or
759
+ self::html:dfn or
760
+ self::html:em or
761
+ self::html:font or
762
+ self::html:i or
763
+ self::html:img or
764
+ self::html:input or
765
+ self::html:kbd or
766
+ self::html:label or
767
+ self::html:q or
768
+ self::html:s or
769
+ self::html:samp or
770
+ self::html:select or
771
+ self::html:small or
772
+ self::html:span or
773
+ self::html:strike or
774
+ self::html:strong or
775
+ self::html:sub or
776
+ self::html:sup or
777
+ self::html:textarea or
778
+ self::html:tt or
779
+ self::html:u or
780
+ self::html:var)">
781
+ <xsl:attribute name="{$name}.within-line">always</xsl:attribute>
782
+ </xsl:when>
783
+
784
+ <xsl:when test="($name = 'keep-together' or $name = 'keep-with-next' or $name = 'keep-with-previous') and
785
+ (self::html:col or
786
+ self::html:colgroup or
787
+ self::html:th or
788
+ self::html:td)">
789
+ <xsl:attribute name="{$name}.within-column">always</xsl:attribute>
790
+ </xsl:when>
791
+
792
+ <xsl:when test="($name = 'keep-together' or $name = 'keep-with-next' or $name = 'keep-with-previous')">
793
+ <xsl:attribute name="{$name}.within-page">always</xsl:attribute>
794
+ </xsl:when>
795
+
796
+ <xsl:when test="($name = 'break-before' or $name = 'break-after')">
797
+ <xsl:attribute name="{$name}">page</xsl:attribute>
798
+ </xsl:when>
799
+
800
+ <xsl:otherwise>
801
+ <xsl:call-template name="class-template">
802
+ <xsl:with-param name="class" select="$name"/>
803
+ </xsl:call-template>
804
+ </xsl:otherwise>
805
+ </xsl:choose>
806
+ </xsl:if>
807
+ <xsl:variable name="rest" select="normalize-space(substring-after($class, ' '))" />
808
+ <xsl:if test="$rest">
809
+ <xsl:call-template name="process-class">
810
+ <xsl:with-param name="class" select="$rest"/>
811
+ </xsl:call-template>
812
+ </xsl:if>
813
+ </xsl:template>
814
+
815
+ <!--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
816
+ Block-level
817
+ =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-->
818
+
819
+ <xsl:template match="html:h1">
820
+ <fo:block xsl:use-attribute-sets="h1">
821
+ <xsl:call-template name="process-common-attributes-and-children"/>
822
+ </fo:block>
823
+ </xsl:template>
824
+
825
+ <xsl:template match="html:h2">
826
+ <fo:block xsl:use-attribute-sets="h2">
827
+ <xsl:call-template name="process-common-attributes-and-children"/>
828
+ </fo:block>
829
+ </xsl:template>
830
+
831
+ <xsl:template match="html:h3">
832
+ <fo:block xsl:use-attribute-sets="h3">
833
+ <xsl:call-template name="process-common-attributes-and-children"/>
834
+ </fo:block>
835
+ </xsl:template>
836
+
837
+ <xsl:template match="html:h4">
838
+ <fo:block xsl:use-attribute-sets="h4">
839
+ <xsl:call-template name="process-common-attributes-and-children"/>
840
+ </fo:block>
841
+ </xsl:template>
842
+
843
+ <xsl:template match="html:h5">
844
+ <fo:block xsl:use-attribute-sets="h5">
845
+ <xsl:call-template name="process-common-attributes-and-children"/>
846
+ </fo:block>
847
+ </xsl:template>
848
+
849
+ <xsl:template match="html:h6">
850
+ <fo:block xsl:use-attribute-sets="h6">
851
+ <xsl:call-template name="process-common-attributes-and-children"/>
852
+ </fo:block>
853
+ </xsl:template>
854
+
855
+ <xsl:template match="html:p">
856
+ <fo:block xsl:use-attribute-sets="p">
857
+ <xsl:call-template name="process-common-attributes-and-children"/>
858
+ </fo:block>
859
+ </xsl:template>
860
+
861
+ <!-- initial paragraph, preceded by h1..6 or div -->
862
+ <xsl:template match="html:p[preceding-sibling::*[1][
863
+ self::html:h1 or self::html:h2 or self::html:h3 or
864
+ self::html:h4 or self::html:h5 or self::html:h6 or
865
+ self::html:div]]">
866
+ <fo:block xsl:use-attribute-sets="p-initial">
867
+ <xsl:call-template name="process-common-attributes-and-children"/>
868
+ </fo:block>
869
+ </xsl:template>
870
+
871
+ <!-- initial paragraph, first child of div, body or td -->
872
+ <xsl:template match="html:p[not(preceding-sibling::*) and (
873
+ parent::html:div or parent::html:body or
874
+ parent::html:td)]">
875
+ <fo:block xsl:use-attribute-sets="p-initial-first">
876
+ <xsl:call-template name="process-common-attributes-and-children"/>
877
+ </fo:block>
878
+ </xsl:template>
879
+
880
+ <xsl:template match="html:blockquote">
881
+ <fo:block xsl:use-attribute-sets="blockquote">
882
+ <xsl:call-template name="process-common-attributes-and-children"/>
883
+ </fo:block>
884
+ </xsl:template>
885
+
886
+ <xsl:template match="html:pre">
887
+ <fo:block xsl:use-attribute-sets="pre">
888
+ <xsl:call-template name="process-pre"/>
889
+ </fo:block>
890
+ </xsl:template>
891
+
892
+ <xsl:template name="process-pre">
893
+ <xsl:call-template name="process-common-attributes"/>
894
+ <!-- remove leading CR/LF/CRLF char -->
895
+ <xsl:variable name="crlf"><xsl:text>&#xD;&#xA;</xsl:text></xsl:variable>
896
+ <xsl:variable name="lf"><xsl:text>&#xA;</xsl:text></xsl:variable>
897
+ <xsl:variable name="cr"><xsl:text>&#xD;</xsl:text></xsl:variable>
898
+ <xsl:for-each select="node()">
899
+ <xsl:choose>
900
+ <xsl:when test="position() = 1 and self::text()">
901
+ <xsl:choose>
902
+ <xsl:when test="starts-with(., $lf)">
903
+ <xsl:value-of select="substring(., 2)"/>
904
+ </xsl:when>
905
+ <xsl:when test="starts-with(., $crlf)">
906
+ <xsl:value-of select="substring(., 3)"/>
907
+ </xsl:when>
908
+ <xsl:when test="starts-with(., $cr)">
909
+ <xsl:value-of select="substring(., 2)"/>
910
+ </xsl:when>
911
+ <xsl:otherwise>
912
+ <xsl:apply-templates select="."/>
913
+ </xsl:otherwise>
914
+ </xsl:choose>
915
+ </xsl:when>
916
+ <xsl:otherwise>
917
+ <xsl:apply-templates select="."/>
918
+ </xsl:otherwise>
919
+ </xsl:choose>
920
+ </xsl:for-each>
921
+ </xsl:template>
922
+
923
+ <xsl:template match="html:address">
924
+ <fo:block xsl:use-attribute-sets="address">
925
+ <xsl:call-template name="process-common-attributes-and-children"/>
926
+ </fo:block>
927
+ </xsl:template>
928
+
929
+ <xsl:template match="html:hr">
930
+ <fo:block xsl:use-attribute-sets="hr">
931
+ <xsl:call-template name="process-common-attributes"/>
932
+ </fo:block>
933
+ </xsl:template>
934
+
935
+ <xsl:template match="html:div">
936
+ <!-- need fo:block-container? or normal fo:block -->
937
+ <xsl:variable name="need-block-container">
938
+ <xsl:call-template name="need-block-container"/>
939
+ </xsl:variable>
940
+ <xsl:choose>
941
+ <xsl:when test="$need-block-container = 'true'">
942
+ <fo:block-container>
943
+ <xsl:if test="@dir">
944
+ <xsl:attribute name="writing-mode">
945
+ <xsl:choose>
946
+ <xsl:when test="@dir = 'rtl'">rl-tb</xsl:when>
947
+ <xsl:otherwise>lr-tb</xsl:otherwise>
948
+ </xsl:choose>
949
+ </xsl:attribute>
950
+ </xsl:if>
951
+ <xsl:call-template name="process-common-attributes"/>
952
+ <fo:block start-indent="0pt" end-indent="0pt">
953
+ <xsl:apply-templates/>
954
+ </fo:block>
955
+ </fo:block-container>
956
+ </xsl:when>
957
+ <xsl:otherwise>
958
+ <!-- normal block -->
959
+ <fo:block>
960
+ <xsl:call-template name="process-common-attributes"/>
961
+ <xsl:apply-templates/>
962
+ </fo:block>
963
+ </xsl:otherwise>
964
+ </xsl:choose>
965
+ </xsl:template>
966
+
967
+ <xsl:template name="need-block-container">
968
+ <xsl:choose>
969
+ <xsl:when test="@dir">true</xsl:when>
970
+ <xsl:when test="@style">
971
+ <xsl:variable name="s"
972
+ select="concat(';', translate(normalize-space(@style),
973
+ ' ', ''))"/>
974
+ <xsl:choose>
975
+ <xsl:when test="contains($s, ';width:') or
976
+ contains($s, ';height:') or
977
+ contains($s, ';position:absolute') or
978
+ contains($s, ';position:fixed') or
979
+ contains($s, ';writing-mode:')">true</xsl:when>
980
+ <xsl:otherwise>false</xsl:otherwise>
981
+ </xsl:choose>
982
+ </xsl:when>
983
+ <xsl:otherwise>false</xsl:otherwise>
984
+ </xsl:choose>
985
+ </xsl:template>
986
+
987
+ <xsl:template match="html:center">
988
+ <fo:block text-align="center">
989
+ <xsl:call-template name="process-common-attributes-and-children"/>
990
+ </fo:block>
991
+ </xsl:template>
992
+
993
+ <xsl:template match="html:fieldset | html:form | html:dir | html:menu">
994
+ <fo:block space-before="1em" space-after="1em">
995
+ <xsl:call-template name="process-common-attributes-and-children"/>
996
+ </fo:block>
997
+ </xsl:template>
998
+
999
+ <!--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
1000
+ List
1001
+ =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-->
1002
+
1003
+ <xsl:template match="html:ul">
1004
+ <fo:list-block xsl:use-attribute-sets="ul">
1005
+ <xsl:call-template name="process-common-attributes-and-children"/>
1006
+ </fo:list-block>
1007
+ </xsl:template>
1008
+
1009
+ <xsl:template match="html:li//html:ul">
1010
+ <fo:list-block xsl:use-attribute-sets="ul-nested">
1011
+ <xsl:call-template name="process-common-attributes-and-children"/>
1012
+ </fo:list-block>
1013
+ </xsl:template>
1014
+
1015
+ <xsl:template match="html:ol">
1016
+ <fo:list-block xsl:use-attribute-sets="ol">
1017
+ <xsl:call-template name="process-common-attributes-and-children"/>
1018
+ </fo:list-block>
1019
+ </xsl:template>
1020
+
1021
+ <xsl:template match="html:li//html:ol">
1022
+ <fo:list-block xsl:use-attribute-sets="ol-nested">
1023
+ <xsl:call-template name="process-common-attributes-and-children"/>
1024
+ </fo:list-block>
1025
+ </xsl:template>
1026
+
1027
+ <xsl:template match="html:ul/html:li">
1028
+ <fo:list-item xsl:use-attribute-sets="ul-li">
1029
+ <xsl:call-template name="process-ul-li"/>
1030
+ </fo:list-item>
1031
+ </xsl:template>
1032
+
1033
+ <xsl:template name="process-ul-li">
1034
+ <xsl:call-template name="process-common-attributes"/>
1035
+ <fo:list-item-label end-indent="label-end()"
1036
+ text-align="end" wrap-option="no-wrap">
1037
+ <fo:block>
1038
+ <xsl:variable name="depth" select="count(ancestor::html:ul)" />
1039
+ <xsl:choose>
1040
+ <xsl:when test="$depth = 1">
1041
+ <fo:inline xsl:use-attribute-sets="ul-label-1">
1042
+ <xsl:value-of select="$ul-label-1"/>
1043
+ </fo:inline>
1044
+ </xsl:when>
1045
+ <xsl:when test="$depth = 2">
1046
+ <fo:inline xsl:use-attribute-sets="ul-label-2">
1047
+ <xsl:value-of select="$ul-label-2"/>
1048
+ </fo:inline>
1049
+ </xsl:when>
1050
+ <xsl:otherwise>
1051
+ <fo:inline xsl:use-attribute-sets="ul-label-3">
1052
+ <xsl:value-of select="$ul-label-3"/>
1053
+ </fo:inline>
1054
+ </xsl:otherwise>
1055
+ </xsl:choose>
1056
+ </fo:block>
1057
+ </fo:list-item-label>
1058
+ <fo:list-item-body start-indent="body-start()">
1059
+ <fo:block>
1060
+ <xsl:apply-templates/>
1061
+ </fo:block>
1062
+ </fo:list-item-body>
1063
+ </xsl:template>
1064
+
1065
+ <xsl:template match="html:ol/html:li">
1066
+ <fo:list-item xsl:use-attribute-sets="ol-li">
1067
+ <xsl:call-template name="process-ol-li"/>
1068
+ </fo:list-item>
1069
+ </xsl:template>
1070
+
1071
+ <xsl:template name="process-ol-li">
1072
+ <xsl:call-template name="process-common-attributes"/>
1073
+ <fo:list-item-label end-indent="label-end()"
1074
+ text-align="end" wrap-option="no-wrap">
1075
+ <fo:block>
1076
+ <xsl:variable name="depth" select="count(ancestor::html:ol)" />
1077
+ <xsl:choose>
1078
+ <xsl:when test="$depth = 1">
1079
+ <fo:inline xsl:use-attribute-sets="ol-label-1">
1080
+ <xsl:number format="{$ol-label-1}"/>
1081
+ </fo:inline>
1082
+ </xsl:when>
1083
+ <xsl:when test="$depth = 2">
1084
+ <fo:inline xsl:use-attribute-sets="ol-label-2">
1085
+ <xsl:number format="{$ol-label-2}"/>
1086
+ </fo:inline>
1087
+ </xsl:when>
1088
+ <xsl:otherwise>
1089
+ <fo:inline xsl:use-attribute-sets="ol-label-3">
1090
+ <xsl:number format="{$ol-label-3}"/>
1091
+ </fo:inline>
1092
+ </xsl:otherwise>
1093
+ </xsl:choose>
1094
+ </fo:block>
1095
+ </fo:list-item-label>
1096
+ <fo:list-item-body start-indent="body-start()">
1097
+ <fo:block>
1098
+ <xsl:apply-templates/>
1099
+ </fo:block>
1100
+ </fo:list-item-body>
1101
+ </xsl:template>
1102
+
1103
+ <xsl:template match="html:dl">
1104
+ <fo:block xsl:use-attribute-sets="dl">
1105
+ <xsl:call-template name="process-common-attributes-and-children"/>
1106
+ </fo:block>
1107
+ </xsl:template>
1108
+
1109
+ <xsl:template match="html:dt">
1110
+ <fo:block xsl:use-attribute-sets="dt">
1111
+ <xsl:call-template name="process-common-attributes-and-children"/>
1112
+ </fo:block>
1113
+ </xsl:template>
1114
+
1115
+ <xsl:template match="html:dd">
1116
+ <fo:block xsl:use-attribute-sets="dd">
1117
+ <xsl:call-template name="process-common-attributes-and-children"/>
1118
+ </fo:block>
1119
+ </xsl:template>
1120
+
1121
+ <!--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
1122
+ Table
1123
+ =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-->
1124
+
1125
+ <xsl:template match="html:table">
1126
+ <fo:block xsl:use-attribute-sets="table-and-caption">
1127
+ <xsl:call-template name="make-table-caption"/>
1128
+ <fo:table xsl:use-attribute-sets="table">
1129
+ <xsl:call-template name="process-table"/>
1130
+ </fo:table>
1131
+ </fo:block>
1132
+ </xsl:template>
1133
+
1134
+ <xsl:template name="make-table-caption">
1135
+ <xsl:if test="html:caption/@align">
1136
+ <xsl:attribute name="caption-side">
1137
+ <xsl:value-of select="html:caption/@align"/>
1138
+ </xsl:attribute>
1139
+ </xsl:if>
1140
+ <xsl:apply-templates select="html:caption"/>
1141
+ </xsl:template>
1142
+
1143
+ <xsl:template name="process-table">
1144
+ <xsl:if test="@width">
1145
+ <xsl:attribute name="inline-progression-dimension">
1146
+ <xsl:choose>
1147
+ <xsl:when test="contains(@width, '%')">
1148
+ <xsl:value-of select="@width"/>
1149
+ </xsl:when>
1150
+ <xsl:otherwise>
1151
+ <xsl:value-of select="@width"/>px</xsl:otherwise>
1152
+ </xsl:choose>
1153
+ </xsl:attribute>
1154
+ </xsl:if>
1155
+ <xsl:if test="@border or @frame">
1156
+ <xsl:choose>
1157
+ <xsl:when test="@border &gt; 0">
1158
+ <xsl:attribute name="border">
1159
+ <xsl:value-of select="@border"/>px</xsl:attribute>
1160
+ </xsl:when>
1161
+ </xsl:choose>
1162
+ <xsl:choose>
1163
+ <xsl:when test="@border = '0' or @frame = 'void'">
1164
+ <xsl:attribute name="border-style">hidden</xsl:attribute>
1165
+ </xsl:when>
1166
+ <xsl:when test="@frame = 'above'">
1167
+ <xsl:attribute name="border-style">outset hidden hidden hidden</xsl:attribute>
1168
+ </xsl:when>
1169
+ <xsl:when test="@frame = 'below'">
1170
+ <xsl:attribute name="border-style">hidden hidden outset hidden</xsl:attribute>
1171
+ </xsl:when>
1172
+ <xsl:when test="@frame = 'hsides'">
1173
+ <xsl:attribute name="border-style">outset hidden</xsl:attribute>
1174
+ </xsl:when>
1175
+ <xsl:when test="@frame = 'vsides'">
1176
+ <xsl:attribute name="border-style">hidden outset</xsl:attribute>
1177
+ </xsl:when>
1178
+ <xsl:when test="@frame = 'lhs'">
1179
+ <xsl:attribute name="border-style">hidden hidden hidden outset</xsl:attribute>
1180
+ </xsl:when>
1181
+ <xsl:when test="@frame = 'rhs'">
1182
+ <xsl:attribute name="border-style">hidden outset hidden hidden</xsl:attribute>
1183
+ </xsl:when>
1184
+ <xsl:otherwise>
1185
+ <xsl:attribute name="border-style">outset</xsl:attribute>
1186
+ </xsl:otherwise>
1187
+ </xsl:choose>
1188
+ </xsl:if>
1189
+ <xsl:if test="@cellspacing">
1190
+ <xsl:attribute name="border-spacing">
1191
+ <xsl:value-of select="@cellspacing"/>px</xsl:attribute>
1192
+ <xsl:attribute name="border-collapse">separate</xsl:attribute>
1193
+ </xsl:if>
1194
+ <xsl:if test="@rules and (@rules = 'groups' or
1195
+ @rules = 'rows' or
1196
+ @rules = 'cols' or
1197
+ @rules = 'all' and (not(@border or @frame) or
1198
+ @border = '0' or @frame and
1199
+ not(@frame = 'box' or @frame = 'border')))">
1200
+ <xsl:attribute name="border-collapse">collapse</xsl:attribute>
1201
+ <xsl:if test="not(@border or @frame)">
1202
+ <xsl:attribute name="border-style">hidden</xsl:attribute>
1203
+ </xsl:if>
1204
+ </xsl:if>
1205
+ <xsl:call-template name="process-common-attributes"/>
1206
+ <xsl:apply-templates select="html:col | html:colgroup"/>
1207
+ <xsl:apply-templates select="html:thead"/>
1208
+ <xsl:apply-templates select="html:tfoot"/>
1209
+ <xsl:choose>
1210
+ <xsl:when test="html:tbody">
1211
+ <xsl:apply-templates select="html:tbody"/>
1212
+ </xsl:when>
1213
+ <xsl:otherwise>
1214
+ <fo:table-body xsl:use-attribute-sets="tbody">
1215
+ <xsl:apply-templates select="html:tr"/>
1216
+ </fo:table-body>
1217
+ </xsl:otherwise>
1218
+ </xsl:choose>
1219
+ </xsl:template>
1220
+
1221
+ <xsl:template match="html:caption">
1222
+ <fo:block xsl:use-attribute-sets="table-caption">
1223
+ <xsl:call-template name="process-common-attributes"/>
1224
+ <fo:block>
1225
+ <xsl:apply-templates/>
1226
+ </fo:block>
1227
+ </fo:block>
1228
+ </xsl:template>
1229
+
1230
+ <xsl:template match="html:thead">
1231
+ <fo:table-header xsl:use-attribute-sets="thead">
1232
+ <xsl:call-template name="process-table-rowgroup"/>
1233
+ </fo:table-header>
1234
+ </xsl:template>
1235
+
1236
+ <xsl:template match="html:tfoot">
1237
+ <fo:table-footer xsl:use-attribute-sets="tfoot">
1238
+ <xsl:call-template name="process-table-rowgroup"/>
1239
+ </fo:table-footer>
1240
+ </xsl:template>
1241
+
1242
+ <xsl:template match="html:tbody">
1243
+ <fo:table-body xsl:use-attribute-sets="tbody">
1244
+ <xsl:call-template name="process-table-rowgroup"/>
1245
+ </fo:table-body>
1246
+ </xsl:template>
1247
+
1248
+ <xsl:template name="process-table-rowgroup">
1249
+ <xsl:if test="ancestor::html:table[1]/@rules = 'groups'">
1250
+ <xsl:attribute name="border">1px solid</xsl:attribute>
1251
+ </xsl:if>
1252
+ <xsl:call-template name="process-common-attributes-and-children"/>
1253
+ </xsl:template>
1254
+
1255
+ <xsl:template match="html:colgroup">
1256
+ <fo:table-column xsl:use-attribute-sets="table-column">
1257
+ <xsl:call-template name="process-table-column"/>
1258
+ </fo:table-column>
1259
+ </xsl:template>
1260
+
1261
+ <xsl:template match="html:colgroup[html:col]">
1262
+ <xsl:apply-templates/>
1263
+ </xsl:template>
1264
+
1265
+ <xsl:template match="html:col">
1266
+ <fo:table-column xsl:use-attribute-sets="table-column">
1267
+ <xsl:call-template name="process-table-column"/>
1268
+ </fo:table-column>
1269
+ </xsl:template>
1270
+
1271
+ <xsl:template name="process-table-column">
1272
+ <xsl:if test="parent::html:colgroup">
1273
+ <xsl:call-template name="process-col-width">
1274
+ <xsl:with-param name="width" select="../@width"/>
1275
+ </xsl:call-template>
1276
+ <xsl:call-template name="process-cell-align">
1277
+ <xsl:with-param name="align" select="../@align"/>
1278
+ </xsl:call-template>
1279
+ <xsl:call-template name="process-cell-valign">
1280
+ <xsl:with-param name="valign" select="../@valign"/>
1281
+ </xsl:call-template>
1282
+ </xsl:if>
1283
+ <xsl:if test="@span">
1284
+ <xsl:attribute name="number-columns-repeated">
1285
+ <xsl:value-of select="@span"/>
1286
+ </xsl:attribute>
1287
+ </xsl:if>
1288
+ <xsl:call-template name="process-col-width">
1289
+ <xsl:with-param name="width" select="@width"/>
1290
+ <!-- it may override parent colgroup's width -->
1291
+ </xsl:call-template>
1292
+ <xsl:if test="ancestor::html:table[1]/@rules = 'cols'">
1293
+ <!--
1294
+ <xsl:attribute name="border">1px solid</xsl:attribute>
1295
+ -->
1296
+ </xsl:if>
1297
+ <xsl:call-template name="process-common-attributes"/>
1298
+ <!-- this processes also align and valign -->
1299
+ </xsl:template>
1300
+
1301
+ <xsl:template match="html:tr">
1302
+ <fo:table-row xsl:use-attribute-sets="tr" keep-together.within-page="always">
1303
+ <xsl:call-template name="process-table-row"/>
1304
+ </fo:table-row>
1305
+ </xsl:template>
1306
+
1307
+ <xsl:template match="html:tr[parent::html:table and html:th and not(html:td)]">
1308
+ <fo:table-row xsl:use-attribute-sets="tr" keep-together.within-page="always">
1309
+ <xsl:call-template name="process-table-row"/>
1310
+ </fo:table-row>
1311
+ </xsl:template>
1312
+
1313
+ <xsl:template name="process-table-row">
1314
+ <xsl:if test="ancestor::html:table[1]/@rules = 'rows'">
1315
+ <xsl:attribute name="border">1px solid</xsl:attribute>
1316
+ </xsl:if>
1317
+ <xsl:call-template name="process-common-attributes-and-children"/>
1318
+ </xsl:template>
1319
+
1320
+ <xsl:template match="html:th">
1321
+ <fo:table-cell xsl:use-attribute-sets="th">
1322
+ <xsl:call-template name="process-table-cell"/>
1323
+ </fo:table-cell>
1324
+ </xsl:template>
1325
+
1326
+ <xsl:template match="html:td">
1327
+ <fo:table-cell xsl:use-attribute-sets="td">
1328
+ <xsl:call-template name="process-table-cell"/>
1329
+ </fo:table-cell>
1330
+ </xsl:template>
1331
+
1332
+ <xsl:template name="process-table-cell">
1333
+ <xsl:if test="@colspan">
1334
+ <xsl:attribute name="number-columns-spanned">
1335
+ <xsl:value-of select="@colspan"/>
1336
+ </xsl:attribute>
1337
+ </xsl:if>
1338
+ <xsl:if test="@rowspan">
1339
+ <xsl:attribute name="number-rows-spanned">
1340
+ <xsl:value-of select="@rowspan"/>
1341
+ </xsl:attribute>
1342
+ </xsl:if>
1343
+ <xsl:for-each select="ancestor::html:table[1]">
1344
+ <xsl:if test="(@border or @rules) and (@rules = 'all' or
1345
+ not(@rules) and not(@border = '0'))">
1346
+ <xsl:attribute name="border-style">inset</xsl:attribute>
1347
+ </xsl:if>
1348
+ <xsl:if test="@cellpadding">
1349
+ <xsl:attribute name="padding">
1350
+ <xsl:choose>
1351
+ <xsl:when test="contains(@cellpadding, '%')">
1352
+ <xsl:value-of select="@cellpadding"/>
1353
+ </xsl:when>
1354
+ <xsl:otherwise>
1355
+ <xsl:value-of select="@cellpadding"/>px</xsl:otherwise>
1356
+ </xsl:choose>
1357
+ </xsl:attribute>
1358
+ </xsl:if>
1359
+ </xsl:for-each>
1360
+ <xsl:if test="not(@align or ../@align or
1361
+ ../parent::*[self::html:thead or self::html:tfoot or
1362
+ self::html:tbody]/@align) and
1363
+ ancestor::html:table[1]/*[self::html:col or
1364
+ self::html:colgroup]/descendant-or-self::*/@align">
1365
+ <xsl:attribute name="text-align">from-table-column()</xsl:attribute>
1366
+ </xsl:if>
1367
+ <xsl:if test="not(@valign or ../@valign or
1368
+ ../parent::*[self::html:thead or self::html:tfoot or
1369
+ self::html:tbody]/@valign) and
1370
+ ancestor::html:table[1]/*[self::html:col or
1371
+ self::html:colgroup]/descendant-or-self::*/@valign">
1372
+ <xsl:attribute name="display-align">from-table-column()</xsl:attribute>
1373
+ <xsl:attribute name="relative-align">from-table-column()</xsl:attribute>
1374
+ </xsl:if>
1375
+ <xsl:attribute name="keep-together.within-column">always</xsl:attribute>
1376
+ <xsl:call-template name="process-common-attributes"/>
1377
+ <fo:block>
1378
+ <xsl:apply-templates/>
1379
+ </fo:block>
1380
+ </xsl:template>
1381
+
1382
+ <xsl:template name="process-col-width">
1383
+ <xsl:param name="width"/>
1384
+ <xsl:if test="$width and $width != '0*'">
1385
+ <xsl:attribute name="column-width">
1386
+ <xsl:choose>
1387
+ <xsl:when test="contains($width, '*')">
1388
+ <xsl:text>proportional-column-width(</xsl:text>
1389
+ <xsl:value-of select="substring-before($width, '*')"/>
1390
+ <xsl:text>)</xsl:text>
1391
+ </xsl:when>
1392
+ <xsl:when test="contains($width, '%')">
1393
+ <xsl:value-of select="$width"/>
1394
+ </xsl:when>
1395
+ <xsl:otherwise>
1396
+ <xsl:value-of select="$width"/>px</xsl:otherwise>
1397
+ </xsl:choose>
1398
+ </xsl:attribute>
1399
+ </xsl:if>
1400
+ </xsl:template>
1401
+
1402
+ <xsl:template name="process-cell-align">
1403
+ <xsl:param name="align"/>
1404
+ <xsl:if test="$align">
1405
+ <xsl:attribute name="text-align">
1406
+ <xsl:choose>
1407
+ <xsl:when test="$align = 'char'">
1408
+ <xsl:choose>
1409
+ <xsl:when test="$align/../@char">
1410
+ <xsl:value-of select="$align/../@char"/>
1411
+ </xsl:when>
1412
+ <xsl:otherwise>
1413
+ <xsl:value-of select="'.'"/>
1414
+ <!-- todo: it should depend on xml:lang ... -->
1415
+ </xsl:otherwise>
1416
+ </xsl:choose>
1417
+ </xsl:when>
1418
+ <xsl:otherwise>
1419
+ <xsl:value-of select="$align"/>
1420
+ </xsl:otherwise>
1421
+ </xsl:choose>
1422
+ </xsl:attribute>
1423
+ </xsl:if>
1424
+ </xsl:template>
1425
+
1426
+ <xsl:template name="process-cell-valign">
1427
+ <xsl:param name="valign"/>
1428
+ <xsl:if test="$valign">
1429
+ <xsl:attribute name="display-align">
1430
+ <xsl:choose>
1431
+ <xsl:when test="$valign = 'middle'">center</xsl:when>
1432
+ <xsl:when test="$valign = 'bottom'">after</xsl:when>
1433
+ <xsl:when test="$valign = 'baseline'">auto</xsl:when>
1434
+ <xsl:otherwise>before</xsl:otherwise>
1435
+ </xsl:choose>
1436
+ </xsl:attribute>
1437
+ <xsl:if test="$valign = 'baseline'">
1438
+ <xsl:attribute name="relative-align">baseline</xsl:attribute>
1439
+ </xsl:if>
1440
+ </xsl:if>
1441
+ </xsl:template>
1442
+
1443
+ <!--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
1444
+ Inline-level
1445
+ =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-->
1446
+
1447
+ <xsl:template match="html:b">
1448
+ <fo:inline xsl:use-attribute-sets="b">
1449
+ <xsl:call-template name="process-common-attributes-and-children"/>
1450
+ </fo:inline>
1451
+ </xsl:template>
1452
+
1453
+ <xsl:template match="html:strong">
1454
+ <fo:inline xsl:use-attribute-sets="strong">
1455
+ <xsl:call-template name="process-common-attributes-and-children"/>
1456
+ </fo:inline>
1457
+ </xsl:template>
1458
+
1459
+ <xsl:template match="html:strong//html:em | html:em//html:strong">
1460
+ <fo:inline xsl:use-attribute-sets="strong-em">
1461
+ <xsl:call-template name="process-common-attributes-and-children"/>
1462
+ </fo:inline>
1463
+ </xsl:template>
1464
+
1465
+ <xsl:template match="html:i">
1466
+ <fo:inline xsl:use-attribute-sets="i">
1467
+ <xsl:call-template name="process-common-attributes-and-children"/>
1468
+ </fo:inline>
1469
+ </xsl:template>
1470
+
1471
+ <xsl:template match="html:cite">
1472
+ <fo:inline xsl:use-attribute-sets="cite">
1473
+ <xsl:call-template name="process-common-attributes-and-children"/>
1474
+ </fo:inline>
1475
+ </xsl:template>
1476
+
1477
+ <xsl:template match="html:em">
1478
+ <fo:inline xsl:use-attribute-sets="em">
1479
+ <xsl:call-template name="process-common-attributes-and-children"/>
1480
+ </fo:inline>
1481
+ </xsl:template>
1482
+
1483
+ <xsl:template match="html:var">
1484
+ <fo:inline xsl:use-attribute-sets="var">
1485
+ <xsl:call-template name="process-common-attributes-and-children"/>
1486
+ </fo:inline>
1487
+ </xsl:template>
1488
+
1489
+ <xsl:template match="html:dfn">
1490
+ <fo:inline xsl:use-attribute-sets="dfn">
1491
+ <xsl:call-template name="process-common-attributes-and-children"/>
1492
+ </fo:inline>
1493
+ </xsl:template>
1494
+
1495
+ <xsl:template match="html:tt">
1496
+ <fo:inline xsl:use-attribute-sets="tt">
1497
+ <xsl:call-template name="process-common-attributes-and-children"/>
1498
+ </fo:inline>
1499
+ </xsl:template>
1500
+
1501
+ <xsl:template match="html:code">
1502
+ <fo:inline xsl:use-attribute-sets="code">
1503
+ <xsl:call-template name="process-common-attributes-and-children"/>
1504
+ </fo:inline>
1505
+ </xsl:template>
1506
+
1507
+ <xsl:template match="html:kbd">
1508
+ <fo:inline xsl:use-attribute-sets="kbd">
1509
+ <xsl:call-template name="process-common-attributes-and-children"/>
1510
+ </fo:inline>
1511
+ </xsl:template>
1512
+
1513
+ <xsl:template match="html:samp">
1514
+ <fo:inline xsl:use-attribute-sets="samp">
1515
+ <xsl:call-template name="process-common-attributes-and-children"/>
1516
+ </fo:inline>
1517
+ </xsl:template>
1518
+
1519
+ <xsl:template match="html:big">
1520
+ <fo:inline xsl:use-attribute-sets="big">
1521
+ <xsl:call-template name="process-common-attributes-and-children"/>
1522
+ </fo:inline>
1523
+ </xsl:template>
1524
+
1525
+ <xsl:template match="html:small">
1526
+ <fo:inline xsl:use-attribute-sets="small">
1527
+ <xsl:call-template name="process-common-attributes-and-children"/>
1528
+ </fo:inline>
1529
+ </xsl:template>
1530
+
1531
+ <xsl:template match="html:sub">
1532
+ <fo:inline xsl:use-attribute-sets="sub">
1533
+ <xsl:call-template name="process-common-attributes-and-children"/>
1534
+ </fo:inline>
1535
+ </xsl:template>
1536
+
1537
+ <xsl:template match="html:sup">
1538
+ <fo:inline xsl:use-attribute-sets="sup">
1539
+ <xsl:call-template name="process-common-attributes-and-children"/>
1540
+ </fo:inline>
1541
+ </xsl:template>
1542
+
1543
+ <xsl:template match="html:s">
1544
+ <fo:inline xsl:use-attribute-sets="s">
1545
+ <xsl:call-template name="process-common-attributes-and-children"/>
1546
+ </fo:inline>
1547
+ </xsl:template>
1548
+
1549
+ <xsl:template match="html:strike">
1550
+ <fo:inline xsl:use-attribute-sets="strike">
1551
+ <xsl:call-template name="process-common-attributes-and-children"/>
1552
+ </fo:inline>
1553
+ </xsl:template>
1554
+
1555
+ <xsl:template match="html:del">
1556
+ <fo:inline xsl:use-attribute-sets="del">
1557
+ <xsl:call-template name="process-common-attributes-and-children"/>
1558
+ </fo:inline>
1559
+ </xsl:template>
1560
+
1561
+ <xsl:template match="html:u">
1562
+ <fo:inline xsl:use-attribute-sets="u">
1563
+ <xsl:call-template name="process-common-attributes-and-children"/>
1564
+ </fo:inline>
1565
+ </xsl:template>
1566
+
1567
+ <xsl:template match="html:ins">
1568
+ <fo:inline xsl:use-attribute-sets="ins">
1569
+ <xsl:call-template name="process-common-attributes-and-children"/>
1570
+ </fo:inline>
1571
+ </xsl:template>
1572
+
1573
+ <xsl:template match="html:abbr">
1574
+ <fo:inline xsl:use-attribute-sets="abbr">
1575
+ <xsl:call-template name="process-common-attributes-and-children"/>
1576
+ </fo:inline>
1577
+ </xsl:template>
1578
+
1579
+ <xsl:template match="html:acronym">
1580
+ <fo:inline xsl:use-attribute-sets="acronym">
1581
+ <xsl:call-template name="process-common-attributes-and-children"/>
1582
+ </fo:inline>
1583
+ </xsl:template>
1584
+
1585
+ <xsl:template match="html:span">
1586
+ <fo:inline>
1587
+ <xsl:call-template name="process-common-attributes-and-children"/>
1588
+ </fo:inline>
1589
+ </xsl:template>
1590
+
1591
+ <xsl:template match="html:span[@dir]">
1592
+ <fo:bidi-override direction="{@dir}" unicode-bidi="embed">
1593
+ <xsl:call-template name="process-common-attributes-and-children"/>
1594
+ </fo:bidi-override>
1595
+ </xsl:template>
1596
+
1597
+ <xsl:template match="html:span[@style and contains(@style, 'writing-mode')]">
1598
+ <fo:inline-container alignment-baseline="central"
1599
+ text-indent="0pt"
1600
+ last-line-end-indent="0pt"
1601
+ start-indent="0pt"
1602
+ end-indent="0pt"
1603
+ text-align="center"
1604
+ text-align-last="center">
1605
+ <xsl:call-template name="process-common-attributes"/>
1606
+ <fo:block wrap-option="no-wrap" line-height="1">
1607
+ <xsl:apply-templates/>
1608
+ </fo:block>
1609
+ </fo:inline-container>
1610
+ </xsl:template>
1611
+
1612
+ <xsl:template match="html:bdo">
1613
+ <fo:bidi-override direction="{@dir}" unicode-bidi="bidi-override">
1614
+ <xsl:call-template name="process-common-attributes-and-children"/>
1615
+ </fo:bidi-override>
1616
+ </xsl:template>
1617
+
1618
+ <xsl:template match="html:br">
1619
+ <fo:block>
1620
+ <xsl:call-template name="process-common-attributes"/>
1621
+ </fo:block>
1622
+ </xsl:template>
1623
+
1624
+ <xsl:template match="html:q">
1625
+ <fo:inline xsl:use-attribute-sets="q">
1626
+ <xsl:call-template name="process-common-attributes"/>
1627
+ <xsl:choose>
1628
+ <xsl:when test="lang('ja')">
1629
+ <xsl:text>「</xsl:text>
1630
+ <xsl:apply-templates/>
1631
+ <xsl:text>」</xsl:text>
1632
+ </xsl:when>
1633
+ <xsl:otherwise>
1634
+ <!-- lang('en') -->
1635
+ <xsl:text>“</xsl:text>
1636
+ <xsl:apply-templates/>
1637
+ <xsl:text>”</xsl:text>
1638
+ <!-- todo: other languages ...-->
1639
+ </xsl:otherwise>
1640
+ </xsl:choose>
1641
+ </fo:inline>
1642
+ </xsl:template>
1643
+
1644
+ <xsl:template match="html:q//html:q">
1645
+ <fo:inline xsl:use-attribute-sets="q-nested">
1646
+ <xsl:call-template name="process-common-attributes"/>
1647
+ <xsl:choose>
1648
+ <xsl:when test="lang('ja')">
1649
+ <xsl:text>『</xsl:text>
1650
+ <xsl:apply-templates/>
1651
+ <xsl:text>』</xsl:text>
1652
+ </xsl:when>
1653
+ <xsl:otherwise>
1654
+ <!-- lang('en') -->
1655
+ <xsl:text>‘</xsl:text>
1656
+ <xsl:apply-templates/>
1657
+ <xsl:text>’</xsl:text>
1658
+ </xsl:otherwise>
1659
+ </xsl:choose>
1660
+ </fo:inline>
1661
+ </xsl:template>
1662
+
1663
+ <!--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
1664
+ Image
1665
+ =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-->
1666
+
1667
+ <xsl:template match="html:img">
1668
+ <fo:external-graphic xsl:use-attribute-sets="img">
1669
+ <xsl:call-template name="process-img"/>
1670
+ </fo:external-graphic>
1671
+ </xsl:template>
1672
+
1673
+ <xsl:template match="html:img[ancestor::html:a/@href]">
1674
+ <fo:external-graphic xsl:use-attribute-sets="img-link">
1675
+ <xsl:call-template name="process-img"/>
1676
+ </fo:external-graphic>
1677
+ </xsl:template>
1678
+
1679
+ <xsl:template name="process-img">
1680
+ <xsl:attribute name="src">
1681
+ <xsl:text>url('</xsl:text>
1682
+ <xsl:value-of select="@src"/>
1683
+ <xsl:text>')</xsl:text>
1684
+ </xsl:attribute>
1685
+ <xsl:if test="@alt">
1686
+ <xsl:attribute name="role">
1687
+ <xsl:value-of select="@alt"/>
1688
+ </xsl:attribute>
1689
+ </xsl:if>
1690
+ <xsl:if test="@width">
1691
+ <xsl:choose>
1692
+ <xsl:when test="contains(@width, '%')">
1693
+ <xsl:attribute name="width">
1694
+ <xsl:value-of select="@width"/>
1695
+ </xsl:attribute>
1696
+ <xsl:attribute name="content-width">scale-to-fit</xsl:attribute>
1697
+ </xsl:when>
1698
+ <xsl:otherwise>
1699
+ <xsl:attribute name="content-width">
1700
+ <xsl:value-of select="@width"/>px</xsl:attribute>
1701
+ </xsl:otherwise>
1702
+ </xsl:choose>
1703
+ </xsl:if>
1704
+ <xsl:if test="@height">
1705
+ <xsl:choose>
1706
+ <xsl:when test="contains(@height, '%')">
1707
+ <xsl:attribute name="height">
1708
+ <xsl:value-of select="@height"/>
1709
+ </xsl:attribute>
1710
+ <xsl:attribute name="content-height">scale-to-fit</xsl:attribute>
1711
+ </xsl:when>
1712
+ <xsl:otherwise>
1713
+ <xsl:attribute name="content-height">
1714
+ <xsl:value-of select="@height"/>px</xsl:attribute>
1715
+ </xsl:otherwise>
1716
+ </xsl:choose>
1717
+ </xsl:if>
1718
+ <xsl:if test="@border">
1719
+ <xsl:attribute name="border">
1720
+ <xsl:value-of select="@border"/>px solid</xsl:attribute>
1721
+ </xsl:if>
1722
+ <xsl:call-template name="process-common-attributes"/>
1723
+ </xsl:template>
1724
+
1725
+ <xsl:template match="html:object">
1726
+ <xsl:apply-templates/>
1727
+ </xsl:template>
1728
+
1729
+ <xsl:template match="html:param"/>
1730
+ <xsl:template match="html:map"/>
1731
+ <xsl:template match="html:area"/>
1732
+ <xsl:template match="html:label"/>
1733
+ <xsl:template match="html:input"/>
1734
+ <xsl:template match="html:select"/>
1735
+ <xsl:template match="html:optgroup"/>
1736
+ <xsl:template match="html:option"/>
1737
+ <xsl:template match="html:textarea"/>
1738
+ <xsl:template match="html:legend"/>
1739
+ <xsl:template match="html:button"/>
1740
+
1741
+ <!--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
1742
+ Link
1743
+ =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-->
1744
+
1745
+ <xsl:template match="html:a">
1746
+ <fo:inline>
1747
+ <xsl:call-template name="process-common-attributes-and-children"/>
1748
+ </fo:inline>
1749
+ </xsl:template>
1750
+
1751
+ <xsl:template match="html:a[@href]">
1752
+ <fo:basic-link xsl:use-attribute-sets="a-link">
1753
+ <xsl:call-template name="process-a-link"/>
1754
+ </fo:basic-link>
1755
+ </xsl:template>
1756
+
1757
+ <xsl:template name="process-a-link">
1758
+ <xsl:call-template name="process-common-attributes"/>
1759
+ <xsl:choose>
1760
+ <xsl:when test="starts-with(@href,'#')">
1761
+ <xsl:attribute name="internal-destination">
1762
+ <xsl:value-of select="substring-after(@href,'#')"/>
1763
+ </xsl:attribute>
1764
+ </xsl:when>
1765
+ <xsl:otherwise>
1766
+ <xsl:attribute name="external-destination">
1767
+ <xsl:text>url('</xsl:text>
1768
+ <xsl:value-of select="@href"/>
1769
+ <xsl:text>')</xsl:text>
1770
+ </xsl:attribute>
1771
+ </xsl:otherwise>
1772
+ </xsl:choose>
1773
+ <xsl:if test="@title">
1774
+ <xsl:attribute name="role">
1775
+ <xsl:value-of select="@title"/>
1776
+ </xsl:attribute>
1777
+ </xsl:if>
1778
+ <xsl:apply-templates/>
1779
+ </xsl:template>
1780
+
1781
+ <!--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
1782
+ Ruby
1783
+ =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-->
1784
+
1785
+ <xsl:template match="html:ruby">
1786
+ <fo:inline-container alignment-baseline="central"
1787
+ block-progression-dimension="1em"
1788
+ text-indent="0pt"
1789
+ last-line-end-indent="0pt"
1790
+ start-indent="0pt"
1791
+ end-indent="0pt"
1792
+ text-align="center"
1793
+ text-align-last="center">
1794
+ <xsl:call-template name="process-common-attributes"/>
1795
+ <fo:block font-size="50%"
1796
+ wrap-option="no-wrap"
1797
+ line-height="1"
1798
+ space-before.conditionality="retain"
1799
+ space-before="-1.1em"
1800
+ space-after="0.1em"
1801
+ role="html:rt">
1802
+ <xsl:for-each select="html:rt | html:rtc[1]/html:rt">
1803
+ <xsl:call-template name="process-common-attributes"/>
1804
+ <xsl:apply-templates/>
1805
+ </xsl:for-each>
1806
+ </fo:block>
1807
+ <fo:block wrap-option="no-wrap" line-height="1" role="html:rb">
1808
+ <xsl:for-each select="html:rb | html:rbc[1]/html:rb">
1809
+ <xsl:call-template name="process-common-attributes"/>
1810
+ <xsl:apply-templates/>
1811
+ </xsl:for-each>
1812
+ </fo:block>
1813
+ <xsl:if test="html:rtc[2]/html:rt">
1814
+ <fo:block font-size="50%"
1815
+ wrap-option="no-wrap"
1816
+ line-height="1"
1817
+ space-before="0.1em"
1818
+ space-after.conditionality="retain"
1819
+ space-after="-1.1em"
1820
+ role="html:rt">
1821
+ <xsl:for-each select="html:rt | html:rtc[2]/html:rt">
1822
+ <xsl:call-template name="process-common-attributes"/>
1823
+ <xsl:apply-templates/>
1824
+ </xsl:for-each>
1825
+ </fo:block>
1826
+ </xsl:if>
1827
+ </fo:inline-container>
1828
+ </xsl:template>
1829
+ </xsl:stylesheet>