/[volute]/trunk/projects/grid/uws/doc/ivoadoc/xhtml2fo.xsl
ViewVC logotype

Contents of /trunk/projects/grid/uws/doc/ivoadoc/xhtml2fo.xsl

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

Name Value
svn:mergeinfo
svn:mime-type text/plain

msdemlei@ari.uni-heidelberg.de
ViewVC Help
Powered by ViewVC 1.1.26