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