source: BOOK/stylesheets/lfs-xsl/docbook-xsl-snapshot/fo/block.xsl@ d4c109d

Last change on this file since d4c109d was f8c4e94, checked in by Manuel Canales Esparcia <manuel@…>, 17 years ago

Added LFS XSL Stylesheets.

  • Property mode set to 100644
File size: 19.4 KB
RevLine 
[f8c4e94]1<?xml version='1.0'?>
2<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3 xmlns:fo="http://www.w3.org/1999/XSL/Format"
4 version='1.0'>
5
6<!-- ********************************************************************
7 $Id$
8 ********************************************************************
9
10 This file is part of the XSL DocBook Stylesheet distribution.
11 See ../README or http://docbook.sf.net/release/xsl/current/ for
12 copyright and other information.
13
14 ******************************************************************** -->
15
16<!-- ==================================================================== -->
17<!-- What should we do about styling blockinfo? -->
18
19<xsl:template match="blockinfo|info">
20 <!-- suppress -->
21</xsl:template>
22
23<!-- ==================================================================== -->
24
25<xsl:template name="block.object">
26 <fo:block>
27 <xsl:call-template name="anchor"/>
28 <xsl:apply-templates/>
29 </fo:block>
30</xsl:template>
31
32<!-- ==================================================================== -->
33
34<xsl:template match="para">
35 <fo:block xsl:use-attribute-sets="normal.para.spacing">
36 <xsl:call-template name="anchor"/>
37 <xsl:apply-templates/>
38 </fo:block>
39</xsl:template>
40
41<xsl:template match="simpara">
42 <fo:block xsl:use-attribute-sets="normal.para.spacing">
43 <xsl:call-template name="anchor"/>
44 <xsl:apply-templates/>
45 </fo:block>
46</xsl:template>
47
48<xsl:template match="formalpara">
49 <fo:block xsl:use-attribute-sets="normal.para.spacing">
50 <xsl:call-template name="anchor"/>
51 <xsl:apply-templates/>
52 </fo:block>
53</xsl:template>
54
55<!-- Only use title from info -->
56<xsl:template match="formalpara/info">
57 <xsl:apply-templates select="title"/>
58</xsl:template>
59
60<xsl:template match="formalpara/title|formalpara/info/title">
61 <xsl:variable name="titleStr">
62 <xsl:apply-templates/>
63 </xsl:variable>
64 <xsl:variable name="lastChar">
65 <xsl:if test="$titleStr != ''">
66 <xsl:value-of select="substring($titleStr,string-length($titleStr),1)"/>
67 </xsl:if>
68 </xsl:variable>
69
70 <fo:inline font-weight="bold"
71 keep-with-next.within-line="always"
72 padding-end="1em">
73 <xsl:copy-of select="$titleStr"/>
74 <xsl:if test="$lastChar != ''
75 and not(contains($runinhead.title.end.punct, $lastChar))">
76 <xsl:value-of select="$runinhead.default.title.end.punct"/>
77 </xsl:if>
78 <xsl:text>&#160;</xsl:text>
79 </fo:inline>
80</xsl:template>
81
82<xsl:template match="formalpara/para">
83 <xsl:apply-templates/>
84</xsl:template>
85
86<!-- ==================================================================== -->
87
88<xsl:template match="blockquote">
89 <fo:block xsl:use-attribute-sets="blockquote.properties">
90 <xsl:call-template name="anchor"/>
91 <fo:block>
92 <xsl:if test="title|info/title">
93 <fo:block xsl:use-attribute-sets="formal.title.properties">
94 <xsl:apply-templates select="." mode="object.title.markup"/>
95 </fo:block>
96 </xsl:if>
97 <xsl:apply-templates select="*[local-name(.) != 'title'
98 and local-name(.) != 'attribution']"/>
99 </fo:block>
100 <xsl:if test="attribution">
101 <fo:block text-align="right">
102 <!-- mdash -->
103 <xsl:text>&#x2014;</xsl:text>
104 <xsl:apply-templates select="attribution"/>
105 </fo:block>
106 </xsl:if>
107 </fo:block>
108</xsl:template>
109
110<xsl:template match="epigraph">
111 <fo:block>
112 <xsl:call-template name="anchor"/>
113 <xsl:apply-templates select="para|simpara|formalpara|literallayout"/>
114 <xsl:if test="attribution">
115 <fo:inline>
116 <xsl:text>--</xsl:text>
117 <xsl:apply-templates select="attribution"/>
118 </fo:inline>
119 </xsl:if>
120 </fo:block>
121</xsl:template>
122
123<xsl:template match="attribution">
124 <fo:inline><xsl:apply-templates/></fo:inline>
125</xsl:template>
126
127<!-- ==================================================================== -->
128
129<xsl:template name="floater">
130 <xsl:param name="position" select="'none'"/>
131 <xsl:param name="clear" select="'both'"/>
132 <xsl:param name="width"/>
133 <xsl:param name="content"/>
134 <xsl:param name="start.indent">0pt</xsl:param>
135 <xsl:param name="end.indent">0pt</xsl:param>
136
137 <xsl:choose>
138 <xsl:when test="not($fop.extensions = 0)">
139 <!-- fop 0.20.5 does not support floats -->
140 <xsl:copy-of select="$content"/>
141 </xsl:when>
142 <xsl:when test="$position = 'none'">
143 <xsl:copy-of select="$content"/>
144 </xsl:when>
145 <xsl:when test="$position = 'before'">
146 <fo:float float="before">
147 <xsl:copy-of select="$content"/>
148 </fo:float>
149 </xsl:when>
150 <xsl:when test="$position = 'left' or
151 $position = 'start' or
152 $position = 'right' or
153 $position = 'end' or
154 $position = 'inside' or
155 $position = 'outside'">
156 <xsl:variable name="float">
157 <fo:float float="{$position}"
158 clear="{$clear}">
159 <fo:block-container
160 start-indent="{$start.indent}"
161 end-indent="{$end.indent}">
162 <xsl:if test="$width != ''">
163 <xsl:attribute name="inline-progression-dimension">
164 <xsl:value-of select="$width"/>
165 </xsl:attribute>
166 </xsl:if>
167 <fo:block>
168 <xsl:copy-of select="$content"/>
169 </fo:block>
170 </fo:block-container>
171 </fo:float>
172 </xsl:variable>
173 <xsl:choose>
174 <xsl:when test="$axf.extensions != 0 and self::sidebar">
175 <fo:block xsl:use-attribute-sets="normal.para.spacing"
176 space-after="0pt"
177 space-after.precedence="force"
178 start-indent="0pt" end-indent="0pt">
179 <xsl:copy-of select="$float"/>
180 </fo:block>
181 </xsl:when>
182 <xsl:when test="$axf.extensions != 0 and
183 ($position = 'left' or $position = 'start')">
184 <fo:float float="{$position}"
185 clear="{$clear}">
186 <fo:block-container
187 inline-progression-dimension=".001mm"
188 end-indent="{$start.indent} + {$width} + {$end.indent}">
189 <xsl:attribute name="start-indent">
190 <xsl:choose>
191 <xsl:when test="ancestor::para">
192 <!-- Special case for handling inline floats
193 in Antenna House-->
194 <xsl:value-of select="concat('-', $body.start.indent)"/>
195 </xsl:when>
196 <xsl:otherwise>0pt</xsl:otherwise>
197 </xsl:choose>
198 </xsl:attribute>
199 <fo:block start-indent="{$start.indent}"
200 end-indent="-{$start.indent} - {$width}">
201 <xsl:copy-of select="$content"/>
202 </fo:block>
203 </fo:block-container>
204 </fo:float>
205
206 </xsl:when>
207 <xsl:when test="$axf.extensions != 0 and
208 ($position = 'right' or $position = 'end')">
209 <!-- Special case for handling inline floats in Antenna House-->
210 <fo:float float="{$position}"
211 clear="{$clear}">
212 <fo:block-container
213 inline-progression-dimension=".001mm"
214 end-indent="-{$body.end.indent}"
215 start-indent="{$start.indent} + {$width} + {$end.indent}">
216 <fo:block end-indent="{$end.indent}"
217 start-indent="-{$end.indent} - {$width}">
218 <xsl:copy-of select="$content"/>
219 </fo:block>
220 </fo:block-container>
221 </fo:float>
222
223 </xsl:when>
224 <xsl:when test="$xep.extensions != 0 and self::sidebar">
225 <!-- float needs some space above to line up with following para -->
226 <fo:block xsl:use-attribute-sets="normal.para.spacing">
227 <xsl:copy-of select="$float"/>
228 </fo:block>
229 </xsl:when>
230 <xsl:when test="$xep.extensions != 0">
231 <xsl:copy-of select="$float"/>
232 </xsl:when>
233 <xsl:otherwise>
234 <xsl:copy-of select="$float"/>
235 </xsl:otherwise>
236 </xsl:choose>
237 </xsl:when>
238 <xsl:otherwise>
239 <xsl:copy-of select="$content"/>
240 </xsl:otherwise>
241 </xsl:choose>
242</xsl:template>
243
244<xsl:template match="sidebar" name="sidebar">
245 <!-- Also does margin notes -->
246 <xsl:variable name="pi-type">
247 <xsl:call-template name="pi.dbfo_float-type"/>
248 </xsl:variable>
249
250 <xsl:variable name="id">
251 <xsl:call-template name="object.id"/>
252 </xsl:variable>
253
254 <xsl:choose>
255 <xsl:when test="$pi-type = 'margin.note'">
256 <xsl:call-template name="margin.note"/>
257 </xsl:when>
258 <xsl:otherwise>
259 <xsl:variable name="content">
260 <fo:block xsl:use-attribute-sets="sidebar.properties"
261 id="{$id}">
262 <xsl:call-template name="sidebar.titlepage"/>
263 <xsl:apply-templates select="node()[not(self::title) and
264 not(self::info) and
265 not(self::sidebarinfo)]"/>
266 </fo:block>
267 </xsl:variable>
268
269 <xsl:variable name="pi-width">
270 <xsl:call-template name="pi.dbfo_sidebar-width"/>
271 </xsl:variable>
272
273 <xsl:variable name="position">
274 <xsl:choose>
275 <xsl:when test="$pi-type != ''">
276 <xsl:value-of select="$pi-type"/>
277 </xsl:when>
278 <xsl:otherwise>
279 <xsl:value-of select="$sidebar.float.type"/>
280 </xsl:otherwise>
281 </xsl:choose>
282 </xsl:variable>
283
284 <xsl:call-template name="floater">
285 <xsl:with-param name="content" select="$content"/>
286 <xsl:with-param name="position" select="$position"/>
287 <xsl:with-param name="width">
288 <xsl:choose>
289 <xsl:when test="$pi-width != ''">
290 <xsl:value-of select="$pi-width"/>
291 </xsl:when>
292 <xsl:otherwise>
293 <xsl:value-of select="$sidebar.float.width"/>
294 </xsl:otherwise>
295 </xsl:choose>
296 </xsl:with-param>
297 <xsl:with-param name="start.indent">
298 <xsl:choose>
299 <xsl:when test="$position = 'start' or
300 $position = 'left'">0pt</xsl:when>
301 <xsl:when test="$position = 'end' or
302 $position = 'right'">0.5em</xsl:when>
303 <xsl:otherwise>0pt</xsl:otherwise>
304 </xsl:choose>
305 </xsl:with-param>
306 <xsl:with-param name="end.indent">
307 <xsl:choose>
308 <xsl:when test="$position = 'start' or
309 $position = 'left'">0.5em</xsl:when>
310 <xsl:when test="$position = 'end' or
311 $position = 'right'">0pt</xsl:when>
312 <xsl:otherwise>0pt</xsl:otherwise>
313 </xsl:choose>
314 </xsl:with-param>
315 </xsl:call-template>
316 </xsl:otherwise>
317 </xsl:choose>
318
319</xsl:template>
320
321<xsl:template match="sidebar/title|sidebarinfo|sidebar/info"/>
322
323<xsl:template match="sidebar/title|sidebarinfo/title|sidebar/info/title"
324 mode="titlepage.mode" priority="1">
325 <fo:block xsl:use-attribute-sets="sidebar.title.properties">
326 <xsl:apply-templates/>
327 </fo:block>
328</xsl:template>
329
330<xsl:template name="margin.note">
331 <xsl:param name="content">
332 <fo:block xsl:use-attribute-sets="margin.note.properties">
333 <xsl:if test="./title">
334 <fo:block xsl:use-attribute-sets="margin.note.title.properties">
335 <xsl:apply-templates select="./title" mode="margin.note.title.mode"/>
336 </fo:block>
337 </xsl:if>
338 <xsl:apply-templates/>
339 </fo:block>
340 </xsl:param>
341
342 <xsl:variable name="pi-width">
343 <xsl:call-template name="pi.dbfo_sidebar-width"/>
344 </xsl:variable>
345
346 <xsl:variable name="position" select="$margin.note.float.type"/>
347
348 <xsl:call-template name="floater">
349 <xsl:with-param name="content" select="$content"/>
350 <xsl:with-param name="position" select="$position"/>
351 <xsl:with-param name="width" >
352 <xsl:choose>
353 <xsl:when test="$pi-width != ''">
354 <xsl:value-of select="$pi-width"/>
355 </xsl:when>
356 <xsl:otherwise>
357 <xsl:value-of select="$margin.note.width"/>
358 </xsl:otherwise>
359 </xsl:choose>
360 </xsl:with-param>
361 <xsl:with-param name="start.indent">
362 <xsl:choose>
363 <xsl:when test="$position = 'start' or
364 $position = 'left'">0pt</xsl:when>
365 <xsl:when test="$position = 'end' or
366 $position = 'right'">0.5em</xsl:when>
367 <xsl:otherwise>0pt</xsl:otherwise>
368 </xsl:choose>
369 </xsl:with-param>
370 <xsl:with-param name="end.indent">
371 <xsl:choose>
372 <xsl:when test="$position = 'start' or
373 $position = 'left'">0.5em</xsl:when>
374 <xsl:when test="$position = 'end' or
375 $position = 'right'">0pt</xsl:when>
376 <xsl:otherwise>0pt</xsl:otherwise>
377 </xsl:choose>
378 </xsl:with-param>
379 </xsl:call-template>
380</xsl:template>
381
382<xsl:template match="sidebar/title" mode="margin.note.title.mode">
383 <xsl:apply-templates/>
384</xsl:template>
385
386<!-- ==================================================================== -->
387
388<xsl:template match="abstract">
389 <fo:block xsl:use-attribute-sets="abstract.properties">
390 <xsl:call-template name="anchor"/>
391 <xsl:apply-templates/>
392 </fo:block>
393</xsl:template>
394
395<xsl:template match="abstract/title|abstract/info/title">
396 <fo:block xsl:use-attribute-sets="abstract.title.properties">
397 <xsl:apply-templates/>
398 </fo:block>
399</xsl:template>
400
401<!-- ==================================================================== -->
402
403<xsl:template match="msgset">
404 <xsl:apply-templates/>
405</xsl:template>
406
407<xsl:template match="msgentry">
408 <xsl:call-template name="block.object"/>
409</xsl:template>
410
411<xsl:template match="simplemsgentry">
412 <xsl:call-template name="block.object"/>
413</xsl:template>
414
415<xsl:template match="msg">
416 <xsl:call-template name="block.object"/>
417</xsl:template>
418
419<xsl:template match="msgmain">
420 <xsl:apply-templates/>
421</xsl:template>
422
423<xsl:template match="msgsub">
424 <xsl:apply-templates/>
425</xsl:template>
426
427<xsl:template match="msgrel">
428 <xsl:apply-templates/>
429</xsl:template>
430
431<xsl:template match="msgtext">
432 <xsl:apply-templates/>
433</xsl:template>
434
435<xsl:template match="msginfo">
436 <xsl:call-template name="block.object"/>
437</xsl:template>
438
439<xsl:template match="msglevel">
440 <fo:block>
441 <fo:inline font-weight="bold"
442 keep-with-next.within-line="always">
443 <xsl:call-template name="gentext.template">
444 <xsl:with-param name="context" select="'msgset'"/>
445 <xsl:with-param name="name" select="'MsgLevel'"/>
446 </xsl:call-template>
447 </fo:inline>
448 <xsl:apply-templates/>
449 </fo:block>
450</xsl:template>
451
452<xsl:template match="msgorig">
453 <fo:block>
454 <fo:inline font-weight="bold"
455 keep-with-next.within-line="always">
456 <xsl:call-template name="gentext.template">
457 <xsl:with-param name="context" select="'msgset'"/>
458 <xsl:with-param name="name" select="'MsgOrig'"/>
459 </xsl:call-template>
460 </fo:inline>
461 <xsl:apply-templates/>
462 </fo:block>
463</xsl:template>
464
465<xsl:template match="msgaud">
466 <fo:block>
467 <fo:inline font-weight="bold"
468 keep-with-next.within-line="always">
469 <xsl:call-template name="gentext.template">
470 <xsl:with-param name="context" select="'msgset'"/>
471 <xsl:with-param name="name" select="'MsgAud'"/>
472 </xsl:call-template>
473 </fo:inline>
474 <xsl:apply-templates/>
475 </fo:block>
476</xsl:template>
477
478<xsl:template match="msgexplan">
479 <xsl:call-template name="block.object"/>
480</xsl:template>
481
482<xsl:template match="msgexplan/title">
483 <fo:block font-weight="bold"
484 keep-with-next.within-column="always"
485 hyphenate="false">
486 <xsl:apply-templates/>
487 </fo:block>
488</xsl:template>
489
490<!-- ==================================================================== -->
491<!-- For better or worse, revhistory is allowed in content... -->
492
493<xsl:template match="revhistory">
494 <fo:table table-layout="fixed" xsl:use-attribute-sets="revhistory.table.properties">
495 <xsl:call-template name="anchor"/>
496 <fo:table-column column-number="1" column-width="proportional-column-width(1)"/>
497 <fo:table-column column-number="2" column-width="proportional-column-width(1)"/>
498 <fo:table-column column-number="3" column-width="proportional-column-width(1)"/>
499 <fo:table-body start-indent="0pt" end-indent="0pt">
500 <fo:table-row>
501 <fo:table-cell number-columns-spanned="3" xsl:use-attribute-sets="revhistory.table.cell.properties">
502 <fo:block xsl:use-attribute-sets="revhistory.title.properties">
503 <xsl:call-template name="gentext">
504 <xsl:with-param name="key" select="'RevHistory'"/>
505 </xsl:call-template>
506 </fo:block>
507 </fo:table-cell>
508 </fo:table-row>
509 <xsl:apply-templates/>
510 </fo:table-body>
511 </fo:table>
512</xsl:template>
513
514<xsl:template match="revhistory/revision">
515 <xsl:variable name="revnumber" select="revnumber"/>
516 <xsl:variable name="revdate" select="date"/>
517 <xsl:variable name="revauthor" select="authorinitials|author"/>
518 <xsl:variable name="revremark" select="revremark|revdescription"/>
519 <fo:table-row>
520 <fo:table-cell xsl:use-attribute-sets="revhistory.table.cell.properties">
521 <fo:block>
522 <xsl:call-template name="anchor"/>
523 <xsl:if test="$revnumber">
524 <xsl:call-template name="gentext">
525 <xsl:with-param name="key" select="'Revision'"/>
526 </xsl:call-template>
527 <xsl:call-template name="gentext.space"/>
528 <xsl:apply-templates select="$revnumber[1]"/>
529 </xsl:if>
530 </fo:block>
531 </fo:table-cell>
532 <fo:table-cell xsl:use-attribute-sets="revhistory.table.cell.properties">
533 <fo:block>
534 <xsl:apply-templates select="$revdate[1]"/>
535 </fo:block>
536 </fo:table-cell>
537 <fo:table-cell xsl:use-attribute-sets="revhistory.table.cell.properties">
538 <fo:block>
539 <xsl:for-each select="$revauthor">
540 <xsl:apply-templates select="."/>
541 <xsl:if test="position() != last()">
542 <xsl:text>, </xsl:text>
543 </xsl:if>
544 </xsl:for-each>
545 </fo:block>
546 </fo:table-cell>
547 </fo:table-row>
548 <xsl:if test="$revremark">
549 <fo:table-row>
550 <fo:table-cell number-columns-spanned="3" xsl:use-attribute-sets="revhistory.table.cell.properties">
551 <fo:block>
552 <xsl:apply-templates select="$revremark[1]"/>
553 </fo:block>
554 </fo:table-cell>
555 </fo:table-row>
556 </xsl:if>
557</xsl:template>
558
559<xsl:template match="revision/revnumber">
560 <xsl:apply-templates/>
561</xsl:template>
562
563<xsl:template match="revision/date">
564 <xsl:apply-templates/>
565</xsl:template>
566
567<xsl:template match="revision/authorinitials">
568 <xsl:apply-templates/>
569</xsl:template>
570
571<xsl:template match="revision/author">
572 <xsl:apply-templates/>
573</xsl:template>
574
575<xsl:template match="revision/revremark">
576 <xsl:apply-templates/>
577</xsl:template>
578
579<xsl:template match="revision/revdescription">
580 <xsl:apply-templates/>
581</xsl:template>
582
583<!-- ==================================================================== -->
584
585<xsl:template match="ackno">
586 <fo:block xsl:use-attribute-sets="normal.para.spacing">
587 <xsl:call-template name="anchor"/>
588 <xsl:apply-templates/>
589 </fo:block>
590</xsl:template>
591
592<!-- ==================================================================== -->
593
594<xsl:template match="highlights">
595 <xsl:call-template name="block.object"/>
596</xsl:template>
597
598<!-- ==================================================================== -->
599
600</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.