2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3 xmlns:fo="http://www.w3.org/1999/XSL/Format"
6 <!-- ********************************************************************
7 $Id: block.xsl 9389 2012-06-02 19:02:39Z bobstayton $
8 ********************************************************************
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.
14 ******************************************************************** -->
16 <!-- ==================================================================== -->
18 <xsl:template match="blockinfo|info">
22 <!-- ==================================================================== -->
24 <xsl:template name="block.object">
25 <xsl:variable name="keep.together">
26 <xsl:call-template name="pi.dbfo_keep-together"/>
29 <xsl:if test="$keep.together != ''">
30 <xsl:attribute name="keep-together.within-column"><xsl:value-of
31 select="$keep.together"/></xsl:attribute>
33 <xsl:call-template name="anchor"/>
34 <xsl:apply-templates/>
38 <!-- ==================================================================== -->
40 <xsl:template match="para">
41 <xsl:variable name="keep.together">
42 <xsl:call-template name="pi.dbfo_keep-together"/>
44 <fo:block xsl:use-attribute-sets="para.properties">
45 <xsl:if test="$keep.together != ''">
46 <xsl:attribute name="keep-together.within-column"><xsl:value-of
47 select="$keep.together"/></xsl:attribute>
49 <xsl:call-template name="anchor"/>
50 <xsl:apply-templates/>
54 <xsl:template match="simpara">
55 <xsl:variable name="keep.together">
56 <xsl:call-template name="pi.dbfo_keep-together"/>
58 <fo:block xsl:use-attribute-sets="normal.para.spacing">
59 <xsl:if test="$keep.together != ''">
60 <xsl:attribute name="keep-together.within-column"><xsl:value-of
61 select="$keep.together"/></xsl:attribute>
63 <xsl:call-template name="anchor"/>
64 <xsl:apply-templates/>
68 <xsl:template match="formalpara">
69 <xsl:variable name="keep.together">
70 <xsl:call-template name="pi.dbfo_keep-together"/>
72 <fo:block xsl:use-attribute-sets="normal.para.spacing">
73 <xsl:if test="$keep.together != ''">
74 <xsl:attribute name="keep-together.within-column"><xsl:value-of
75 select="$keep.together"/></xsl:attribute>
77 <xsl:call-template name="anchor"/>
78 <xsl:apply-templates/>
82 <!-- Only use title from info -->
83 <xsl:template match="formalpara/info">
84 <xsl:apply-templates select="title"/>
87 <xsl:template match="formalpara/title|formalpara/info/title">
88 <xsl:variable name="titleStr">
89 <xsl:apply-templates/>
91 <xsl:variable name="lastChar">
92 <xsl:if test="$titleStr != ''">
93 <xsl:value-of select="substring($titleStr,string-length($titleStr),1)"/>
97 <fo:inline font-weight="bold"
98 keep-with-next.within-line="always"
100 <xsl:copy-of select="$titleStr"/>
101 <xsl:if test="$lastChar != ''
102 and not(contains($runinhead.title.end.punct, $lastChar))">
103 <xsl:value-of select="$runinhead.default.title.end.punct"/>
105 <xsl:text> </xsl:text>
109 <xsl:template match="formalpara/para">
110 <xsl:apply-templates/>
113 <!-- ==================================================================== -->
115 <xsl:template match="blockquote">
116 <xsl:variable name="keep.together">
117 <xsl:call-template name="pi.dbfo_keep-together"/>
119 <fo:block xsl:use-attribute-sets="blockquote.properties">
120 <xsl:if test="$keep.together != ''">
121 <xsl:attribute name="keep-together.within-column"><xsl:value-of
122 select="$keep.together"/></xsl:attribute>
124 <xsl:call-template name="anchor"/>
126 <xsl:if test="title|info/title">
127 <fo:block xsl:use-attribute-sets="formal.title.properties">
128 <xsl:apply-templates select="." mode="object.title.markup"/>
131 <xsl:apply-templates select="*[local-name(.) != 'title'
132 and local-name(.) != 'attribution']"/>
134 <xsl:if test="attribution">
135 <fo:block text-align="right">
137 <xsl:text>—</xsl:text>
138 <xsl:apply-templates select="attribution"/>
144 <!-- Use an em dash per Chicago Manual of Style and https://sourceforge.net/tracker/index.php?func=detail&aid=2793878&group_id=21935&atid=373747 -->
145 <xsl:template match="epigraph">
147 <xsl:call-template name="anchor"/>
148 <xsl:apply-templates select="para|simpara|formalpara|literallayout"/>
149 <xsl:if test="attribution">
151 <xsl:text>—</xsl:text>
152 <xsl:apply-templates select="attribution"/>
158 <xsl:template match="attribution">
159 <fo:inline><xsl:apply-templates/></fo:inline>
162 <!-- ==================================================================== -->
164 <xsl:template name="floater">
165 <xsl:param name="position" select="'none'"/>
166 <xsl:param name="clear" select="'both'"/>
167 <xsl:param name="width"/>
168 <xsl:param name="content"/>
169 <xsl:param name="start.indent">0pt</xsl:param>
170 <xsl:param name="end.indent">0pt</xsl:param>
173 <xsl:when test="not($fop.extensions = 0)">
174 <!-- fop 0.20.5 does not support floats -->
175 <xsl:copy-of select="$content"/>
177 <xsl:when test="$position = 'none'">
178 <xsl:copy-of select="$content"/>
180 <xsl:when test="$position = 'before'">
181 <fo:float float="before">
182 <xsl:copy-of select="$content"/>
185 <xsl:when test="$position = 'left' or
186 $position = 'start' or
187 $position = 'right' or
189 $position = 'inside' or
190 $position = 'outside'">
191 <xsl:variable name="float">
192 <fo:float float="{$position}"
195 start-indent="{$start.indent}"
196 end-indent="{$end.indent}">
197 <xsl:if test="$width != ''">
198 <xsl:attribute name="inline-progression-dimension">
199 <xsl:value-of select="$width"/>
203 <xsl:copy-of select="$content"/>
205 </fo:block-container>
209 <xsl:when test="$axf.extensions != 0 and self::sidebar">
210 <fo:block xsl:use-attribute-sets="normal.para.spacing"
212 space-after.precedence="force"
213 start-indent="0pt" end-indent="0pt">
214 <xsl:copy-of select="$float"/>
217 <xsl:when test="$axf.extensions != 0 and
218 ($position = 'left' or $position = 'start')">
219 <fo:float float="{$position}"
222 inline-progression-dimension=".001mm"
223 end-indent="{$start.indent} + {$width} + {$end.indent}">
224 <xsl:attribute name="start-indent">
226 <xsl:when test="ancestor::para">
227 <!-- Special case for handling inline floats
229 <xsl:value-of select="concat('-', $body.start.indent)"/>
231 <xsl:otherwise>0pt</xsl:otherwise>
234 <fo:block start-indent="{$start.indent}"
235 end-indent="-{$start.indent} - {$width}">
236 <xsl:copy-of select="$content"/>
238 </fo:block-container>
242 <xsl:when test="$axf.extensions != 0 and
243 ($position = 'right' or $position = 'end')">
244 <!-- Special case for handling inline floats in Antenna House-->
245 <fo:float float="{$position}"
248 inline-progression-dimension=".001mm"
249 end-indent="-{$body.end.indent}"
250 start-indent="{$start.indent} + {$width} + {$end.indent}">
251 <fo:block end-indent="{$end.indent}"
252 start-indent="-{$end.indent} - {$width}">
253 <xsl:copy-of select="$content"/>
255 </fo:block-container>
259 <xsl:when test="$xep.extensions != 0 and self::sidebar">
260 <!-- float needs some space above to line up with following para -->
261 <fo:block xsl:use-attribute-sets="normal.para.spacing">
262 <xsl:copy-of select="$float"/>
265 <xsl:when test="$xep.extensions != 0">
266 <xsl:copy-of select="$float"/>
269 <xsl:copy-of select="$float"/>
274 <xsl:copy-of select="$content"/>
279 <xsl:template match="sidebar" name="sidebar">
280 <!-- Also does margin notes -->
281 <xsl:variable name="pi-type">
282 <xsl:call-template name="pi.dbfo_float-type"/>
285 <xsl:variable name="id">
286 <xsl:call-template name="object.id"/>
290 <xsl:when test="$pi-type = 'margin.note'">
291 <xsl:call-template name="margin.note"/>
294 <xsl:variable name="content">
295 <fo:block xsl:use-attribute-sets="sidebar.properties"
297 <xsl:call-template name="sidebar.titlepage"/>
298 <xsl:apply-templates select="node()[not(self::title) and
300 not(self::sidebarinfo)]"/>
304 <xsl:variable name="pi-width">
305 <xsl:call-template name="pi.dbfo_sidebar-width"/>
308 <xsl:variable name="position">
310 <xsl:when test="$pi-type != ''">
311 <xsl:value-of select="$pi-type"/>
314 <xsl:value-of select="$sidebar.float.type"/>
319 <xsl:call-template name="floater">
320 <xsl:with-param name="content" select="$content"/>
321 <xsl:with-param name="position" select="$position"/>
322 <xsl:with-param name="width">
324 <xsl:when test="$pi-width != ''">
325 <xsl:value-of select="$pi-width"/>
328 <xsl:value-of select="$sidebar.float.width"/>
332 <xsl:with-param name="start.indent">
334 <xsl:when test="$position = 'start' or
335 $position = 'left'">0pt</xsl:when>
336 <xsl:when test="$position = 'end' or
337 $position = 'right'">0.5em</xsl:when>
338 <xsl:otherwise>0pt</xsl:otherwise>
341 <xsl:with-param name="end.indent">
343 <xsl:when test="$position = 'start' or
344 $position = 'left'">0.5em</xsl:when>
345 <xsl:when test="$position = 'end' or
346 $position = 'right'">0pt</xsl:when>
347 <xsl:otherwise>0pt</xsl:otherwise>
356 <xsl:template match="sidebar/title|sidebarinfo|sidebar/info"/>
358 <xsl:template match="sidebar/title|sidebarinfo/title|sidebar/info/title"
359 mode="titlepage.mode" priority="1">
360 <fo:block xsl:use-attribute-sets="sidebar.title.properties">
361 <xsl:apply-templates/>
365 <!-- Turn off para space-before if sidebar starts with a para, not title -->
366 <xsl:template match="sidebar/*[1][self::para]">
367 <xsl:variable name="keep.together">
368 <xsl:call-template name="pi.dbfo_keep-together"/>
370 <fo:block xsl:use-attribute-sets="para.properties">
371 <xsl:attribute name="space-before.maximum">0pt</xsl:attribute>
372 <xsl:attribute name="space-before.minimum">0pt</xsl:attribute>
373 <xsl:attribute name="space-before.optimum">0pt</xsl:attribute>
374 <xsl:if test="$keep.together != ''">
375 <xsl:attribute name="keep-together.within-column"><xsl:value-of
376 select="$keep.together"/></xsl:attribute>
378 <xsl:call-template name="anchor"/>
379 <xsl:apply-templates/>
384 <xsl:template name="margin.note">
385 <xsl:param name="content">
386 <fo:block xsl:use-attribute-sets="margin.note.properties">
387 <xsl:if test="./title">
388 <fo:block xsl:use-attribute-sets="margin.note.title.properties">
389 <xsl:apply-templates select="./title" mode="margin.note.title.mode"/>
392 <xsl:apply-templates/>
396 <xsl:variable name="pi-width">
397 <xsl:call-template name="pi.dbfo_sidebar-width"/>
400 <xsl:variable name="position" select="$margin.note.float.type"/>
402 <xsl:call-template name="floater">
403 <xsl:with-param name="content" select="$content"/>
404 <xsl:with-param name="position" select="$position"/>
405 <xsl:with-param name="width" >
407 <xsl:when test="$pi-width != ''">
408 <xsl:value-of select="$pi-width"/>
411 <xsl:value-of select="$margin.note.width"/>
415 <xsl:with-param name="start.indent">
417 <xsl:when test="$position = 'start' or
418 $position = 'left'">0pt</xsl:when>
419 <xsl:when test="$position = 'end' or
420 $position = 'right'">0.5em</xsl:when>
421 <xsl:otherwise>0pt</xsl:otherwise>
424 <xsl:with-param name="end.indent">
426 <xsl:when test="$position = 'start' or
427 $position = 'left'">0.5em</xsl:when>
428 <xsl:when test="$position = 'end' or
429 $position = 'right'">0pt</xsl:when>
430 <xsl:otherwise>0pt</xsl:otherwise>
436 <xsl:template match="sidebar/title" mode="margin.note.title.mode">
437 <xsl:apply-templates/>
440 <!-- ==================================================================== -->
442 <xsl:template match="abstract">
443 <xsl:variable name="keep.together">
444 <xsl:call-template name="pi.dbfo_keep-together"/>
446 <fo:block xsl:use-attribute-sets="abstract.properties">
447 <xsl:if test="$keep.together != ''">
448 <xsl:attribute name="keep-together.within-column"><xsl:value-of
449 select="$keep.together"/></xsl:attribute>
451 <xsl:call-template name="anchor"/>
452 <xsl:apply-templates/>
456 <xsl:template match="abstract/title|abstract/info/title">
457 <fo:block xsl:use-attribute-sets="abstract.title.properties">
458 <xsl:apply-templates/>
462 <!-- ==================================================================== -->
464 <xsl:template match="msgset">
465 <xsl:apply-templates/>
468 <xsl:template match="msgentry">
469 <xsl:call-template name="block.object"/>
472 <xsl:template match="simplemsgentry">
473 <xsl:call-template name="block.object"/>
476 <xsl:template match="msg">
477 <xsl:call-template name="block.object"/>
480 <xsl:template match="msgmain">
481 <xsl:apply-templates/>
484 <xsl:template match="msgsub">
485 <xsl:apply-templates/>
488 <xsl:template match="msgrel">
489 <xsl:apply-templates/>
492 <xsl:template match="msgtext">
493 <xsl:apply-templates/>
496 <xsl:template match="msginfo">
497 <xsl:call-template name="block.object"/>
500 <xsl:template match="msglevel">
502 <fo:inline font-weight="bold"
503 keep-with-next.within-line="always">
504 <xsl:call-template name="gentext.template">
505 <xsl:with-param name="context" select="'msgset'"/>
506 <xsl:with-param name="name" select="'MsgLevel'"/>
509 <xsl:apply-templates/>
513 <xsl:template match="msgorig">
515 <fo:inline font-weight="bold"
516 keep-with-next.within-line="always">
517 <xsl:call-template name="gentext.template">
518 <xsl:with-param name="context" select="'msgset'"/>
519 <xsl:with-param name="name" select="'MsgOrig'"/>
522 <xsl:apply-templates/>
526 <xsl:template match="msgaud">
528 <fo:inline font-weight="bold"
529 keep-with-next.within-line="always">
530 <xsl:call-template name="gentext.template">
531 <xsl:with-param name="context" select="'msgset'"/>
532 <xsl:with-param name="name" select="'MsgAud'"/>
535 <xsl:apply-templates/>
539 <xsl:template match="msgexplan">
540 <xsl:call-template name="block.object"/>
543 <xsl:template match="msgexplan/title">
544 <fo:block font-weight="bold"
545 keep-with-next.within-column="always"
547 <xsl:apply-templates/>
551 <!-- ==================================================================== -->
552 <!-- For better or worse, revhistory is allowed in content... -->
554 <xsl:template match="revhistory">
555 <fo:table table-layout="fixed" xsl:use-attribute-sets="revhistory.table.properties">
556 <xsl:call-template name="anchor"/>
557 <fo:table-column column-number="1" column-width="proportional-column-width(1)"/>
558 <fo:table-column column-number="2" column-width="proportional-column-width(1)"/>
559 <fo:table-column column-number="3" column-width="proportional-column-width(1)"/>
560 <fo:table-body start-indent="0pt" end-indent="0pt">
562 <fo:table-cell number-columns-spanned="3" xsl:use-attribute-sets="revhistory.table.cell.properties">
563 <fo:block xsl:use-attribute-sets="revhistory.title.properties">
565 <xsl:when test="title|info/title">
566 <xsl:apply-templates select="title|info/title" mode="titlepage.mode"/>
569 <xsl:call-template name="gentext">
570 <xsl:with-param name="key" select="'RevHistory'"/>
577 <xsl:apply-templates/>
582 <xsl:template match="revhistory/title">
583 <!-- Handled in titlepage.mode -->
586 <xsl:template match="revhistory/revision">
587 <xsl:variable name="revnumber" select="revnumber"/>
588 <xsl:variable name="revdate" select="date"/>
589 <xsl:variable name="revauthor" select="authorinitials|author"/>
590 <xsl:variable name="revremark" select="revremark|revdescription"/>
592 <fo:table-cell xsl:use-attribute-sets="revhistory.table.cell.properties">
594 <xsl:call-template name="anchor"/>
595 <xsl:if test="$revnumber">
596 <xsl:call-template name="gentext">
597 <xsl:with-param name="key" select="'Revision'"/>
599 <xsl:call-template name="gentext.space"/>
600 <xsl:apply-templates select="$revnumber[1]"/>
604 <fo:table-cell xsl:use-attribute-sets="revhistory.table.cell.properties">
606 <xsl:apply-templates select="$revdate[1]"/>
609 <fo:table-cell xsl:use-attribute-sets="revhistory.table.cell.properties">
611 <xsl:for-each select="$revauthor">
612 <xsl:apply-templates select="."/>
613 <xsl:if test="position() != last()">
614 <xsl:text>, </xsl:text>
620 <xsl:if test="$revremark">
622 <fo:table-cell number-columns-spanned="3" xsl:use-attribute-sets="revhistory.table.cell.properties">
624 <xsl:apply-templates select="$revremark[1]"/>
631 <xsl:template match="revision/revnumber">
632 <xsl:apply-templates/>
635 <xsl:template match="revision/date">
636 <xsl:apply-templates/>
639 <xsl:template match="revision/authorinitials">
640 <xsl:apply-templates/>
643 <xsl:template match="revision/author">
644 <xsl:apply-templates/>
647 <xsl:template match="revision/revremark">
648 <xsl:apply-templates/>
651 <xsl:template match="revision/revdescription">
652 <xsl:apply-templates/>
655 <!-- ==================================================================== -->
657 <xsl:template match="ackno|acknowledgements[parent::article]">
658 <fo:block xsl:use-attribute-sets="normal.para.spacing">
659 <xsl:call-template name="anchor"/>
660 <xsl:apply-templates/>
664 <!-- ==================================================================== -->
666 <xsl:template match="highlights">
667 <xsl:call-template name="block.object"/>
670 <!-- ==================================================================== -->