f6731d392779240f25bfc01ddec297f3764d307d
[exim.git] / doc / doc-docbook / MyStyle-fo.xsl
1 <!-- $Cambridge: exim/doc/doc-docbook/MyStyle-fo.xsl,v 1.4 2006/04/04 14:03:49 ph10 Exp $ -->
2
3 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4                 xmlns:fo="http://www.w3.org/1999/XSL/Format"
5                 version="1.0">
6
7 <!-- This stylesheet driver contains changes that I want to apply to the
8 printed output form of both the filter document and the main Exim
9 specification. It is imported by MyStyle-filter-fo.xsl and MyStyle-spec-fo.xsl.
10 -->
11
12 <xsl:import href="MyTitleStyle.xsl"/>
13
14
15
16 <!-- Set A4 paper, double sided -->
17
18 <xsl:param name="paper.type" select="'A4'"></xsl:param>
19
20 <!-- This currently causes errors
21 <xsl:param name="double.sided" select="1"></xsl:param>
22 -->
23
24 <!-- Let's have whatever fop extensions there are -->
25
26 <xsl:param name="fop.extensions" select="1"></xsl:param>
27
28 <!-- Arrange for the table of contents to be an even number of pages. The name
29 "lot" includes all pages that contain a "list of titles", which in our case is
30 only the TOC. -->
31
32 <xsl:template name="force.page.count">
33   <xsl:param name="element" select="local-name(.)"/>
34   <xsl:param name="master-reference" select="''"/>
35   <xsl:choose>
36     <xsl:when test="$master-reference = 'lot'">end-on-even</xsl:when>
37     <xsl:otherwise>no-force</xsl:otherwise>
38   </xsl:choose>
39 </xsl:template>
40
41 <!-- Allow for typed index entries. The "role" setting works with DocBook
42 version 4.2 or earlier. Later versions (which we are not currently using)
43 need "type". -->
44
45 <xsl:param name="index.on.type" select="1"></xsl:param>
46 <xsl:param name="index.on.role" select="1"></xsl:param>
47
48 <!-- The default uses short chapter titles in the TOC! I want them only for
49 use in footer lines. So we have to modify this template. I changed
50 "titleabbrev.markup" to "title.markup". While I'm here, I also made chapter
51 entries print in bold. -->
52
53 <xsl:template name="toc.line">
54   <xsl:variable name="id">
55     <xsl:call-template name="object.id"/>
56   </xsl:variable>
57
58   <xsl:variable name="label">
59     <xsl:apply-templates select="." mode="label.markup"/>
60   </xsl:variable>
61
62   <fo:block text-align-last="justify"
63             end-indent="{$toc.indent.width}pt"
64             last-line-end-indent="-{$toc.indent.width}pt">
65     <fo:inline keep-with-next.within-line="always">
66       <!-- Added lines for bold -->
67       <xsl:choose>
68         <xsl:when test="self::chapter">
69           <xsl:attribute name="font-weight">bold</xsl:attribute>
70         </xsl:when>
71         <xsl:when test="self::index">
72           <xsl:attribute name="font-weight">bold</xsl:attribute>
73         </xsl:when>
74       </xsl:choose>
75       <!--  ..................  -->
76       <fo:basic-link internal-destination="{$id}">
77         <xsl:if test="$label != ''">
78           <xsl:copy-of select="$label"/>
79           <xsl:value-of select="$autotoc.label.separator"/>
80         </xsl:if>
81         <xsl:apply-templates select="." mode="title.markup"/>
82       </fo:basic-link>
83     </fo:inline>
84     <fo:inline keep-together.within-line="always">
85       <xsl:text> </xsl:text>
86       <fo:leader leader-pattern="dots"
87                  leader-pattern-width="3pt"
88                  leader-alignment="reference-area"
89                  keep-with-next.within-line="always"/>
90       <xsl:text> </xsl:text>
91       <fo:basic-link internal-destination="{$id}">
92         <fo:page-number-citation ref-id="{$id}"/>
93       </fo:basic-link>
94     </fo:inline>
95   </fo:block>
96 </xsl:template>
97
98
99 <!--
100 Adjust the sizes of the fonts for titles; the defaults are too gross.
101 -->
102
103 <!-- Level 1 is sect1 level -->
104
105 <xsl:attribute-set name="section.title.level1.properties">
106   <xsl:attribute name="font-size">
107     <xsl:value-of select="$body.font.master * 1.2"></xsl:value-of>
108     <xsl:text>pt</xsl:text>
109   </xsl:attribute>
110 </xsl:attribute-set>
111
112
113 <!-- Fiddling with chapter titles is more messy -->
114
115 <xsl:template match="title" mode="chapter.titlepage.recto.auto.mode">
116   <fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format"
117             xsl:use-attribute-sets="chapter.titlepage.recto.style"
118             margin-left="{$title.margin.left}"
119             font-size="17pt"
120             font-weight="bold"
121             font-family="{$title.font.family}">
122     <xsl:call-template name="component.title">
123       <xsl:with-param name="node" select="ancestor-or-self::chapter[1]"/>
124     </xsl:call-template>
125   </fo:block>
126 </xsl:template>
127
128 <xsl:template match="title" mode="chapter.titlepage.verso.auto.mode">
129   <fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format"
130             xsl:use-attribute-sets="chapter.titlepage.recto.style"
131             margin-left="{$title.margin.left}"
132             font-size="17pt"
133             font-weight="bold"
134             font-family="{$title.font.family}">
135     <xsl:call-template name="component.title">
136       <xsl:with-param name="node" select="ancestor-or-self::chapter[1]"/>
137     </xsl:call-template>
138   </fo:block>
139 </xsl:template>
140
141
142 <!-- This provides a hard pagebreak mechanism as a get-out -->
143
144 <xsl:template match="processing-instruction('hard-pagebreak')">
145   <fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format" break-before='page'>
146   </fo:block>
147 </xsl:template>
148
149
150 <!-- Sort out the footer. Useful information is available at
151 http://www.sagehill.net/docbookxsl/PrintHeaders.html
152 -->
153
154 <xsl:attribute-set name="footer.content.properties">
155   <!-- <xsl:attribute name="font-family">serif</xsl:attribute> -->
156   <!-- <xsl:attribute name="font-size">9pt</xsl:attribute> -->
157   <xsl:attribute name="font-style">italic</xsl:attribute>
158 </xsl:attribute-set>
159
160
161 <!-- The default cell widths make the centre one too large -->
162
163 <xsl:param name="footer.column.widths">4 1 4</xsl:param>
164
165
166 <!-- Put the abbreviated chapter titles in running feet, and add the chapter
167 number afterwards in parentheses. I changed title.markup to titleabbrev.markup,
168 and added some lines.
169 -->
170
171 <xsl:template name="footer.content">
172   <xsl:param name="pageclass" select="''"/>
173   <xsl:param name="sequence" select="''"/>
174   <xsl:param name="position" select="''"/>
175   <xsl:param name="gentext-key" select="''"/>
176
177   <fo:block>
178     <!-- pageclass can be front, body, back -->
179     <!-- sequence can be odd, even, first, blank -->
180     <!-- position can be left, center, right -->
181     <xsl:choose>
182       <xsl:when test="$pageclass = 'titlepage'">
183         <!-- nop; no footer on title pages -->
184       </xsl:when>
185
186       <xsl:when test="$double.sided != 0 and $sequence = 'even'
187                       and $position='left'">
188         <fo:page-number/>
189       </xsl:when>
190
191       <xsl:when test="$double.sided != 0 and ($sequence = 'odd' or $sequence = 'first')
192                       and $position='right'">
193         <fo:page-number/>
194       </xsl:when>
195
196       <xsl:when test="$double.sided = 0 and $position='center'">
197         <fo:page-number/>
198       </xsl:when>
199
200       <!-- This clause added by PH -->
201       <xsl:when test="$double.sided = 0 and $position='right' and $pageclass='body'">
202         <xsl:apply-templates select="." mode="titleabbrev.markup"/>
203           <xsl:text> (</xsl:text>
204           <xsl:apply-templates select="." mode="label.markup"/>
205           <xsl:text>)</xsl:text>
206       </xsl:when>
207
208       <!-- Changed title.markup to titleabbrev.markup for TOC -->
209       <xsl:when test="$double.sided = 0 and $position='right'">
210         <xsl:apply-templates select="." mode="titleabbrev.markup"/>
211       </xsl:when>
212
213       <xsl:when test="$sequence='blank'">
214         <xsl:choose>
215           <xsl:when test="$double.sided != 0 and $position = 'left'">
216             <fo:page-number/>
217           </xsl:when>
218           <xsl:when test="$double.sided = 0 and $position = 'center'">
219             <fo:page-number/>
220           </xsl:when>
221           <xsl:otherwise>
222             <!-- nop -->
223           </xsl:otherwise>
224         </xsl:choose>
225       </xsl:when>
226
227       <xsl:otherwise>
228         <!-- nop -->
229       </xsl:otherwise>
230     </xsl:choose>
231   </fo:block>
232 </xsl:template>
233
234
235 <!-- Arrange for ordered list numbers to be in parentheses instead of just
236 followed by a dot, which I don't like. Unfortunately, this styling is
237 output-specific, so we have to do it separately for FO and HTML output. -->
238
239 <xsl:template match="orderedlist/listitem" mode="item-number">
240   <xsl:variable name="numeration">
241     <xsl:call-template name="list.numeration">
242       <xsl:with-param name="node" select="parent::orderedlist"/>
243     </xsl:call-template>
244   </xsl:variable>
245
246   <xsl:variable name="type">
247     <xsl:choose>
248       <xsl:when test="$numeration='arabic'">(1)</xsl:when>
249       <xsl:when test="$numeration='loweralpha'">(a)</xsl:when>
250       <xsl:when test="$numeration='lowerroman'">(i)</xsl:when>
251       <xsl:when test="$numeration='upperalpha'">(A)</xsl:when>
252       <xsl:when test="$numeration='upperroman'">(I)</xsl:when>
253       <!-- What!? This should never happen -->
254       <xsl:otherwise>
255         <xsl:message>
256           <xsl:text>Unexpected numeration: </xsl:text>
257           <xsl:value-of select="$numeration"/>
258         </xsl:message>
259         <xsl:value-of select="1."/>
260       </xsl:otherwise>
261     </xsl:choose>
262   </xsl:variable>
263
264   <xsl:variable name="item-number">
265     <xsl:call-template name="orderedlist-item-number"/>
266   </xsl:variable>
267
268   <xsl:if test="parent::orderedlist/@inheritnum='inherit'
269                 and ancestor::listitem[parent::orderedlist]">
270     <xsl:apply-templates select="ancestor::listitem[parent::orderedlist][1]"
271                          mode="item-number"/>
272   </xsl:if>
273
274   <xsl:number value="$item-number" format="{$type}"/>
275 </xsl:template>
276
277 </xsl:stylesheet>