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