resetting manifest requested domain to floor
[platform/upstream/bzip2.git] / bz-fo.xsl
1 <?xml version="1.0" encoding="UTF-8"?> <!-- -*- sgml -*- -->
2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
3      xmlns:fo="http://www.w3.org/1999/XSL/Format" version="1.0">
4
5 <xsl:import href="http://docbook.sourceforge.net/release/xsl/current/fo/docbook.xsl"/>
6 <xsl:import href="bz-common.xsl"/>
7
8 <!-- set indent = yes while debugging, then change to NO -->
9 <xsl:output method="xml" indent="yes"/>
10
11 <!-- ensure only passivetex extensions are on -->
12 <xsl:param name="stylesheet.result.type" select="'fo'"/>
13 <!-- fo extensions: PDF bookmarks and index terms -->
14 <xsl:param name="use.extensions" select="'1'"/>
15 <xsl:param name="xep.extensions" select="0"/>      
16 <xsl:param name="fop.extensions" select="0"/>     
17 <xsl:param name="saxon.extensions" select="0"/>   
18 <xsl:param name="passivetex.extensions" select="1"/>
19 <xsl:param name="tablecolumns.extension" select="'1'"/>
20
21 <!-- ensure we are using single sided -->
22 <xsl:param name="double.sided" select="'0'"/> 
23
24 <!-- insert cross references to page numbers -->
25 <xsl:param name="insert.xref.page.number" select="1"/>
26
27 <!-- <?custom-pagebreak?> inserts a page break at this point -->
28 <xsl:template match="processing-instruction('custom-pagebreak')">
29   <fo:block break-before='page'/>
30 </xsl:template>
31
32 <!-- show links in color -->
33 <xsl:attribute-set name="xref.properties">
34   <xsl:attribute name="color">blue</xsl:attribute>
35 </xsl:attribute-set>
36
37 <!-- make pre listings indented a bit + a bg colour -->
38 <xsl:template match="programlisting | screen">
39   <fo:block start-indent="0.25in" wrap-option="no-wrap" 
40             white-space-collapse="false" text-align="start" 
41             font-family="monospace" background-color="#f2f2f9"
42             linefeed-treatment="preserve" 
43             xsl:use-attribute-sets="normal.para.spacing">
44     <xsl:apply-templates/>
45   </fo:block>
46 </xsl:template>
47 <!-- make verbatim output prettier -->
48 <xsl:template match="literallayout">
49   <fo:block start-indent="0.25in" wrap-option="no-wrap" 
50             white-space-collapse="false" text-align="start" 
51             font-family="monospace" background-color="#edf7f4"
52             linefeed-treatment="preserve" 
53             space-before="0em" space-after="0em">
54     <xsl:apply-templates/>
55   </fo:block>
56 </xsl:template>
57
58 <!-- workaround bug in passivetex fo output for itemizedlist -->
59 <xsl:template match="itemizedlist/listitem">
60   <xsl:variable name="id">
61   <xsl:call-template name="object.id"/></xsl:variable>
62   <xsl:variable name="itemsymbol">
63     <xsl:call-template name="list.itemsymbol">
64       <xsl:with-param name="node" select="parent::itemizedlist"/>
65     </xsl:call-template>
66   </xsl:variable>
67   <xsl:variable name="item.contents">
68     <fo:list-item-label end-indent="label-end()">
69       <fo:block>
70         <xsl:choose>
71           <xsl:when test="$itemsymbol='disc'">&#x2022;</xsl:when>
72           <xsl:when test="$itemsymbol='bullet'">&#x2022;</xsl:when>
73           <xsl:otherwise>&#x2022;</xsl:otherwise>
74         </xsl:choose>
75       </fo:block>
76     </fo:list-item-label>
77     <fo:list-item-body start-indent="body-start()">
78       <xsl:apply-templates/>    <!-- removed extra block wrapper -->
79     </fo:list-item-body>
80   </xsl:variable>
81   <xsl:choose>
82     <xsl:when test="parent::*/@spacing = 'compact'">
83       <fo:list-item id="{$id}" 
84           xsl:use-attribute-sets="compact.list.item.spacing">
85         <xsl:copy-of select="$item.contents"/>
86       </fo:list-item>
87     </xsl:when>
88     <xsl:otherwise>
89       <fo:list-item id="{$id}" xsl:use-attribute-sets="list.item.spacing">
90         <xsl:copy-of select="$item.contents"/>
91       </fo:list-item>
92     </xsl:otherwise>
93   </xsl:choose>
94 </xsl:template>
95
96 <!-- workaround bug in passivetex fo output for orderedlist -->
97 <xsl:template match="orderedlist/listitem">
98   <xsl:variable name="id">
99   <xsl:call-template name="object.id"/></xsl:variable>
100   <xsl:variable name="item.contents">
101     <fo:list-item-label end-indent="label-end()">
102       <fo:block>
103         <xsl:apply-templates select="." mode="item-number"/>
104       </fo:block>
105     </fo:list-item-label>
106     <fo:list-item-body start-indent="body-start()">
107       <xsl:apply-templates/>    <!-- removed extra block wrapper -->
108     </fo:list-item-body>
109   </xsl:variable>
110   <xsl:choose>
111     <xsl:when test="parent::*/@spacing = 'compact'">
112       <fo:list-item id="{$id}" 
113           xsl:use-attribute-sets="compact.list.item.spacing">
114         <xsl:copy-of select="$item.contents"/>
115       </fo:list-item>
116     </xsl:when>
117     <xsl:otherwise>
118       <fo:list-item id="{$id}" xsl:use-attribute-sets="list.item.spacing">
119         <xsl:copy-of select="$item.contents"/>
120       </fo:list-item>
121     </xsl:otherwise>
122   </xsl:choose>
123 </xsl:template>
124
125 <!-- workaround bug in passivetex fo output for variablelist -->
126 <xsl:param name="variablelist.as.blocks" select="1"/>
127 <xsl:template match="varlistentry" mode="vl.as.blocks">
128   <xsl:variable name="id">
129     <xsl:call-template name="object.id"/></xsl:variable>
130   <fo:block id="{$id}" xsl:use-attribute-sets="list.item.spacing"  
131       keep-together.within-column="always" 
132       keep-with-next.within-column="always">
133     <xsl:apply-templates select="term"/>
134   </fo:block>
135   <fo:block start-indent="0.5in" end-indent="0in" 
136             space-after.minimum="0.2em" 
137             space-after.optimum="0.4em" 
138             space-after.maximum="0.6em">
139     <fo:block>
140       <xsl:apply-templates select="listitem"/>
141     </fo:block>
142   </fo:block>
143 </xsl:template>
144
145
146 <!-- workaround bug in footers: force right-align w/two 80|30 cols -->
147 <xsl:template name="footer.table">
148   <xsl:param name="pageclass" select="''"/>
149   <xsl:param name="sequence" select="''"/>
150   <xsl:param name="gentext-key" select="''"/>
151   <xsl:choose>
152     <xsl:when test="$pageclass = 'index'">
153       <xsl:attribute name="margin-left">0pt</xsl:attribute>
154     </xsl:when>
155   </xsl:choose>
156   <xsl:variable name="candidate">
157     <fo:table table-layout="fixed" width="100%">
158       <fo:table-column column-number="1" column-width="80%"/>
159       <fo:table-column column-number="2" column-width="20%"/>
160       <fo:table-body>
161         <fo:table-row height="14pt">
162           <fo:table-cell text-align="left" display-align="after">
163             <xsl:attribute name="relative-align">baseline</xsl:attribute>
164             <fo:block> 
165               <fo:block> </fo:block><!-- empty cell -->
166             </fo:block>
167           </fo:table-cell>
168           <fo:table-cell text-align="center" display-align="after">
169             <xsl:attribute name="relative-align">baseline</xsl:attribute>
170             <fo:block>
171               <xsl:call-template name="footer.content">
172                 <xsl:with-param name="pageclass" select="$pageclass"/>
173                 <xsl:with-param name="sequence" select="$sequence"/>
174                 <xsl:with-param name="position" select="'center'"/>
175                 <xsl:with-param name="gentext-key" select="$gentext-key"/>
176               </xsl:call-template>
177             </fo:block>
178           </fo:table-cell>
179         </fo:table-row>
180       </fo:table-body>
181     </fo:table>
182   </xsl:variable>
183   <!-- Really output a footer? -->
184   <xsl:choose>
185     <xsl:when test="$pageclass='titlepage' and $gentext-key='book'
186                     and $sequence='first'">
187       <!-- no, book titlepages have no footers at all -->
188     </xsl:when>
189     <xsl:when test="$sequence = 'blank' and $footers.on.blank.pages = 0">
190       <!-- no output -->
191     </xsl:when>
192     <xsl:otherwise>
193       <xsl:copy-of select="$candidate"/>
194     </xsl:otherwise>
195   </xsl:choose>
196 </xsl:template>
197
198
199 <!-- fix bug in headers: force right-align w/two 40|60 cols -->
200 <xsl:template name="header.table">
201   <xsl:param name="pageclass" select="''"/>
202   <xsl:param name="sequence" select="''"/>
203   <xsl:param name="gentext-key" select="''"/>
204   <xsl:choose>
205     <xsl:when test="$pageclass = 'index'">
206       <xsl:attribute name="margin-left">0pt</xsl:attribute>
207     </xsl:when>
208   </xsl:choose>
209   <xsl:variable name="candidate">
210     <fo:table table-layout="fixed" width="100%">
211       <xsl:call-template name="head.sep.rule">
212         <xsl:with-param name="pageclass" select="$pageclass"/>
213         <xsl:with-param name="sequence" select="$sequence"/>
214         <xsl:with-param name="gentext-key" select="$gentext-key"/>
215       </xsl:call-template>
216       <fo:table-column column-number="1" column-width="40%"/>
217       <fo:table-column column-number="2" column-width="60%"/>
218       <fo:table-body>
219         <fo:table-row height="14pt">
220           <fo:table-cell text-align="left" display-align="before">
221             <xsl:attribute name="relative-align">baseline</xsl:attribute>
222             <fo:block>
223               <fo:block> </fo:block><!-- empty cell -->
224             </fo:block>
225           </fo:table-cell>
226           <fo:table-cell text-align="center" display-align="before">
227             <xsl:attribute name="relative-align">baseline</xsl:attribute>
228             <fo:block>
229               <xsl:call-template name="header.content">
230                 <xsl:with-param name="pageclass" select="$pageclass"/>
231                 <xsl:with-param name="sequence" select="$sequence"/>
232                 <xsl:with-param name="position" select="'center'"/>
233                 <xsl:with-param name="gentext-key" select="$gentext-key"/>
234               </xsl:call-template>
235             </fo:block>
236           </fo:table-cell>
237         </fo:table-row>
238       </fo:table-body>
239     </fo:table>
240   </xsl:variable>
241   <!-- Really output a header? -->
242   <xsl:choose>
243     <xsl:when test="$pageclass = 'titlepage' and $gentext-key = 'book'
244                     and $sequence='first'">
245       <!-- no, book titlepages have no headers at all -->
246     </xsl:when>
247     <xsl:when test="$sequence = 'blank' and $headers.on.blank.pages = 0">
248       <!-- no output -->
249     </xsl:when>
250     <xsl:otherwise>
251       <xsl:copy-of select="$candidate"/>
252     </xsl:otherwise>
253   </xsl:choose>
254 </xsl:template>
255
256
257 <!-- Bug-fix for Suse 10 PassiveTex version -->
258 <!-- Precompute attribute values 'cos PassiveTex is too stupid: -->
259 <xsl:attribute-set name="component.title.properties">
260   <xsl:attribute name="keep-with-next.within-column">always</xsl:attribute>
261   <xsl:attribute name="space-before.optimum">
262     <xsl:value-of select="concat($body.font.master, 'pt')"/>
263   </xsl:attribute>
264   <xsl:attribute name="space-before.minimum">
265     <xsl:value-of select="$body.font.master * 0.8"/>
266     <xsl:text>pt</xsl:text>
267   </xsl:attribute>
268   <xsl:attribute name="space-before.maximum">
269     <xsl:value-of select="$body.font.master * 1.2"/>
270     <xsl:text>pt</xsl:text>
271   </xsl:attribute>
272   <xsl:attribute name="hyphenate">false</xsl:attribute>
273 </xsl:attribute-set>
274
275
276 </xsl:stylesheet>