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 8597 2010-03-20 04:56:04Z 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 <!-- ==================================================================== -->
17 <!-- What should we do about styling blockinfo? -->
19 <xsl:template match=
"blockinfo|info">
23 <!-- ==================================================================== -->
25 <xsl:template name=
"block.object">
26 <xsl:variable name=
"keep.together">
27 <xsl:call-template name=
"pi.dbfo_keep-together"/>
30 <xsl:if test=
"$keep.together != ''">
31 <xsl:attribute name=
"keep-together.within-column"><xsl:value-of
32 select=
"$keep.together"/></xsl:attribute>
34 <xsl:call-template name=
"anchor"/>
35 <xsl:apply-templates/>
39 <!-- ==================================================================== -->
41 <xsl:template match=
"para">
42 <xsl:variable name=
"keep.together">
43 <xsl:call-template name=
"pi.dbfo_keep-together"/>
45 <fo:block xsl:
use-attribute-sets=
"normal.para.spacing">
46 <xsl:if test=
"$keep.together != ''">
47 <xsl:attribute name=
"keep-together.within-column"><xsl:value-of
48 select=
"$keep.together"/></xsl:attribute>
50 <xsl:call-template name=
"anchor"/>
51 <xsl:apply-templates/>
55 <xsl:template match=
"simpara">
56 <xsl:variable name=
"keep.together">
57 <xsl:call-template name=
"pi.dbfo_keep-together"/>
59 <fo:block xsl:
use-attribute-sets=
"normal.para.spacing">
60 <xsl:if test=
"$keep.together != ''">
61 <xsl:attribute name=
"keep-together.within-column"><xsl:value-of
62 select=
"$keep.together"/></xsl:attribute>
64 <xsl:call-template name=
"anchor"/>
65 <xsl:apply-templates/>
69 <xsl:template match=
"formalpara">
70 <xsl:variable name=
"keep.together">
71 <xsl:call-template name=
"pi.dbfo_keep-together"/>
73 <fo:block xsl:
use-attribute-sets=
"normal.para.spacing">
74 <xsl:if test=
"$keep.together != ''">
75 <xsl:attribute name=
"keep-together.within-column"><xsl:value-of
76 select=
"$keep.together"/></xsl:attribute>
78 <xsl:call-template name=
"anchor"/>
79 <xsl:apply-templates/>
83 <!-- Only use title from info -->
84 <xsl:template match=
"formalpara/info">
85 <xsl:apply-templates select=
"title"/>
88 <xsl:template match=
"formalpara/title|formalpara/info/title">
89 <xsl:variable name=
"titleStr">
90 <xsl:apply-templates/>
92 <xsl:variable name=
"lastChar">
93 <xsl:if test=
"$titleStr != ''">
94 <xsl:value-of select=
"substring($titleStr,string-length($titleStr),1)"/>
98 <fo:inline font-weight=
"bold"
99 keep-with-next.
within-line=
"always"
101 <xsl:copy-of select=
"$titleStr"/>
102 <xsl:if test=
"$lastChar != ''
103 and not(contains($runinhead.title.end.punct, $lastChar))">
104 <xsl:value-of select=
"$runinhead.default.title.end.punct"/>
106 <xsl:text> </xsl:text>
110 <xsl:template match=
"formalpara/para">
111 <xsl:apply-templates/>
114 <!-- ==================================================================== -->
116 <xsl:template match=
"blockquote">
117 <xsl:variable name=
"keep.together">
118 <xsl:call-template name=
"pi.dbfo_keep-together"/>
120 <fo:block xsl:
use-attribute-sets=
"blockquote.properties">
121 <xsl:if test=
"$keep.together != ''">
122 <xsl:attribute name=
"keep-together.within-column"><xsl:value-of
123 select=
"$keep.together"/></xsl:attribute>
125 <xsl:call-template name=
"anchor"/>
127 <xsl:if test=
"title|info/title">
128 <fo:block xsl:
use-attribute-sets=
"formal.title.properties">
129 <xsl:apply-templates select=
"." mode=
"object.title.markup"/>
132 <xsl:apply-templates select=
"*[local-name(.) != 'title'
133 and local-name(.) != 'attribution']"/>
135 <xsl:if test=
"attribution">
136 <fo:block text-align=
"right">
138 <xsl:text>—</xsl:text>
139 <xsl:apply-templates select=
"attribution"/>
145 <!-- 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 -->
146 <xsl:template match=
"epigraph">
148 <xsl:call-template name=
"anchor"/>
149 <xsl:apply-templates select=
"para|simpara|formalpara|literallayout"/>
150 <xsl:if test=
"attribution">
152 <xsl:text>—</xsl:text>
153 <xsl:apply-templates select=
"attribution"/>
159 <xsl:template match=
"attribution">
160 <fo:inline><xsl:apply-templates/></fo:inline>
163 <!-- ==================================================================== -->
165 <xsl:template name=
"floater">
166 <xsl:param name=
"position" select=
"'none'"/>
167 <xsl:param name=
"clear" select=
"'both'"/>
168 <xsl:param name=
"width"/>
169 <xsl:param name=
"content"/>
170 <xsl:param name=
"start.indent">0pt
</xsl:param>
171 <xsl:param name=
"end.indent">0pt
</xsl:param>
174 <xsl:when test=
"not($fop.extensions = 0)">
175 <!-- fop 0.20.5 does not support floats -->
176 <xsl:copy-of select=
"$content"/>
178 <xsl:when test=
"$position = 'none'">
179 <xsl:copy-of select=
"$content"/>
181 <xsl:when test=
"$position = 'before'">
182 <fo:float float=
"before">
183 <xsl:copy-of select=
"$content"/>
186 <xsl:when test=
"$position = 'left' or
187 $position = 'start' or
188 $position = 'right' or
190 $position = 'inside' or
191 $position = 'outside'">
192 <xsl:variable name=
"float">
193 <fo:float float=
"{$position}"
196 start-indent=
"{$start.indent}"
197 end-indent=
"{$end.indent}">
198 <xsl:if test=
"$width != ''">
199 <xsl:attribute name=
"inline-progression-dimension">
200 <xsl:value-of select=
"$width"/>
204 <xsl:copy-of select=
"$content"/>
206 </fo:block-container>
210 <xsl:when test=
"$axf.extensions != 0 and self::sidebar">
211 <fo:block xsl:
use-attribute-sets=
"normal.para.spacing"
213 space-after.
precedence=
"force"
214 start-indent=
"0pt" end-indent=
"0pt">
215 <xsl:copy-of select=
"$float"/>
218 <xsl:when test=
"$axf.extensions != 0 and
219 ($position = 'left' or $position = 'start')">
220 <fo:float float=
"{$position}"
223 inline-progression-dimension=
".001mm"
224 end-indent=
"{$start.indent} + {$width} + {$end.indent}">
225 <xsl:attribute name=
"start-indent">
227 <xsl:when test=
"ancestor::para">
228 <!-- Special case for handling inline floats
230 <xsl:value-of select=
"concat('-', $body.start.indent)"/>
232 <xsl:otherwise>0pt
</xsl:otherwise>
235 <fo:block start-indent=
"{$start.indent}"
236 end-indent=
"-{$start.indent} - {$width}">
237 <xsl:copy-of select=
"$content"/>
239 </fo:block-container>
243 <xsl:when test=
"$axf.extensions != 0 and
244 ($position = 'right' or $position = 'end')">
245 <!-- Special case for handling inline floats in Antenna House-->
246 <fo:float float=
"{$position}"
249 inline-progression-dimension=
".001mm"
250 end-indent=
"-{$body.end.indent}"
251 start-indent=
"{$start.indent} + {$width} + {$end.indent}">
252 <fo:block end-indent=
"{$end.indent}"
253 start-indent=
"-{$end.indent} - {$width}">
254 <xsl:copy-of select=
"$content"/>
256 </fo:block-container>
260 <xsl:when test=
"$xep.extensions != 0 and self::sidebar">
261 <!-- float needs some space above to line up with following para -->
262 <fo:block xsl:
use-attribute-sets=
"normal.para.spacing">
263 <xsl:copy-of select=
"$float"/>
266 <xsl:when test=
"$xep.extensions != 0">
267 <xsl:copy-of select=
"$float"/>
270 <xsl:copy-of select=
"$float"/>
275 <xsl:copy-of select=
"$content"/>
280 <xsl:template match=
"sidebar" name=
"sidebar">
281 <!-- Also does margin notes -->
282 <xsl:variable name=
"pi-type">
283 <xsl:call-template name=
"pi.dbfo_float-type"/>
286 <xsl:variable name=
"id">
287 <xsl:call-template name=
"object.id"/>
291 <xsl:when test=
"$pi-type = 'margin.note'">
292 <xsl:call-template name=
"margin.note"/>
295 <xsl:variable name=
"content">
296 <fo:block xsl:
use-attribute-sets=
"sidebar.properties"
298 <xsl:call-template name=
"sidebar.titlepage"/>
299 <xsl:apply-templates select=
"node()[not(self::title) and
301 not(self::sidebarinfo)]"/>
305 <xsl:variable name=
"pi-width">
306 <xsl:call-template name=
"pi.dbfo_sidebar-width"/>
309 <xsl:variable name=
"position">
311 <xsl:when test=
"$pi-type != ''">
312 <xsl:value-of select=
"$pi-type"/>
315 <xsl:value-of select=
"$sidebar.float.type"/>
320 <xsl:call-template name=
"floater">
321 <xsl:with-param name=
"content" select=
"$content"/>
322 <xsl:with-param name=
"position" select=
"$position"/>
323 <xsl:with-param name=
"width">
325 <xsl:when test=
"$pi-width != ''">
326 <xsl:value-of select=
"$pi-width"/>
329 <xsl:value-of select=
"$sidebar.float.width"/>
333 <xsl:with-param name=
"start.indent">
335 <xsl:when test=
"$position = 'start' or
336 $position = 'left'">0pt
</xsl:when>
337 <xsl:when test=
"$position = 'end' or
338 $position = 'right'">0.5em
</xsl:when>
339 <xsl:otherwise>0pt
</xsl:otherwise>
342 <xsl:with-param name=
"end.indent">
344 <xsl:when test=
"$position = 'start' or
345 $position = 'left'">0.5em
</xsl:when>
346 <xsl:when test=
"$position = 'end' or
347 $position = 'right'">0pt
</xsl:when>
348 <xsl:otherwise>0pt
</xsl:otherwise>
357 <xsl:template match=
"sidebar/title|sidebarinfo|sidebar/info"/>
359 <xsl:template match=
"sidebar/title|sidebarinfo/title|sidebar/info/title"
360 mode=
"titlepage.mode" priority=
"1">
361 <fo:block xsl:
use-attribute-sets=
"sidebar.title.properties">
362 <xsl:apply-templates/>
366 <xsl:template name=
"margin.note">
367 <xsl:param name=
"content">
368 <fo:block xsl:
use-attribute-sets=
"margin.note.properties">
369 <xsl:if test=
"./title">
370 <fo:block xsl:
use-attribute-sets=
"margin.note.title.properties">
371 <xsl:apply-templates select=
"./title" mode=
"margin.note.title.mode"/>
374 <xsl:apply-templates/>
378 <xsl:variable name=
"pi-width">
379 <xsl:call-template name=
"pi.dbfo_sidebar-width"/>
382 <xsl:variable name=
"position" select=
"$margin.note.float.type"/>
384 <xsl:call-template name=
"floater">
385 <xsl:with-param name=
"content" select=
"$content"/>
386 <xsl:with-param name=
"position" select=
"$position"/>
387 <xsl:with-param name=
"width" >
389 <xsl:when test=
"$pi-width != ''">
390 <xsl:value-of select=
"$pi-width"/>
393 <xsl:value-of select=
"$margin.note.width"/>
397 <xsl:with-param name=
"start.indent">
399 <xsl:when test=
"$position = 'start' or
400 $position = 'left'">0pt
</xsl:when>
401 <xsl:when test=
"$position = 'end' or
402 $position = 'right'">0.5em
</xsl:when>
403 <xsl:otherwise>0pt
</xsl:otherwise>
406 <xsl:with-param name=
"end.indent">
408 <xsl:when test=
"$position = 'start' or
409 $position = 'left'">0.5em
</xsl:when>
410 <xsl:when test=
"$position = 'end' or
411 $position = 'right'">0pt
</xsl:when>
412 <xsl:otherwise>0pt
</xsl:otherwise>
418 <xsl:template match=
"sidebar/title" mode=
"margin.note.title.mode">
419 <xsl:apply-templates/>
422 <!-- ==================================================================== -->
424 <xsl:template match=
"abstract">
425 <xsl:variable name=
"keep.together">
426 <xsl:call-template name=
"pi.dbfo_keep-together"/>
428 <fo:block xsl:
use-attribute-sets=
"abstract.properties">
429 <xsl:if test=
"$keep.together != ''">
430 <xsl:attribute name=
"keep-together.within-column"><xsl:value-of
431 select=
"$keep.together"/></xsl:attribute>
433 <xsl:call-template name=
"anchor"/>
434 <xsl:apply-templates/>
438 <xsl:template match=
"abstract/title|abstract/info/title">
439 <fo:block xsl:
use-attribute-sets=
"abstract.title.properties">
440 <xsl:apply-templates/>
444 <!-- ==================================================================== -->
446 <xsl:template match=
"msgset">
447 <xsl:apply-templates/>
450 <xsl:template match=
"msgentry">
451 <xsl:call-template name=
"block.object"/>
454 <xsl:template match=
"simplemsgentry">
455 <xsl:call-template name=
"block.object"/>
458 <xsl:template match=
"msg">
459 <xsl:call-template name=
"block.object"/>
462 <xsl:template match=
"msgmain">
463 <xsl:apply-templates/>
466 <xsl:template match=
"msgsub">
467 <xsl:apply-templates/>
470 <xsl:template match=
"msgrel">
471 <xsl:apply-templates/>
474 <xsl:template match=
"msgtext">
475 <xsl:apply-templates/>
478 <xsl:template match=
"msginfo">
479 <xsl:call-template name=
"block.object"/>
482 <xsl:template match=
"msglevel">
484 <fo:inline font-weight=
"bold"
485 keep-with-next.
within-line=
"always">
486 <xsl:call-template name=
"gentext.template">
487 <xsl:with-param name=
"context" select=
"'msgset'"/>
488 <xsl:with-param name=
"name" select=
"'MsgLevel'"/>
491 <xsl:apply-templates/>
495 <xsl:template match=
"msgorig">
497 <fo:inline font-weight=
"bold"
498 keep-with-next.
within-line=
"always">
499 <xsl:call-template name=
"gentext.template">
500 <xsl:with-param name=
"context" select=
"'msgset'"/>
501 <xsl:with-param name=
"name" select=
"'MsgOrig'"/>
504 <xsl:apply-templates/>
508 <xsl:template match=
"msgaud">
510 <fo:inline font-weight=
"bold"
511 keep-with-next.
within-line=
"always">
512 <xsl:call-template name=
"gentext.template">
513 <xsl:with-param name=
"context" select=
"'msgset'"/>
514 <xsl:with-param name=
"name" select=
"'MsgAud'"/>
517 <xsl:apply-templates/>
521 <xsl:template match=
"msgexplan">
522 <xsl:call-template name=
"block.object"/>
525 <xsl:template match=
"msgexplan/title">
526 <fo:block font-weight=
"bold"
527 keep-with-next.
within-column=
"always"
529 <xsl:apply-templates/>
533 <!-- ==================================================================== -->
534 <!-- For better or worse, revhistory is allowed in content... -->
536 <xsl:template match=
"revhistory">
537 <fo:table table-layout=
"fixed" xsl:
use-attribute-sets=
"revhistory.table.properties">
538 <xsl:call-template name=
"anchor"/>
539 <fo:table-column column-number=
"1" column-width=
"proportional-column-width(1)"/>
540 <fo:table-column column-number=
"2" column-width=
"proportional-column-width(1)"/>
541 <fo:table-column column-number=
"3" column-width=
"proportional-column-width(1)"/>
542 <fo:table-body start-indent=
"0pt" end-indent=
"0pt">
544 <fo:table-cell number-columns-spanned=
"3" xsl:
use-attribute-sets=
"revhistory.table.cell.properties">
545 <fo:block xsl:
use-attribute-sets=
"revhistory.title.properties">
547 <xsl:when test=
"title|info/title">
548 <xsl:apply-templates select=
"title|info/title" mode=
"titlepage.mode"/>
551 <xsl:call-template name=
"gentext">
552 <xsl:with-param name=
"key" select=
"'RevHistory'"/>
559 <xsl:apply-templates/>
564 <xsl:template match=
"revhistory/title">
565 <!-- Handled in titlepage.mode -->
568 <xsl:template match=
"revhistory/revision">
569 <xsl:variable name=
"revnumber" select=
"revnumber"/>
570 <xsl:variable name=
"revdate" select=
"date"/>
571 <xsl:variable name=
"revauthor" select=
"authorinitials|author"/>
572 <xsl:variable name=
"revremark" select=
"revremark|revdescription"/>
574 <fo:table-cell xsl:
use-attribute-sets=
"revhistory.table.cell.properties">
576 <xsl:call-template name=
"anchor"/>
577 <xsl:if test=
"$revnumber">
578 <xsl:call-template name=
"gentext">
579 <xsl:with-param name=
"key" select=
"'Revision'"/>
581 <xsl:call-template name=
"gentext.space"/>
582 <xsl:apply-templates select=
"$revnumber[1]"/>
586 <fo:table-cell xsl:
use-attribute-sets=
"revhistory.table.cell.properties">
588 <xsl:apply-templates select=
"$revdate[1]"/>
591 <fo:table-cell xsl:
use-attribute-sets=
"revhistory.table.cell.properties">
593 <xsl:for-each select=
"$revauthor">
594 <xsl:apply-templates select=
"."/>
595 <xsl:if test=
"position() != last()">
596 <xsl:text>,
</xsl:text>
602 <xsl:if test=
"$revremark">
604 <fo:table-cell number-columns-spanned=
"3" xsl:
use-attribute-sets=
"revhistory.table.cell.properties">
606 <xsl:apply-templates select=
"$revremark[1]"/>
613 <xsl:template match=
"revision/revnumber">
614 <xsl:apply-templates/>
617 <xsl:template match=
"revision/date">
618 <xsl:apply-templates/>
621 <xsl:template match=
"revision/authorinitials">
622 <xsl:apply-templates/>
625 <xsl:template match=
"revision/author">
626 <xsl:apply-templates/>
629 <xsl:template match=
"revision/revremark">
630 <xsl:apply-templates/>
633 <xsl:template match=
"revision/revdescription">
634 <xsl:apply-templates/>
637 <!-- ==================================================================== -->
639 <xsl:template match=
"ackno|acknowledgements[parent::article]">
640 <fo:block xsl:
use-attribute-sets=
"normal.para.spacing">
641 <xsl:call-template name=
"anchor"/>
642 <xsl:apply-templates/>
646 <!-- ==================================================================== -->
648 <xsl:template match=
"highlights">
649 <xsl:call-template name=
"block.object"/>
652 <!-- ==================================================================== -->