]> git.evergreen-ils.org Git - working/Evergreen.git/blob - stylesheets/styleguide/docbook-xsl-1.75.2/fo/block.xsl
stylesheet changes.
[working/Evergreen.git] / stylesheets / styleguide / docbook-xsl-1.75.2 / fo / block.xsl
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: block.xsl 8441 2009-05-24 02:14:56Z abdelazer $
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   <xsl:variable name="keep.together">
27     <xsl:call-template name="pi.dbfo_keep-together"/>
28   </xsl:variable>
29   <fo:block>
30     <xsl:if test="$keep.together != ''">
31       <xsl:attribute name="keep-together.within-column"><xsl:value-of
32                       select="$keep.together"/></xsl:attribute>
33     </xsl:if>
34     <xsl:call-template name="anchor"/>
35     <xsl:apply-templates/>
36   </fo:block>
37 </xsl:template>
38
39 <!-- ==================================================================== -->
40
41 <xsl:template match="para">
42   <xsl:variable name="keep.together">
43     <xsl:call-template name="pi.dbfo_keep-together"/>
44   </xsl:variable>
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>
49     </xsl:if>
50     <xsl:call-template name="anchor"/>
51     <xsl:apply-templates/>
52   </fo:block>
53 </xsl:template>
54
55 <xsl:template match="simpara">
56   <xsl:variable name="keep.together">
57     <xsl:call-template name="pi.dbfo_keep-together"/>
58   </xsl:variable>
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>
63     </xsl:if>
64     <xsl:call-template name="anchor"/>
65     <xsl:apply-templates/>
66   </fo:block>
67 </xsl:template>
68
69 <xsl:template match="formalpara">
70   <xsl:variable name="keep.together">
71     <xsl:call-template name="pi.dbfo_keep-together"/>
72   </xsl:variable>
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>
77     </xsl:if>
78     <xsl:call-template name="anchor"/>
79     <xsl:apply-templates/>
80   </fo:block>
81 </xsl:template>
82
83 <!-- Only use title from info -->
84 <xsl:template match="formalpara/info">
85   <xsl:apply-templates select="title"/>
86 </xsl:template>
87
88 <xsl:template match="formalpara/title|formalpara/info/title">
89   <xsl:variable name="titleStr">
90       <xsl:apply-templates/>
91   </xsl:variable>
92   <xsl:variable name="lastChar">
93     <xsl:if test="$titleStr != ''">
94       <xsl:value-of select="substring($titleStr,string-length($titleStr),1)"/>
95     </xsl:if>
96   </xsl:variable>
97
98   <fo:inline font-weight="bold"
99              keep-with-next.within-line="always"
100              padding-end="1em">
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"/>
105     </xsl:if>
106     <xsl:text>&#160;</xsl:text>
107   </fo:inline>
108 </xsl:template>
109
110 <xsl:template match="formalpara/para">
111   <xsl:apply-templates/>
112 </xsl:template>
113
114 <!-- ==================================================================== -->
115
116 <xsl:template match="blockquote">
117   <xsl:variable name="keep.together">
118     <xsl:call-template name="pi.dbfo_keep-together"/>
119   </xsl:variable>
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>
124     </xsl:if>
125     <xsl:call-template name="anchor"/>
126     <fo:block>
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"/>
130         </fo:block>
131       </xsl:if>
132       <xsl:apply-templates select="*[local-name(.) != 'title'
133                                    and local-name(.) != 'attribution']"/>
134     </fo:block>
135     <xsl:if test="attribution">
136       <fo:block text-align="right">
137         <!-- mdash -->
138         <xsl:text>&#x2014;</xsl:text>
139         <xsl:apply-templates select="attribution"/>
140       </fo:block>
141     </xsl:if>
142   </fo:block>
143 </xsl:template>
144
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">
147   <fo:block>
148     <xsl:call-template name="anchor"/>
149     <xsl:apply-templates select="para|simpara|formalpara|literallayout"/>
150     <xsl:if test="attribution">
151       <fo:inline>
152         <xsl:text>&#x2014;</xsl:text>
153         <xsl:apply-templates select="attribution"/>
154       </fo:inline>
155     </xsl:if>
156   </fo:block>
157 </xsl:template>
158
159 <xsl:template match="attribution">
160   <fo:inline><xsl:apply-templates/></fo:inline>
161 </xsl:template>
162
163 <!-- ==================================================================== -->
164
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>
172
173   <xsl:choose>
174     <xsl:when test="not($fop.extensions = 0)">
175       <!-- fop 0.20.5 does not support floats -->
176       <xsl:copy-of select="$content"/>
177     </xsl:when>
178     <xsl:when test="$position = 'none'">
179       <xsl:copy-of select="$content"/>
180     </xsl:when>
181     <xsl:when test="$position = 'before'">
182       <fo:float float="before">
183         <xsl:copy-of select="$content"/>
184       </fo:float>
185     </xsl:when>
186     <xsl:when test="$position = 'left' or
187                     $position = 'start' or
188                     $position = 'right' or
189                     $position = 'end' or
190                     $position = 'inside' or
191                     $position = 'outside'">
192       <xsl:variable name="float">
193         <fo:float float="{$position}"
194                   clear="{$clear}">
195           <fo:block-container 
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"/>
201               </xsl:attribute>
202             </xsl:if>
203             <fo:block>
204               <xsl:copy-of select="$content"/>
205             </fo:block>
206           </fo:block-container>
207         </fo:float>
208       </xsl:variable>
209       <xsl:choose>
210         <xsl:when test="$axf.extensions != 0 and self::sidebar">
211           <fo:block xsl:use-attribute-sets="normal.para.spacing"
212                     space-after="0pt"
213                     space-after.precedence="force"
214                     start-indent="0pt" end-indent="0pt">
215             <xsl:copy-of select="$float"/>
216           </fo:block>
217         </xsl:when>
218         <xsl:when test="$axf.extensions != 0 and 
219                         ($position = 'left' or $position = 'start')">
220           <fo:float float="{$position}"
221                     clear="{$clear}">
222             <fo:block-container 
223                       inline-progression-dimension=".001mm"
224                       end-indent="{$start.indent} + {$width} + {$end.indent}">
225               <xsl:attribute name="start-indent">
226                 <xsl:choose>
227                   <xsl:when test="ancestor::para">
228                     <!-- Special case for handling inline floats
229                          in Antenna House-->
230                     <xsl:value-of select="concat('-', $body.start.indent)"/>
231                   </xsl:when>
232                   <xsl:otherwise>0pt</xsl:otherwise>
233                 </xsl:choose>
234               </xsl:attribute>
235               <fo:block start-indent="{$start.indent}"
236                         end-indent="-{$start.indent} - {$width}">
237                 <xsl:copy-of select="$content"/>
238               </fo:block>
239             </fo:block-container>
240           </fo:float>
241
242         </xsl:when>
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}"
247                     clear="{$clear}">
248             <fo:block-container 
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"/>
255               </fo:block>
256             </fo:block-container>
257           </fo:float>
258
259         </xsl:when>
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"/>
264           </fo:block>
265         </xsl:when>
266         <xsl:when test="$xep.extensions != 0">
267           <xsl:copy-of select="$float"/>
268         </xsl:when>
269         <xsl:otherwise>
270           <xsl:copy-of select="$float"/>
271         </xsl:otherwise>
272       </xsl:choose>
273     </xsl:when>
274     <xsl:otherwise>
275       <xsl:copy-of select="$content"/>
276     </xsl:otherwise>
277   </xsl:choose>
278 </xsl:template>
279
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"/>
284   </xsl:variable>
285
286   <xsl:variable name="id">
287     <xsl:call-template name="object.id"/>
288   </xsl:variable>
289
290   <xsl:choose>
291     <xsl:when test="$pi-type = 'margin.note'">
292       <xsl:call-template name="margin.note"/>
293     </xsl:when>
294     <xsl:otherwise>
295       <xsl:variable name="content">
296         <fo:block xsl:use-attribute-sets="sidebar.properties"
297                   id="{$id}">
298           <xsl:call-template name="sidebar.titlepage"/>
299           <xsl:apply-templates select="node()[not(self::title) and
300                                          not(self::info) and
301                                          not(self::sidebarinfo)]"/>
302         </fo:block>
303       </xsl:variable>
304
305       <xsl:variable name="pi-width">
306         <xsl:call-template name="pi.dbfo_sidebar-width"/>
307       </xsl:variable>
308
309       <xsl:variable name="position">
310         <xsl:choose>
311           <xsl:when test="$pi-type != ''">
312             <xsl:value-of select="$pi-type"/>
313           </xsl:when>
314           <xsl:otherwise>
315             <xsl:value-of select="$sidebar.float.type"/>
316           </xsl:otherwise>
317         </xsl:choose>
318       </xsl:variable>
319     
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">
324           <xsl:choose>
325             <xsl:when test="$pi-width != ''">
326               <xsl:value-of select="$pi-width"/>
327             </xsl:when>
328             <xsl:otherwise>
329               <xsl:value-of select="$sidebar.float.width"/>
330             </xsl:otherwise>
331           </xsl:choose>
332         </xsl:with-param>
333         <xsl:with-param name="start.indent">
334           <xsl:choose>
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>
340           </xsl:choose>
341         </xsl:with-param>
342         <xsl:with-param name="end.indent">
343           <xsl:choose>
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>
349           </xsl:choose>
350         </xsl:with-param>
351       </xsl:call-template>
352     </xsl:otherwise>
353   </xsl:choose>
354
355 </xsl:template>
356
357 <xsl:template match="sidebar/title|sidebarinfo|sidebar/info"/>
358
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/>
363   </fo:block>
364 </xsl:template>
365
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"/>
372         </fo:block>
373       </xsl:if>
374       <xsl:apply-templates/>
375     </fo:block>
376   </xsl:param>
377
378   <xsl:variable name="pi-width">
379     <xsl:call-template name="pi.dbfo_sidebar-width"/>
380   </xsl:variable>
381
382   <xsl:variable name="position" select="$margin.note.float.type"/>
383
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" >
388       <xsl:choose>
389         <xsl:when test="$pi-width != ''">
390           <xsl:value-of select="$pi-width"/>
391         </xsl:when>
392         <xsl:otherwise>
393           <xsl:value-of select="$margin.note.width"/>
394         </xsl:otherwise>
395       </xsl:choose>
396     </xsl:with-param>
397     <xsl:with-param name="start.indent">
398       <xsl:choose>
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>
404       </xsl:choose>
405     </xsl:with-param>
406     <xsl:with-param name="end.indent">
407       <xsl:choose>
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>
413       </xsl:choose>
414     </xsl:with-param>
415   </xsl:call-template>
416 </xsl:template>
417
418 <xsl:template match="sidebar/title" mode="margin.note.title.mode">
419   <xsl:apply-templates/>
420 </xsl:template>
421
422 <!-- ==================================================================== -->
423
424 <xsl:template match="abstract">
425   <xsl:variable name="keep.together">
426     <xsl:call-template name="pi.dbfo_keep-together"/>
427   </xsl:variable>
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>
432     </xsl:if>
433     <xsl:call-template name="anchor"/>
434     <xsl:apply-templates/>
435   </fo:block>
436 </xsl:template>
437
438 <xsl:template match="abstract/title|abstract/info/title">
439   <fo:block xsl:use-attribute-sets="abstract.title.properties">
440     <xsl:apply-templates/>
441   </fo:block>
442 </xsl:template>
443
444 <!-- ==================================================================== -->
445
446 <xsl:template match="msgset">
447   <xsl:apply-templates/>
448 </xsl:template>
449
450 <xsl:template match="msgentry">
451   <xsl:call-template name="block.object"/>
452 </xsl:template>
453
454 <xsl:template match="simplemsgentry">
455   <xsl:call-template name="block.object"/>
456 </xsl:template>
457
458 <xsl:template match="msg">
459   <xsl:call-template name="block.object"/>
460 </xsl:template>
461
462 <xsl:template match="msgmain">
463   <xsl:apply-templates/>
464 </xsl:template>
465
466 <xsl:template match="msgsub">
467   <xsl:apply-templates/>
468 </xsl:template>
469
470 <xsl:template match="msgrel">
471   <xsl:apply-templates/>
472 </xsl:template>
473
474 <xsl:template match="msgtext">
475   <xsl:apply-templates/>
476 </xsl:template>
477
478 <xsl:template match="msginfo">
479   <xsl:call-template name="block.object"/>
480 </xsl:template>
481
482 <xsl:template match="msglevel">
483   <fo:block>
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'"/>
489       </xsl:call-template>
490     </fo:inline>
491     <xsl:apply-templates/>
492   </fo:block>
493 </xsl:template>
494
495 <xsl:template match="msgorig">
496   <fo:block>
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'"/>
502       </xsl:call-template>
503     </fo:inline>
504     <xsl:apply-templates/>
505   </fo:block>
506 </xsl:template>
507
508 <xsl:template match="msgaud">
509   <fo:block>
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'"/>
515       </xsl:call-template>
516     </fo:inline>
517     <xsl:apply-templates/>
518   </fo:block>
519 </xsl:template>
520
521 <xsl:template match="msgexplan">
522   <xsl:call-template name="block.object"/>
523 </xsl:template>
524
525 <xsl:template match="msgexplan/title">
526   <fo:block font-weight="bold"
527             keep-with-next.within-column="always"
528             hyphenate="false">
529     <xsl:apply-templates/>
530   </fo:block>
531 </xsl:template>
532
533 <!-- ==================================================================== -->
534 <!-- For better or worse, revhistory is allowed in content... -->
535
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">
543       <fo:table-row>
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">
546             <xsl:call-template name="gentext">
547               <xsl:with-param name="key" select="'RevHistory'"/>
548             </xsl:call-template>
549           </fo:block>
550         </fo:table-cell>
551       </fo:table-row>
552       <xsl:apply-templates/>
553     </fo:table-body>
554   </fo:table>
555 </xsl:template>
556
557 <xsl:template match="revhistory/revision">
558   <xsl:variable name="revnumber" select="revnumber"/>
559   <xsl:variable name="revdate"   select="date"/>
560   <xsl:variable name="revauthor" select="authorinitials|author"/>
561   <xsl:variable name="revremark" select="revremark|revdescription"/>
562   <fo:table-row>
563     <fo:table-cell xsl:use-attribute-sets="revhistory.table.cell.properties">
564       <fo:block>
565         <xsl:call-template name="anchor"/>
566         <xsl:if test="$revnumber">
567           <xsl:call-template name="gentext">
568             <xsl:with-param name="key" select="'Revision'"/>
569           </xsl:call-template>
570           <xsl:call-template name="gentext.space"/>
571           <xsl:apply-templates select="$revnumber[1]"/>
572         </xsl:if>
573       </fo:block>
574     </fo:table-cell>
575     <fo:table-cell xsl:use-attribute-sets="revhistory.table.cell.properties">
576       <fo:block>
577         <xsl:apply-templates select="$revdate[1]"/>
578       </fo:block>
579     </fo:table-cell>
580     <fo:table-cell xsl:use-attribute-sets="revhistory.table.cell.properties">
581       <fo:block>
582         <xsl:for-each select="$revauthor">
583           <xsl:apply-templates select="."/>
584           <xsl:if test="position() != last()">
585             <xsl:text>, </xsl:text>
586           </xsl:if>
587         </xsl:for-each>
588       </fo:block>
589     </fo:table-cell>
590   </fo:table-row>
591   <xsl:if test="$revremark">
592     <fo:table-row>
593       <fo:table-cell number-columns-spanned="3" xsl:use-attribute-sets="revhistory.table.cell.properties">
594         <fo:block>
595           <xsl:apply-templates select="$revremark[1]"/>
596         </fo:block>
597       </fo:table-cell>
598     </fo:table-row>
599   </xsl:if>
600 </xsl:template>
601
602 <xsl:template match="revision/revnumber">
603   <xsl:apply-templates/>
604 </xsl:template>
605
606 <xsl:template match="revision/date">
607   <xsl:apply-templates/>
608 </xsl:template>
609
610 <xsl:template match="revision/authorinitials">
611   <xsl:apply-templates/>
612 </xsl:template>
613
614 <xsl:template match="revision/author">
615   <xsl:apply-templates/>
616 </xsl:template>
617
618 <xsl:template match="revision/revremark">
619   <xsl:apply-templates/>
620 </xsl:template>
621
622 <xsl:template match="revision/revdescription">
623   <xsl:apply-templates/>
624 </xsl:template>
625
626 <!-- ==================================================================== -->
627
628 <xsl:template match="ackno|acknowledgements[parent::article]">
629   <fo:block xsl:use-attribute-sets="normal.para.spacing">
630     <xsl:call-template name="anchor"/>
631     <xsl:apply-templates/>
632   </fo:block>
633 </xsl:template>
634
635 <!-- ==================================================================== -->
636
637 <xsl:template match="highlights">
638   <xsl:call-template name="block.object"/>
639 </xsl:template>
640
641 <!-- ==================================================================== -->
642
643 </xsl:stylesheet>