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 8<xsl:template name="setup.pagemasters"> 9 <fo:layout-master-set> 10 <!-- one sided, single column --> 11 <fo:simple-page-master master-name="blank" 12 page-width="{$page.width}" 13 page-height="{$page.height}" 14 margin-top="{$page.margin.top}" 15 margin-bottom="{$page.margin.bottom}" 16 margin-left="{$page.margin.outer}" 17 margin-right="{$page.margin.inner}"> 18 <fo:region-body 19 margin-bottom="{$body.margin.bottom}" 20 margin-top="{$body.margin.top}"/> 21 <fo:region-before region-name="xsl-region-before-blank" 22 extent="{$region.before.extent}"/> 23 <fo:region-after region-name="xsl-region-after-blank" 24 extent="{$region.after.extent}"/> 25 </fo:simple-page-master> 26 27 <!-- one sided, single column --> 28 <fo:simple-page-master master-name="simple1" 29 page-width="{$page.width}" 30 page-height="{$page.height}" 31 margin-top="{$page.margin.top}" 32 margin-bottom="{$page.margin.bottom}" 33 margin-left="{$page.margin.outer}" 34 margin-right="{$page.margin.inner}"> 35 <fo:region-body 36 margin-bottom="{$body.margin.bottom}" 37 margin-top="{$body.margin.top}"/> 38 <fo:region-before extent="{$region.before.extent}"/> 39 <fo:region-after extent="{$region.after.extent}"/> 40 </fo:simple-page-master> 41 42 <!-- for left-hand/even pages in twosided mode, single column --> 43 <fo:simple-page-master master-name="left1" 44 page-width="{$page.width}" 45 page-height="{$page.height}" 46 margin-top="{$page.margin.top}" 47 margin-bottom="{$page.margin.bottom}" 48 margin-left="{$page.margin.outer}" 49 margin-right="{$page.margin.inner}"> 50 <fo:region-body 51 margin-bottom="{$body.margin.bottom}" 52 margin-top="{$body.margin.top}"/> 53 <fo:region-before region-name="xsl-region-before-left" 54 extent="{$region.before.extent}"/> 55 <fo:region-after region-name="xsl-region-after-left" 56 extent="{$region.after.extent}"/> 57 </fo:simple-page-master> 58 59 <!-- for right-hand/odd pages in twosided mode, single column --> 60 <fo:simple-page-master master-name="right1" 61 page-width="{$page.width}" 62 page-height="{$page.height}" 63 margin-top="{$page.margin.top}" 64 margin-bottom="{$page.margin.bottom}" 65 margin-left="{$page.margin.inner}" 66 margin-right="{$page.margin.outer}"> 67 <fo:region-body 68 margin-bottom="{$body.margin.bottom}" 69 margin-top="{$body.margin.top}"/> 70 <fo:region-before region-name="xsl-region-before-right" 71 extent="{$region.before.extent}"/> 72 <fo:region-after region-name="xsl-region-after-right" 73 extent="{$region.after.extent}"/> 74 </fo:simple-page-master> 75 76 <!-- special case of first page in either mode, single column --> 77 <fo:simple-page-master master-name="first1" 78 page-width="{$page.width}" 79 page-height="{$page.height}" 80 margin-top="{$page.margin.top}" 81 margin-bottom="{$page.margin.bottom}" 82 margin-left="{$page.margin.inner}" 83 margin-right="{$page.margin.inner}"> 84 <fo:region-body 85 margin-bottom="{$body.margin.bottom}" 86 margin-top="{$body.margin.top}"/> 87 <fo:region-before region-name="xsl-region-before-first" 88 extent="{$region.before.extent}"/> 89 <fo:region-after region-name="xsl-region-after-first" 90 extent="{$region.after.extent}"/> 91 </fo:simple-page-master> 92 93 <!-- for pages in one-side mode, 2 column --> 94 <fo:simple-page-master master-name="simple2" 95 page-width="{$page.width}" 96 page-height="{$page.height}" 97 margin-top="{$page.margin.top}" 98 margin-bottom="{$page.margin.bottom}" 99 margin-left="{$page.margin.outer}" 100 margin-right="{$page.margin.inner}"> 101 <fo:region-body 102 column-count="{$column.count}" 103 margin-bottom="{$body.margin.bottom}" 104 margin-top="{$body.margin.top}"/> 105 <fo:region-before extent="{$region.before.extent}"/> 106 <fo:region-after extent="{$region.after.extent}"/> 107 </fo:simple-page-master> 108 109 <!-- for left-hand/even pages in twosided mode, 2 column --> 110 <fo:simple-page-master master-name="left2" 111 page-width="{$page.width}" 112 page-height="{$page.height}" 113 margin-top="{$page.margin.top}" 114 margin-bottom="{$page.margin.bottom}" 115 margin-left="{$page.margin.outer}" 116 margin-right="{$page.margin.inner}"> 117 <fo:region-body 118 column-count="{$column.count}" 119 margin-bottom="{$body.margin.bottom}" 120 margin-top="{$body.margin.top}"/> 121 <fo:region-before region-name="xsl-region-before-left" 122 extent="{$region.before.extent}"/> 123 <fo:region-after region-name="xsl-region-after-left" 124 extent="{$region.after.extent}"/> 125 </fo:simple-page-master> 126 127 <!-- for right-hand/odd pages in twosided mode, 2 column --> 128 <fo:simple-page-master master-name="right2" 129 page-width="{$page.width}" 130 page-height="{$page.height}" 131 margin-top="{$page.margin.top}" 132 margin-bottom="{$page.margin.bottom}" 133 margin-left="{$page.margin.inner}" 134 margin-right="{$page.margin.outer}"> 135 <fo:region-body 136 column-count="{$column.count}" 137 margin-bottom="{$body.margin.bottom}" 138 margin-top="{$body.margin.top}"/> 139 <fo:region-before region-name="xsl-region-before-right" 140 extent="{$region.before.extent}"/> 141 <fo:region-after region-name="xsl-region-after-right" 142 extent="{$region.after.extent}"/> 143 </fo:simple-page-master> 144 145 <!-- special case of first page in either mode --> 146 <fo:simple-page-master master-name="first2" 147 page-width="{$page.width}" 148 page-height="{$page.height}" 149 margin-top="{$page.margin.top}" 150 margin-bottom="{$page.margin.bottom}" 151 margin-left="{$page.margin.inner}" 152 margin-right="{$page.margin.inner}"> 153 <fo:region-body 154 column-count="1" 155 margin-bottom="{$body.margin.bottom}" 156 margin-top="{$body.margin.top}"/> 157 <fo:region-before region-name="xsl-region-before-first" 158 extent="{$region.before.extent}"/> 159 <fo:region-after region-name="xsl-region-after-first" 160 extent="{$region.after.extent}"/> 161 </fo:simple-page-master> 162 163 <!-- setup for title-page, 1 column --> 164 <fo:page-sequence-master master-name="titlepage1"> 165 <fo:repeatable-page-master-alternatives> 166 <fo:conditional-page-master-reference master-name="first1"/> 167 </fo:repeatable-page-master-alternatives> 168 </fo:page-sequence-master> 169 170 <!-- setup for single-sided, 1 column --> 171 <fo:page-sequence-master master-name="oneside1"> 172 <fo:repeatable-page-master-alternatives> 173 <fo:conditional-page-master-reference master-name="simple1"/> 174 </fo:repeatable-page-master-alternatives> 175 </fo:page-sequence-master> 176 177 <!-- setup for double-sided, 1 column --> 178 <fo:page-sequence-master master-name="twoside1"> 179 <fo:repeatable-page-master-alternatives> 180 <fo:conditional-page-master-reference master-name="blank" 181 blank-or-not-blank="blank"/> 182 <fo:conditional-page-master-reference master-name="right1" 183 odd-or-even="odd"/> 184 <fo:conditional-page-master-reference master-name="left1" 185 odd-or-even="even"/> 186 </fo:repeatable-page-master-alternatives> 187 </fo:page-sequence-master> 188 189 <!-- setup for title-page, 2 column --> 190 <fo:page-sequence-master master-name="titlepage2"> 191 <fo:repeatable-page-master-alternatives> 192 <fo:conditional-page-master-reference master-name="first2"/> 193 </fo:repeatable-page-master-alternatives> 194 </fo:page-sequence-master> 195 196 <!-- setup for single-sided, 2 column --> 197 <fo:page-sequence-master master-name="oneside2"> 198 <fo:repeatable-page-master-alternatives> 199 <fo:conditional-page-master-reference master-name="simple2"/> 200 </fo:repeatable-page-master-alternatives> 201 </fo:page-sequence-master> 202 203 <!-- setup for double-sided, 2 column --> 204 <fo:page-sequence-master master-name="twoside2"> 205 <fo:repeatable-page-master-alternatives> 206 <fo:conditional-page-master-reference master-name="blank" 207 blank-or-not-blank="blank"/> 208 <fo:conditional-page-master-reference master-name="right2" 209 odd-or-even="odd"/> 210 <fo:conditional-page-master-reference master-name="left2" 211 odd-or-even="even"/> 212 </fo:repeatable-page-master-alternatives> 213 </fo:page-sequence-master> 214 215 <xsl:call-template name="user.pagemasters"/> 216 217 </fo:layout-master-set> 218</xsl:template> 219 220<!-- ==================================================================== --> 221 222<xsl:template name="user.pagemasters"/> <!-- intentionally empty --> 223 224<!-- ==================================================================== --> 225 226<!-- $double.sided, $column.count, and context --> 227 228<xsl:template name="select.pagemaster"> 229 <xsl:param name="element" select="local-name(.)"/> 230 <xsl:choose> 231 <xsl:when test="$double.sided != 0"> 232 <xsl:choose> 233 <xsl:when test="$column.count > 1"> 234 <xsl:call-template name="select.doublesided.multicolumn.pagemaster"> 235 <xsl:with-param name="element" select="$element"/> 236 </xsl:call-template> 237 </xsl:when> 238 <xsl:otherwise> 239 <xsl:call-template name="select.doublesided.pagemaster"> 240 <xsl:with-param name="element" select="$element"/> 241 </xsl:call-template> 242 </xsl:otherwise> 243 </xsl:choose> 244 </xsl:when> 245 <xsl:otherwise> 246 <xsl:choose> 247 <xsl:when test="$column.count > 1"> 248 <xsl:call-template name="select.singlesided.multicolumn.pagemaster"> 249 <xsl:with-param name="element" select="$element"/> 250 </xsl:call-template> 251 </xsl:when> 252 <xsl:otherwise> 253 <xsl:call-template name="select.singlesided.pagemaster"> 254 <xsl:with-param name="element" select="$element"/> 255 </xsl:call-template> 256 </xsl:otherwise> 257 </xsl:choose> 258 </xsl:otherwise> 259 </xsl:choose> 260</xsl:template> 261 262<xsl:template name="select.doublesided.multicolumn.pagemaster"> 263 <xsl:param name="element" select="local-name(.)"/> 264 <xsl:choose> 265 <xsl:when test="$element='set' or $element='book' or $element='part'"> 266 <xsl:text>titlepage2</xsl:text> 267 </xsl:when> 268 <xsl:otherwise>twoside2</xsl:otherwise> 269 </xsl:choose> 270</xsl:template> 271 272<xsl:template name="select.doublesided.pagemaster"> 273 <xsl:param name="element" select="local-name(.)"/> 274 <xsl:choose> 275 <xsl:when test="$element='set' or $element='book' or $element='part'"> 276 <xsl:text>titlepage1</xsl:text> 277 </xsl:when> 278 <xsl:otherwise>twoside1</xsl:otherwise> 279 </xsl:choose> 280</xsl:template> 281 282<xsl:template name="select.singlesided.multicolumn.pagemaster"> 283 <xsl:param name="element" select="local-name(.)"/> 284 <xsl:choose> 285 <xsl:when test="$element='set' or $element='book' or $element='part'"> 286 <xsl:text>titlepage2</xsl:text> 287 </xsl:when> 288 <xsl:otherwise>oneside2</xsl:otherwise> 289 </xsl:choose> 290</xsl:template> 291 292<xsl:template name="select.singlesided.pagemaster"> 293 <xsl:param name="element" select="local-name(.)"/> 294 <xsl:choose> 295 <xsl:when test="$element='set' or $element='book' or $element='part'"> 296 <xsl:text>titlepage1</xsl:text> 297 </xsl:when> 298 <xsl:otherwise>oneside1</xsl:otherwise> 299 </xsl:choose> 300</xsl:template> 301 302<!-- ==================================================================== --> 303 304<xsl:template match="*" mode="running.head.mode"> 305 <xsl:param name="master-name" select="'unknown'"/> 306 <!-- by default, nothing --> 307 <xsl:choose> 308 <xsl:when test="$master-name='titlepage1'"> 309 </xsl:when> 310 <xsl:when test="$master-name='oneside1'"> 311 </xsl:when> 312 <xsl:when test="$master-name='twoside1'"> 313 </xsl:when> 314 <xsl:when test="$master-name='titlepage2'"> 315 </xsl:when> 316 <xsl:when test="$master-name='oneside2'"> 317 </xsl:when> 318 <xsl:when test="$master-name='twoside2'"> 319 </xsl:when> 320 </xsl:choose> 321</xsl:template> 322 323<xsl:template match="chapter|appendix" mode="running.head.mode"> 324 <xsl:param name="master-name" select="'unknown'"/> 325 <xsl:variable name="head"> 326 <fo:block font-size="{$body.font.size}"> 327 <xsl:apply-templates select="." mode="object.title.markup"/> 328 </fo:block> 329 </xsl:variable> 330 331 <xsl:choose> 332 <xsl:when test="$master-name='titlepage1'"></xsl:when> 333 <xsl:when test="$master-name='oneside1'"> 334 <fo:static-content flow-name="xsl-region-before"> 335 <fo:block text-align="center"> 336 <xsl:copy-of select="$head"/> 337 </fo:block> 338 </fo:static-content> 339 </xsl:when> 340 <xsl:when test="$master-name='twoside1'"> 341 <fo:static-content flow-name="xsl-region-before-left"> 342 <fo:block text-align="right"> 343 <xsl:copy-of select="$head"/> 344 </fo:block> 345 </fo:static-content> 346 <fo:static-content flow-name="xsl-region-before-right"> 347 <fo:block text-align="left"> 348 <xsl:copy-of select="$head"/> 349 </fo:block> 350 </fo:static-content> 351 </xsl:when> 352 <xsl:when test="$master-name='titlepage2'"></xsl:when> 353 <xsl:when test="$master-name='oneside2'"> 354 <fo:static-content flow-name="xsl-region-before"> 355 <fo:block text-align="center"> 356 <xsl:copy-of select="$head"/> 357 </fo:block> 358 </fo:static-content> 359 </xsl:when> 360 <xsl:when test="$master-name='twoside2'"> 361 <fo:static-content flow-name="xsl-region-before-left"> 362 <fo:block text-align="right"> 363 <xsl:copy-of select="$head"/> 364 </fo:block> 365 </fo:static-content> 366 <fo:static-content flow-name="xsl-region-before-right"> 367 <fo:block text-align="left"> 368 <xsl:copy-of select="$head"/> 369 </fo:block> 370 </fo:static-content> 371 </xsl:when> 372 </xsl:choose> 373</xsl:template> 374 375<xsl:template match="*" mode="running.foot.mode"> 376 <xsl:param name="master-name" select="'unknown'"/> 377 <xsl:variable name="foot"> 378 <fo:page-number/> 379 </xsl:variable> 380 <!-- by default, the page number --> 381 <xsl:choose> 382 <xsl:when test="$master-name='titlepage1'"></xsl:when> 383 <xsl:when test="$master-name='oneside1'"> 384 <fo:static-content flow-name="xsl-region-after"> 385 <fo:block text-align="center" font-size="{$body.font.size}"> 386 <xsl:copy-of select="$foot"/> 387 </fo:block> 388 </fo:static-content> 389 </xsl:when> 390 <xsl:when test="$master-name='twoside1'"> 391 <fo:static-content flow-name="xsl-region-after-left"> 392 <fo:block text-align="left" font-size="{$body.font.size}"> 393 <xsl:copy-of select="$foot"/> 394 </fo:block> 395 </fo:static-content> 396 <fo:static-content flow-name="xsl-region-after-right"> 397 <fo:block text-align="right" font-size="{$body.font.size}"> 398 <xsl:copy-of select="$foot"/> 399 </fo:block> 400 </fo:static-content> 401 </xsl:when> 402 <xsl:when test="$master-name='titlepage2'"></xsl:when> 403 <xsl:when test="$master-name='oneside2'"> 404 <fo:static-content flow-name="xsl-after-before"> 405 <fo:block text-align="center" font-size="{$body.font.size}"> 406 <xsl:copy-of select="$foot"/> 407 </fo:block> 408 </fo:static-content> 409 </xsl:when> 410 <xsl:when test="$master-name='twoside2'"> 411 <fo:static-content flow-name="xsl-region-after-left"> 412 <fo:block text-align="left" font-size="{$body.font.size}"> 413 <xsl:copy-of select="$foot"/> 414 </fo:block> 415 </fo:static-content> 416 <fo:static-content flow-name="xsl-region-after-right"> 417 <fo:block text-align="right" font-size="{$body.font.size}"> 418 <xsl:copy-of select="$foot"/> 419 </fo:block> 420 </fo:static-content> 421 </xsl:when> 422 </xsl:choose> 423</xsl:template> 424 425<xsl:template match="set|book|part|reference" mode="running.foot.mode"> 426 <!-- nothing --> 427</xsl:template> 428 429<!-- ==================================================================== --> 430 431</xsl:stylesheet> 432