]> git.stg.codes - stg.git/blob - doc/xslt/fo/pagesetup.xsl
All right in GetParamValue and GetPropertyValue
[stg.git] / doc / xslt / fo / pagesetup.xsl
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: pagesetup.xsl 8900 2010-08-29 20:04:32Z dleidert $
8      ********************************************************************
9
10      This file is part of the DocBook XSL Stylesheet distribution.
11      See ../README or http://docbook.sf.net/ for copyright
12      copyright and other information.
13
14      ******************************************************************** -->
15
16 <!-- ==================================================================== -->
17
18 <xsl:param name="body.fontset">
19   <xsl:value-of select="$body.font.family"/>
20   <xsl:if test="$body.font.family != ''
21                 and $symbol.font.family  != ''">,</xsl:if>
22     <xsl:value-of select="$symbol.font.family"/>
23 </xsl:param>
24
25 <xsl:param name="title.fontset">
26   <xsl:value-of select="$title.font.family"/>
27   <xsl:if test="$title.font.family != ''
28                 and $symbol.font.family  != ''">,</xsl:if>
29     <xsl:value-of select="$symbol.font.family"/>
30 </xsl:param>
31
32 <xsl:param name="margin.left.inner">
33   <xsl:choose>
34     <xsl:when test="$passivetex.extensions != 0">
35       <xsl:value-of select="$page.margin.inner"/>
36     </xsl:when>
37     <xsl:otherwise>
38       <xsl:value-of select="$page.margin.inner"/>
39       <xsl:text> - </xsl:text>
40       <xsl:value-of select="$title.margin.left"/>
41     </xsl:otherwise>
42   </xsl:choose>
43 </xsl:param>
44
45 <xsl:template name="setup.pagemasters">
46   <fo:layout-master-set>
47     <!-- blank pages -->
48     <fo:simple-page-master master-name="blank"
49                            page-width="{$page.width}"
50                            page-height="{$page.height}"
51                            margin-top="{$page.margin.top}"
52                            margin-bottom="{$page.margin.bottom}">
53       <xsl:attribute name="margin-{$direction.align.start}">
54         <xsl:value-of select="$page.margin.outer"/>
55         <xsl:if test="$fop.extensions != 0">
56           <xsl:value-of select="concat(' - (',$title.margin.left,')')"/>
57         </xsl:if>
58       </xsl:attribute>
59       <xsl:attribute name="margin-{$direction.align.end}">
60         <xsl:value-of select="$page.margin.inner"/>
61       </xsl:attribute>
62       <xsl:if test="$axf.extensions != 0">
63         <xsl:call-template name="axf-page-master-properties">
64           <xsl:with-param name="page.master">blank</xsl:with-param>
65         </xsl:call-template>
66       </xsl:if>
67       <fo:region-body display-align="center"
68                       margin-bottom="{$body.margin.bottom}"
69                       margin-top="{$body.margin.top}">
70         <xsl:if test="$fop.extensions = 0 and $fop1.extensions = 0">
71           <xsl:attribute name="region-name">blank-body</xsl:attribute>
72         </xsl:if>
73       </fo:region-body>
74       <fo:region-before region-name="xsl-region-before-blank"
75                         extent="{$region.before.extent}"
76                         display-align="before"/>
77       <fo:region-after region-name="xsl-region-after-blank"
78                        extent="{$region.after.extent}"
79                         display-align="after"/>
80     </fo:simple-page-master>
81
82     <!-- title pages -->
83     <fo:simple-page-master master-name="titlepage-first"
84                            page-width="{$page.width}"
85                            page-height="{$page.height}"
86                            margin-top="{$page.margin.top}"
87                            margin-bottom="{$page.margin.bottom}">
88       <xsl:attribute name="margin-{$direction.align.start}">
89         <xsl:value-of select="$page.margin.inner"/>
90         <xsl:if test="$fop.extensions != 0">
91           <xsl:value-of select="concat(' - (',$title.margin.left,')')"/>
92         </xsl:if>
93       </xsl:attribute>
94       <xsl:attribute name="margin-{$direction.align.end}">
95         <xsl:value-of select="$page.margin.outer"/>
96       </xsl:attribute>
97       <xsl:if test="$axf.extensions != 0">
98         <xsl:call-template name="axf-page-master-properties">
99           <xsl:with-param name="page.master">titlepage-first</xsl:with-param>
100         </xsl:call-template>
101       </xsl:if>
102       <fo:region-body margin-bottom="{$body.margin.bottom}"
103                       margin-top="{$body.margin.top}"
104                       column-gap="{$column.gap.titlepage}"
105                       column-count="{$column.count.titlepage}">
106       </fo:region-body>
107       <fo:region-before region-name="xsl-region-before-first"
108                         extent="{$region.before.extent}"
109                         display-align="before"/>
110       <fo:region-after region-name="xsl-region-after-first"
111                        extent="{$region.after.extent}"
112                         display-align="after"/>
113     </fo:simple-page-master>
114
115     <fo:simple-page-master master-name="titlepage-odd"
116                            page-width="{$page.width}"
117                            page-height="{$page.height}"
118                            margin-top="{$page.margin.top}"
119                            margin-bottom="{$page.margin.bottom}">
120       <xsl:attribute name="margin-{$direction.align.start}">
121         <xsl:value-of select="$page.margin.inner"/>
122         <xsl:if test="$fop.extensions != 0">
123           <xsl:value-of select="concat(' - (',$title.margin.left,')')"/>
124         </xsl:if>
125       </xsl:attribute>
126       <xsl:attribute name="margin-{$direction.align.end}">
127         <xsl:value-of select="$page.margin.outer"/>
128       </xsl:attribute>
129       <xsl:if test="$axf.extensions != 0">
130         <xsl:call-template name="axf-page-master-properties">
131           <xsl:with-param name="page.master">titlepage-odd</xsl:with-param>
132         </xsl:call-template>
133       </xsl:if>
134       <fo:region-body margin-bottom="{$body.margin.bottom}"
135                       margin-top="{$body.margin.top}"
136                       column-gap="{$column.gap.titlepage}"
137                       column-count="{$column.count.titlepage}">
138       </fo:region-body>
139       <fo:region-before region-name="xsl-region-before-odd"
140                         extent="{$region.before.extent}"
141                         display-align="before"/>
142       <fo:region-after region-name="xsl-region-after-odd"
143                        extent="{$region.after.extent}"
144                         display-align="after"/>
145     </fo:simple-page-master>
146
147     <fo:simple-page-master master-name="titlepage-even"
148                            page-width="{$page.width}"
149                            page-height="{$page.height}"
150                            margin-top="{$page.margin.top}"
151                            margin-bottom="{$page.margin.bottom}">
152       <xsl:attribute name="margin-{$direction.align.start}">
153         <xsl:value-of select="$page.margin.outer"/>
154         <xsl:if test="$fop.extensions != 0">
155           <xsl:value-of select="concat(' - (',$title.margin.left,')')"/>
156         </xsl:if>
157       </xsl:attribute>
158       <xsl:attribute name="margin-{$direction.align.end}">
159         <xsl:value-of select="$page.margin.inner"/>
160       </xsl:attribute>
161       <xsl:if test="$axf.extensions != 0">
162         <xsl:call-template name="axf-page-master-properties">
163           <xsl:with-param name="page.master">titlepage-even</xsl:with-param>
164         </xsl:call-template>
165       </xsl:if>
166       <fo:region-body margin-bottom="{$body.margin.bottom}"
167                       margin-top="{$body.margin.top}"
168                       column-gap="{$column.gap.titlepage}"
169                       column-count="{$column.count.titlepage}">
170       </fo:region-body>
171       <fo:region-before region-name="xsl-region-before-even"
172                         extent="{$region.before.extent}"
173                         display-align="before"/>
174       <fo:region-after region-name="xsl-region-after-even"
175                        extent="{$region.after.extent}"
176                         display-align="after"/>
177     </fo:simple-page-master>
178
179     <!-- list-of-title pages -->
180     <fo:simple-page-master master-name="lot-first"
181                            page-width="{$page.width}"
182                            page-height="{$page.height}"
183                            margin-top="{$page.margin.top}"
184                            margin-bottom="{$page.margin.bottom}">
185       <xsl:attribute name="margin-{$direction.align.start}">
186         <xsl:value-of select="$page.margin.inner"/>
187         <xsl:if test="$fop.extensions != 0">
188           <xsl:value-of select="concat(' - (',$title.margin.left,')')"/>
189         </xsl:if>
190       </xsl:attribute>
191       <xsl:attribute name="margin-{$direction.align.end}">
192         <xsl:value-of select="$page.margin.outer"/>
193       </xsl:attribute>
194       <xsl:if test="$axf.extensions != 0">
195         <xsl:call-template name="axf-page-master-properties">
196           <xsl:with-param name="page.master">lot-first</xsl:with-param>
197         </xsl:call-template>
198       </xsl:if>
199       <fo:region-body margin-bottom="{$body.margin.bottom}"
200                       margin-top="{$body.margin.top}"
201                       column-gap="{$column.gap.lot}"
202                       column-count="{$column.count.lot}">
203       </fo:region-body>
204       <fo:region-before region-name="xsl-region-before-first"
205                         extent="{$region.before.extent}"
206                         display-align="before"/>
207       <fo:region-after region-name="xsl-region-after-first"
208                        extent="{$region.after.extent}"
209                        display-align="after"/>
210     </fo:simple-page-master>
211
212     <fo:simple-page-master master-name="lot-odd"
213                            page-width="{$page.width}"
214                            page-height="{$page.height}"
215                            margin-top="{$page.margin.top}"
216                            margin-bottom="{$page.margin.bottom}">
217       <xsl:attribute name="margin-{$direction.align.start}">
218         <xsl:value-of select="$page.margin.inner"/>
219         <xsl:if test="$fop.extensions != 0">
220           <xsl:value-of select="concat(' - (',$title.margin.left,')')"/>
221         </xsl:if>
222       </xsl:attribute>
223       <xsl:attribute name="margin-{$direction.align.end}">
224         <xsl:value-of select="$page.margin.outer"/>
225       </xsl:attribute>
226       <xsl:if test="$axf.extensions != 0">
227         <xsl:call-template name="axf-page-master-properties">
228           <xsl:with-param name="page.master">lot-odd</xsl:with-param>
229         </xsl:call-template>
230       </xsl:if>
231       <fo:region-body margin-bottom="{$body.margin.bottom}"
232                       margin-top="{$body.margin.top}"
233                       column-gap="{$column.gap.lot}"
234                       column-count="{$column.count.lot}">
235       </fo:region-body>
236       <fo:region-before region-name="xsl-region-before-odd"
237                         extent="{$region.before.extent}"
238                         display-align="before"/>
239       <fo:region-after region-name="xsl-region-after-odd"
240                        extent="{$region.after.extent}"
241                         display-align="after"/>
242     </fo:simple-page-master>
243
244     <fo:simple-page-master master-name="lot-even"
245                            page-width="{$page.width}"
246                            page-height="{$page.height}"
247                            margin-top="{$page.margin.top}"
248                            margin-bottom="{$page.margin.bottom}">
249       <xsl:attribute name="margin-{$direction.align.start}">
250         <xsl:value-of select="$page.margin.outer"/>
251         <xsl:if test="$fop.extensions != 0">
252           <xsl:value-of select="concat(' - (',$title.margin.left,')')"/>
253         </xsl:if>
254       </xsl:attribute>
255       <xsl:attribute name="margin-{$direction.align.end}">
256         <xsl:value-of select="$page.margin.inner"/>
257       </xsl:attribute>
258       <xsl:if test="$axf.extensions != 0">
259         <xsl:call-template name="axf-page-master-properties">
260           <xsl:with-param name="page.master">lot-even</xsl:with-param>
261         </xsl:call-template>
262       </xsl:if>
263       <fo:region-body margin-bottom="{$body.margin.bottom}"
264                       margin-top="{$body.margin.top}"
265                       column-gap="{$column.gap.lot}"
266                       column-count="{$column.count.lot}">
267       </fo:region-body>
268       <fo:region-before region-name="xsl-region-before-even"
269                         extent="{$region.before.extent}"
270                         display-align="before"/>
271       <fo:region-after region-name="xsl-region-after-even"
272                        extent="{$region.after.extent}"
273                         display-align="after"/>
274     </fo:simple-page-master>
275
276     <!-- frontmatter pages -->
277     <fo:simple-page-master master-name="front-first"
278                            page-width="{$page.width}"
279                            page-height="{$page.height}"
280                            margin-top="{$page.margin.top}"
281                            margin-bottom="{$page.margin.bottom}">
282       <xsl:attribute name="margin-{$direction.align.start}">
283         <xsl:value-of select="$page.margin.inner"/>
284         <xsl:if test="$fop.extensions != 0">
285           <xsl:value-of select="concat(' - (',$title.margin.left,')')"/>
286         </xsl:if>
287       </xsl:attribute>
288       <xsl:attribute name="margin-{$direction.align.end}">
289         <xsl:value-of select="$page.margin.outer"/>
290       </xsl:attribute>
291       <xsl:if test="$axf.extensions != 0">
292         <xsl:call-template name="axf-page-master-properties">
293           <xsl:with-param name="page.master">front-first</xsl:with-param>
294         </xsl:call-template>
295       </xsl:if>
296       <fo:region-body margin-bottom="{$body.margin.bottom}"
297                       margin-top="{$body.margin.top}"
298                       column-gap="{$column.gap.front}"
299                       column-count="{$column.count.front}">
300       </fo:region-body>
301       <fo:region-before region-name="xsl-region-before-first"
302                         extent="{$region.before.extent}"
303                         display-align="before"/>
304       <fo:region-after region-name="xsl-region-after-first"
305                        extent="{$region.after.extent}"
306                         display-align="after"/>
307     </fo:simple-page-master>
308
309     <fo:simple-page-master master-name="front-odd"
310                            page-width="{$page.width}"
311                            page-height="{$page.height}"
312                            margin-top="{$page.margin.top}"
313                            margin-bottom="{$page.margin.bottom}">
314       <xsl:attribute name="margin-{$direction.align.start}">
315         <xsl:value-of select="$page.margin.inner"/>
316         <xsl:if test="$fop.extensions != 0">
317           <xsl:value-of select="concat(' - (',$title.margin.left,')')"/>
318         </xsl:if>
319       </xsl:attribute>
320       <xsl:attribute name="margin-{$direction.align.end}">
321         <xsl:value-of select="$page.margin.outer"/>
322       </xsl:attribute>
323       <xsl:if test="$axf.extensions != 0">
324         <xsl:call-template name="axf-page-master-properties">
325           <xsl:with-param name="page.master">front-odd</xsl:with-param>
326         </xsl:call-template>
327       </xsl:if>
328       <fo:region-body margin-bottom="{$body.margin.bottom}"
329                       margin-top="{$body.margin.top}"
330                       column-gap="{$column.gap.front}"
331                       column-count="{$column.count.front}">
332       </fo:region-body>
333       <fo:region-before region-name="xsl-region-before-odd"
334                         extent="{$region.before.extent}"
335                         display-align="before"/>
336       <fo:region-after region-name="xsl-region-after-odd"
337                        extent="{$region.after.extent}"
338                         display-align="after"/>
339     </fo:simple-page-master>
340
341     <fo:simple-page-master master-name="front-even"
342                            page-width="{$page.width}"
343                            page-height="{$page.height}"
344                            margin-top="{$page.margin.top}"
345                            margin-bottom="{$page.margin.bottom}">
346       <xsl:attribute name="margin-{$direction.align.start}">
347         <xsl:value-of select="$page.margin.outer"/>
348         <xsl:if test="$fop.extensions != 0">
349           <xsl:value-of select="concat(' - (',$title.margin.left,')')"/>
350         </xsl:if>
351       </xsl:attribute>
352       <xsl:attribute name="margin-{$direction.align.end}">
353         <xsl:value-of select="$page.margin.inner"/>
354       </xsl:attribute>
355       <xsl:if test="$axf.extensions != 0">
356         <xsl:call-template name="axf-page-master-properties">
357           <xsl:with-param name="page.master">front-even</xsl:with-param>
358         </xsl:call-template>
359       </xsl:if>
360       <fo:region-body margin-bottom="{$body.margin.bottom}"
361                       margin-top="{$body.margin.top}"
362                       column-gap="{$column.gap.front}"
363                       column-count="{$column.count.front}">
364       </fo:region-body>
365       <fo:region-before region-name="xsl-region-before-even"
366                         extent="{$region.before.extent}"
367                         display-align="before"/>
368       <fo:region-after region-name="xsl-region-after-even"
369                        extent="{$region.after.extent}"
370                         display-align="after"/>
371     </fo:simple-page-master>
372
373     <!-- body pages -->
374     <fo:simple-page-master master-name="body-first"
375                            page-width="{$page.width}"
376                            page-height="{$page.height}"
377                            margin-top="{$page.margin.top}"
378                            margin-bottom="{$page.margin.bottom}">
379       <xsl:attribute name="margin-{$direction.align.start}">
380         <xsl:value-of select="$page.margin.inner"/>
381         <xsl:if test="$fop.extensions != 0">
382           <xsl:value-of select="concat(' - (',$title.margin.left,')')"/>
383         </xsl:if>
384         <xsl:if test="$fop.extensions != 0">
385           <xsl:value-of select="concat(' - (',$title.margin.left,')')"/>
386         </xsl:if>
387       </xsl:attribute>
388       <xsl:attribute name="margin-{$direction.align.end}">
389         <xsl:value-of select="$page.margin.outer"/>
390       </xsl:attribute>
391       <xsl:if test="$axf.extensions != 0">
392         <xsl:call-template name="axf-page-master-properties">
393           <xsl:with-param name="page.master">body-first</xsl:with-param>
394         </xsl:call-template>
395       </xsl:if>
396       <fo:region-body margin-bottom="{$body.margin.bottom}"
397                       margin-top="{$body.margin.top}"
398                       column-gap="{$column.gap.body}"
399                       column-count="{$column.count.body}">
400       </fo:region-body>
401       <fo:region-before region-name="xsl-region-before-first"
402                         extent="{$region.before.extent}"
403                         display-align="before"/>
404       <fo:region-after region-name="xsl-region-after-first"
405                        extent="{$region.after.extent}"
406                        display-align="after"/>
407     </fo:simple-page-master>
408
409     <fo:simple-page-master master-name="body-odd"
410                            page-width="{$page.width}"
411                            page-height="{$page.height}"
412                            margin-top="{$page.margin.top}"
413                            margin-bottom="{$page.margin.bottom}">
414       <xsl:attribute name="margin-{$direction.align.start}">
415         <xsl:value-of select="$page.margin.inner"/>
416         <xsl:if test="$fop.extensions != 0">
417           <xsl:value-of select="concat(' - (',$title.margin.left,')')"/>
418         </xsl:if>
419       </xsl:attribute>
420       <xsl:attribute name="margin-{$direction.align.end}">
421         <xsl:value-of select="$page.margin.outer"/>
422       </xsl:attribute>
423       <xsl:if test="$axf.extensions != 0">
424         <xsl:call-template name="axf-page-master-properties">
425           <xsl:with-param name="page.master">body-odd</xsl:with-param>
426         </xsl:call-template>
427       </xsl:if>
428       <fo:region-body margin-bottom="{$body.margin.bottom}"
429                       margin-top="{$body.margin.top}"
430                       column-gap="{$column.gap.body}"
431                       column-count="{$column.count.body}">
432       </fo:region-body>
433       <fo:region-before region-name="xsl-region-before-odd"
434                         extent="{$region.before.extent}"
435                         display-align="before"/>
436       <fo:region-after region-name="xsl-region-after-odd"
437                        extent="{$region.after.extent}"
438                        display-align="after"/>
439     </fo:simple-page-master>
440
441     <fo:simple-page-master master-name="body-even"
442                            page-width="{$page.width}"
443                            page-height="{$page.height}"
444                            margin-top="{$page.margin.top}"
445                            margin-bottom="{$page.margin.bottom}">
446       <xsl:attribute name="margin-{$direction.align.start}">
447         <xsl:value-of select="$page.margin.outer"/>
448         <xsl:if test="$fop.extensions != 0">
449           <xsl:value-of select="concat(' - (',$title.margin.left,')')"/>
450         </xsl:if>
451       </xsl:attribute>
452       <xsl:attribute name="margin-{$direction.align.end}">
453         <xsl:value-of select="$page.margin.inner"/>
454       </xsl:attribute>
455       <xsl:if test="$axf.extensions != 0">
456         <xsl:call-template name="axf-page-master-properties">
457           <xsl:with-param name="page.master">body-even</xsl:with-param>
458         </xsl:call-template>
459       </xsl:if>
460       <fo:region-body margin-bottom="{$body.margin.bottom}"
461                       margin-top="{$body.margin.top}"
462                       column-gap="{$column.gap.body}"
463                       column-count="{$column.count.body}">
464       </fo:region-body>
465       <fo:region-before region-name="xsl-region-before-even"
466                         extent="{$region.before.extent}"
467                         display-align="before"/>
468       <fo:region-after region-name="xsl-region-after-even"
469                        extent="{$region.after.extent}"
470                        display-align="after"/>
471     </fo:simple-page-master>
472
473     <!-- backmatter pages -->
474     <fo:simple-page-master master-name="back-first"
475                            page-width="{$page.width}"
476                            page-height="{$page.height}"
477                            margin-top="{$page.margin.top}"
478                            margin-bottom="{$page.margin.bottom}">
479       <xsl:attribute name="margin-{$direction.align.start}">
480         <xsl:value-of select="$page.margin.inner"/>
481         <xsl:if test="$fop.extensions != 0">
482           <xsl:value-of select="concat(' - (',$title.margin.left,')')"/>
483         </xsl:if>
484       </xsl:attribute>
485       <xsl:attribute name="margin-{$direction.align.end}">
486         <xsl:value-of select="$page.margin.outer"/>
487       </xsl:attribute>
488       <xsl:if test="$axf.extensions != 0">
489         <xsl:call-template name="axf-page-master-properties">
490           <xsl:with-param name="page.master">back-first</xsl:with-param>
491         </xsl:call-template>
492       </xsl:if>
493       <fo:region-body margin-bottom="{$body.margin.bottom}"
494                       margin-top="{$body.margin.top}"
495                       column-gap="{$column.gap.back}"
496                       column-count="{$column.count.back}">
497       </fo:region-body>
498       <fo:region-before region-name="xsl-region-before-first"
499                         extent="{$region.before.extent}"
500                         display-align="before"/>
501       <fo:region-after region-name="xsl-region-after-first"
502                        extent="{$region.after.extent}"
503                        display-align="after"/>
504     </fo:simple-page-master>
505
506     <fo:simple-page-master master-name="back-odd"
507                            page-width="{$page.width}"
508                            page-height="{$page.height}"
509                            margin-top="{$page.margin.top}"
510                            margin-bottom="{$page.margin.bottom}">
511       <xsl:attribute name="margin-{$direction.align.start}">
512         <xsl:value-of select="$page.margin.inner"/>
513         <xsl:if test="$fop.extensions != 0">
514           <xsl:value-of select="concat(' - (',$title.margin.left,')')"/>
515         </xsl:if>
516       </xsl:attribute>
517       <xsl:attribute name="margin-{$direction.align.end}">
518         <xsl:value-of select="$page.margin.outer"/>
519       </xsl:attribute>
520       <xsl:if test="$axf.extensions != 0">
521         <xsl:call-template name="axf-page-master-properties">
522           <xsl:with-param name="page.master">back-odd</xsl:with-param>
523         </xsl:call-template>
524       </xsl:if>
525       <fo:region-body margin-bottom="{$body.margin.bottom}"
526                       margin-top="{$body.margin.top}"
527                       column-gap="{$column.gap.back}"
528                       column-count="{$column.count.back}">
529       </fo:region-body>
530       <fo:region-before region-name="xsl-region-before-odd"
531                         extent="{$region.before.extent}"
532                         display-align="before"/>
533       <fo:region-after region-name="xsl-region-after-odd"
534                        extent="{$region.after.extent}"
535                        display-align="after"/>
536     </fo:simple-page-master>
537
538     <fo:simple-page-master master-name="back-even"
539                            page-width="{$page.width}"
540                            page-height="{$page.height}"
541                            margin-top="{$page.margin.top}"
542                            margin-bottom="{$page.margin.bottom}">
543       <xsl:attribute name="margin-{$direction.align.start}">
544         <xsl:value-of select="$page.margin.outer"/>
545         <xsl:if test="$fop.extensions != 0">
546           <xsl:value-of select="concat(' - (',$title.margin.left,')')"/>
547         </xsl:if>
548       </xsl:attribute>
549       <xsl:attribute name="margin-{$direction.align.end}">
550         <xsl:value-of select="$page.margin.inner"/>
551       </xsl:attribute>
552       <xsl:if test="$axf.extensions != 0">
553         <xsl:call-template name="axf-page-master-properties">
554           <xsl:with-param name="page.master">back-even</xsl:with-param>
555         </xsl:call-template>
556       </xsl:if>
557       <fo:region-body margin-bottom="{$body.margin.bottom}"
558                       margin-top="{$body.margin.top}"
559                       column-gap="{$column.gap.back}"
560                       column-count="{$column.count.back}">
561       </fo:region-body>
562       <fo:region-before region-name="xsl-region-before-even"
563                         extent="{$region.before.extent}"
564                         display-align="before"/>
565       <fo:region-after region-name="xsl-region-after-even"
566                        extent="{$region.after.extent}"
567                        display-align="after"/>
568     </fo:simple-page-master>
569
570     <!-- index pages -->
571     <fo:simple-page-master master-name="index-first"
572                            page-width="{$page.width}"
573                            page-height="{$page.height}"
574                            margin-top="{$page.margin.top}"
575                            margin-bottom="{$page.margin.bottom}">
576       <xsl:attribute name="margin-{$direction.align.start}">
577         <xsl:value-of select="$page.margin.inner"/>
578         <xsl:if test="$fop.extensions != 0">
579           <xsl:value-of select="concat(' - (',$title.margin.left,')')"/>
580         </xsl:if>
581       </xsl:attribute>
582       <xsl:attribute name="margin-{$direction.align.end}">
583         <xsl:value-of select="$page.margin.outer"/>
584       </xsl:attribute>
585       <xsl:if test="$axf.extensions != 0">
586         <xsl:call-template name="axf-page-master-properties">
587           <xsl:with-param name="page.master">index-first</xsl:with-param>
588         </xsl:call-template>
589       </xsl:if>
590       <fo:region-body margin-bottom="{$body.margin.bottom}"
591                       margin-top="{$body.margin.top}"
592                       column-gap="{$column.gap.index}"
593                       column-count="{$column.count.index}">
594       </fo:region-body>
595       <fo:region-before region-name="xsl-region-before-first"
596                         extent="{$region.before.extent}"
597                         display-align="before"/>
598       <fo:region-after region-name="xsl-region-after-first"
599                        extent="{$region.after.extent}"
600                        display-align="after"/>
601     </fo:simple-page-master>
602
603     <fo:simple-page-master master-name="index-odd"
604                            page-width="{$page.width}"
605                            page-height="{$page.height}"
606                            margin-top="{$page.margin.top}"
607                            margin-bottom="{$page.margin.bottom}">
608       <xsl:attribute name="margin-{$direction.align.start}">
609         <xsl:value-of select="$page.margin.inner"/>
610         <xsl:if test="$fop.extensions != 0">
611           <xsl:value-of select="concat(' - (',$title.margin.left,')')"/>
612         </xsl:if>
613       </xsl:attribute>
614       <xsl:attribute name="margin-{$direction.align.end}">
615         <xsl:value-of select="$page.margin.outer"/>
616       </xsl:attribute>
617       <xsl:if test="$axf.extensions != 0">
618         <xsl:call-template name="axf-page-master-properties">
619           <xsl:with-param name="page.master">index-odd</xsl:with-param>
620         </xsl:call-template>
621       </xsl:if>
622       <fo:region-body margin-bottom="{$body.margin.bottom}"
623                       margin-top="{$body.margin.top}"
624                       column-gap="{$column.gap.index}"
625                       column-count="{$column.count.index}">
626       </fo:region-body>
627       <fo:region-before region-name="xsl-region-before-odd"
628                         extent="{$region.before.extent}"
629                         display-align="before"/>
630       <fo:region-after region-name="xsl-region-after-odd"
631                        extent="{$region.after.extent}"
632                        display-align="after"/>
633     </fo:simple-page-master>
634
635     <fo:simple-page-master master-name="index-even"
636                            page-width="{$page.width}"
637                            page-height="{$page.height}"
638                            margin-top="{$page.margin.top}"
639                            margin-bottom="{$page.margin.bottom}">
640       <xsl:attribute name="margin-{$direction.align.start}">
641         <xsl:value-of select="$page.margin.outer"/>
642         <xsl:if test="$fop.extensions != 0">
643           <xsl:value-of select="concat(' - (',$title.margin.left,')')"/>
644         </xsl:if>
645       </xsl:attribute>
646       <xsl:attribute name="margin-{$direction.align.end}">
647         <xsl:value-of select="$page.margin.inner"/>
648       </xsl:attribute>
649       <xsl:if test="$axf.extensions != 0">
650         <xsl:call-template name="axf-page-master-properties">
651           <xsl:with-param name="page.master">index-even</xsl:with-param>
652         </xsl:call-template>
653       </xsl:if>
654       <fo:region-body margin-bottom="{$body.margin.bottom}"
655                       margin-top="{$body.margin.top}"
656                       column-gap="{$column.gap.index}"
657                       column-count="{$column.count.index}">
658       </fo:region-body>
659       <fo:region-before region-name="xsl-region-before-even"
660                         extent="{$region.before.extent}"
661                         display-align="before"/>
662       <fo:region-after region-name="xsl-region-after-even"
663                        extent="{$region.after.extent}"
664                        display-align="after"/>
665     </fo:simple-page-master>
666
667     <xsl:if test="$draft.mode != 'no'">
668       <!-- draft blank pages -->
669       <fo:simple-page-master master-name="blank-draft"
670                              page-width="{$page.width}"
671                              page-height="{$page.height}"
672                              margin-top="{$page.margin.top}"
673                              margin-bottom="{$page.margin.bottom}">
674         <xsl:attribute name="margin-{$direction.align.start}">
675           <xsl:value-of select="$page.margin.outer"/>
676           <xsl:if test="$fop.extensions != 0">
677             <xsl:value-of select="concat(' - (',$title.margin.left,')')"/>
678           </xsl:if>
679         </xsl:attribute>
680         <xsl:attribute name="margin-{$direction.align.end}">
681           <xsl:value-of select="$page.margin.inner"/>
682         </xsl:attribute>
683         <xsl:if test="$axf.extensions != 0">
684           <xsl:call-template name="axf-page-master-properties">
685             <xsl:with-param name="page.master">blank-draft</xsl:with-param>
686           </xsl:call-template>
687         </xsl:if>
688         <fo:region-body margin-bottom="{$body.margin.bottom}"
689                         margin-top="{$body.margin.top}">
690           <xsl:if test="$draft.watermark.image != ''">
691             <xsl:attribute name="background-image">
692               <xsl:call-template name="fo-external-image">
693                 <xsl:with-param name="filename" select="$draft.watermark.image"/>
694               </xsl:call-template>
695             </xsl:attribute>
696             <xsl:attribute name="background-attachment">fixed</xsl:attribute>
697             <xsl:attribute name="background-repeat">no-repeat</xsl:attribute>
698             <xsl:attribute name="background-position-horizontal">center</xsl:attribute>
699             <xsl:attribute name="background-position-vertical">center</xsl:attribute>
700           </xsl:if>
701         </fo:region-body>
702         <fo:region-before region-name="xsl-region-before-blank"
703                           extent="{$region.before.extent}"
704                           display-align="before"/>
705         <fo:region-after region-name="xsl-region-after-blank"
706                          extent="{$region.after.extent}"
707                          display-align="after"/>
708       </fo:simple-page-master>
709
710       <!-- draft title pages -->
711       <fo:simple-page-master master-name="titlepage-first-draft"
712                              page-width="{$page.width}"
713                              page-height="{$page.height}"
714                              margin-top="{$page.margin.top}"
715                              margin-bottom="{$page.margin.bottom}">
716         <xsl:attribute name="margin-{$direction.align.start}">
717           <xsl:value-of select="$page.margin.inner"/>
718           <xsl:if test="$fop.extensions != 0">
719             <xsl:value-of select="concat(' - (',$title.margin.left,')')"/>
720           </xsl:if>
721         </xsl:attribute>
722         <xsl:attribute name="margin-{$direction.align.end}">
723           <xsl:value-of select="$page.margin.outer"/>
724         </xsl:attribute>
725         <xsl:if test="$axf.extensions != 0">
726           <xsl:call-template name="axf-page-master-properties">
727             <xsl:with-param name="page.master">titlepage-first-draft</xsl:with-param>
728           </xsl:call-template>
729         </xsl:if>
730         <fo:region-body margin-bottom="{$body.margin.bottom}"
731                         margin-top="{$body.margin.top}"
732                         column-gap="{$column.gap.titlepage}"
733                         column-count="{$column.count.titlepage}">
734           <xsl:if test="$draft.watermark.image != ''">
735             <xsl:attribute name="background-image">
736               <xsl:call-template name="fo-external-image">
737                 <xsl:with-param name="filename" select="$draft.watermark.image"/>
738               </xsl:call-template>
739             </xsl:attribute>
740             <xsl:attribute name="background-attachment">fixed</xsl:attribute>
741             <xsl:attribute name="background-repeat">no-repeat</xsl:attribute>
742             <xsl:attribute name="background-position-horizontal">center</xsl:attribute>
743             <xsl:attribute name="background-position-vertical">center</xsl:attribute>
744           </xsl:if>
745         </fo:region-body>
746         <fo:region-before region-name="xsl-region-before-first"
747                           extent="{$region.before.extent}"
748                           display-align="before"/>
749         <fo:region-after region-name="xsl-region-after-first"
750                          extent="{$region.after.extent}"
751                          display-align="after"/>
752       </fo:simple-page-master>
753
754       <fo:simple-page-master master-name="titlepage-odd-draft"
755                              page-width="{$page.width}"
756                              page-height="{$page.height}"
757                              margin-top="{$page.margin.top}"
758                              margin-bottom="{$page.margin.bottom}">
759         <xsl:attribute name="margin-{$direction.align.start}">
760           <xsl:value-of select="$page.margin.inner"/>
761           <xsl:if test="$fop.extensions != 0">
762             <xsl:value-of select="concat(' - (',$title.margin.left,')')"/>
763           </xsl:if>
764         </xsl:attribute>
765         <xsl:attribute name="margin-{$direction.align.end}">
766           <xsl:value-of select="$page.margin.outer"/>
767         </xsl:attribute>
768         <xsl:if test="$axf.extensions != 0">
769           <xsl:call-template name="axf-page-master-properties">
770             <xsl:with-param name="page.master">titlepage-odd-draft</xsl:with-param>
771           </xsl:call-template>
772         </xsl:if>
773         <fo:region-body margin-bottom="{$body.margin.bottom}"
774                         margin-top="{$body.margin.top}"
775                         column-gap="{$column.gap.titlepage}"
776                         column-count="{$column.count.titlepage}">
777           <xsl:if test="$draft.watermark.image != ''">
778             <xsl:attribute name="background-image">
779               <xsl:call-template name="fo-external-image">
780                 <xsl:with-param name="filename" select="$draft.watermark.image"/>
781               </xsl:call-template>
782             </xsl:attribute>
783             <xsl:attribute name="background-attachment">fixed</xsl:attribute>
784             <xsl:attribute name="background-repeat">no-repeat</xsl:attribute>
785             <xsl:attribute name="background-position-horizontal">center</xsl:attribute>
786             <xsl:attribute name="background-position-vertical">center</xsl:attribute>
787           </xsl:if>
788         </fo:region-body>
789         <fo:region-before region-name="xsl-region-before-odd"
790                           extent="{$region.before.extent}"
791                           display-align="before"/>
792         <fo:region-after region-name="xsl-region-after-odd"
793                          extent="{$region.after.extent}"
794                          display-align="after"/>
795       </fo:simple-page-master>
796
797       <fo:simple-page-master master-name="titlepage-even-draft"
798                              page-width="{$page.width}"
799                              page-height="{$page.height}"
800                              margin-top="{$page.margin.top}"
801                              margin-bottom="{$page.margin.bottom}">
802         <xsl:attribute name="margin-{$direction.align.start}">
803           <xsl:value-of select="$page.margin.outer"/>
804           <xsl:if test="$fop.extensions != 0">
805             <xsl:value-of select="concat(' - (',$title.margin.left,')')"/>
806           </xsl:if>
807         </xsl:attribute>
808         <xsl:attribute name="margin-{$direction.align.end}">
809           <xsl:value-of select="$page.margin.inner"/>
810         </xsl:attribute>
811         <xsl:if test="$axf.extensions != 0">
812           <xsl:call-template name="axf-page-master-properties">
813             <xsl:with-param name="page.master">titlepage-even-draft</xsl:with-param>
814           </xsl:call-template>
815         </xsl:if>
816         <fo:region-body margin-bottom="{$body.margin.bottom}"
817                         margin-top="{$body.margin.top}"
818                         column-gap="{$column.gap.titlepage}"
819                         column-count="{$column.count.titlepage}">
820           <xsl:if test="$draft.watermark.image != ''">
821             <xsl:attribute name="background-image">
822               <xsl:call-template name="fo-external-image">
823                 <xsl:with-param name="filename" select="$draft.watermark.image"/>
824               </xsl:call-template>
825             </xsl:attribute>
826             <xsl:attribute name="background-attachment">fixed</xsl:attribute>
827             <xsl:attribute name="background-repeat">no-repeat</xsl:attribute>
828             <xsl:attribute name="background-position-horizontal">center</xsl:attribute>
829             <xsl:attribute name="background-position-vertical">center</xsl:attribute>
830           </xsl:if>
831         </fo:region-body>
832         <fo:region-before region-name="xsl-region-before-even"
833                           extent="{$region.before.extent}"
834                           display-align="before"/>
835         <fo:region-after region-name="xsl-region-after-even"
836                          extent="{$region.after.extent}"
837                          display-align="after"/>
838       </fo:simple-page-master>
839
840       <!-- draft list-of-title pages -->
841       <fo:simple-page-master master-name="lot-first-draft"
842                              page-width="{$page.width}"
843                              page-height="{$page.height}"
844                              margin-top="{$page.margin.top}"
845                              margin-bottom="{$page.margin.bottom}">
846         <xsl:attribute name="margin-{$direction.align.start}">
847           <xsl:value-of select="$page.margin.inner"/>
848           <xsl:if test="$fop.extensions != 0">
849             <xsl:value-of select="concat(' - (',$title.margin.left,')')"/>
850           </xsl:if>
851         </xsl:attribute>
852         <xsl:attribute name="margin-{$direction.align.end}">
853           <xsl:value-of select="$page.margin.outer"/>
854         </xsl:attribute>
855         <xsl:if test="$axf.extensions != 0">
856           <xsl:call-template name="axf-page-master-properties">
857             <xsl:with-param name="page.master">lot-first-draft</xsl:with-param>
858           </xsl:call-template>
859         </xsl:if>
860         <fo:region-body margin-bottom="{$body.margin.bottom}"
861                         margin-top="{$body.margin.top}"
862                         column-gap="{$column.gap.lot}"
863                         column-count="{$column.count.lot}">
864           <xsl:if test="$draft.watermark.image != ''">
865             <xsl:attribute name="background-image">
866               <xsl:call-template name="fo-external-image">
867                 <xsl:with-param name="filename" select="$draft.watermark.image"/>
868               </xsl:call-template>
869             </xsl:attribute>
870             <xsl:attribute name="background-attachment">fixed</xsl:attribute>
871             <xsl:attribute name="background-repeat">no-repeat</xsl:attribute>
872             <xsl:attribute name="background-position-horizontal">center</xsl:attribute>
873             <xsl:attribute name="background-position-vertical">center</xsl:attribute>
874           </xsl:if>
875         </fo:region-body>
876         <fo:region-before region-name="xsl-region-before-first"
877                           extent="{$region.before.extent}"
878                           display-align="before"/>
879         <fo:region-after region-name="xsl-region-after-first"
880                          extent="{$region.after.extent}"
881                          display-align="after"/>
882       </fo:simple-page-master>
883
884       <fo:simple-page-master master-name="lot-odd-draft"
885                              page-width="{$page.width}"
886                              page-height="{$page.height}"
887                              margin-top="{$page.margin.top}"
888                              margin-bottom="{$page.margin.bottom}">
889         <xsl:attribute name="margin-{$direction.align.start}">
890           <xsl:value-of select="$page.margin.inner"/>
891           <xsl:if test="$fop.extensions != 0">
892             <xsl:value-of select="concat(' - (',$title.margin.left,')')"/>
893           </xsl:if>
894         </xsl:attribute>
895         <xsl:attribute name="margin-{$direction.align.end}">
896           <xsl:value-of select="$page.margin.outer"/>
897         </xsl:attribute>
898         <xsl:if test="$axf.extensions != 0">
899           <xsl:call-template name="axf-page-master-properties">
900             <xsl:with-param name="page.master">lot-odd-draft</xsl:with-param>
901           </xsl:call-template>
902         </xsl:if>
903         <fo:region-body margin-bottom="{$body.margin.bottom}"
904                         margin-top="{$body.margin.top}"
905                         column-gap="{$column.gap.lot}"
906                         column-count="{$column.count.lot}">
907           <xsl:if test="$draft.watermark.image != ''">
908             <xsl:attribute name="background-image">
909               <xsl:call-template name="fo-external-image">
910                 <xsl:with-param name="filename" select="$draft.watermark.image"/>
911               </xsl:call-template>
912             </xsl:attribute>
913             <xsl:attribute name="background-attachment">fixed</xsl:attribute>
914             <xsl:attribute name="background-repeat">no-repeat</xsl:attribute>
915             <xsl:attribute name="background-position-horizontal">center</xsl:attribute>
916             <xsl:attribute name="background-position-vertical">center</xsl:attribute>
917           </xsl:if>
918         </fo:region-body>
919         <fo:region-before region-name="xsl-region-before-odd"
920                           extent="{$region.before.extent}"
921                           display-align="before"/>
922         <fo:region-after region-name="xsl-region-after-odd"
923                          extent="{$region.after.extent}"
924                          display-align="after"/>
925       </fo:simple-page-master>
926
927       <fo:simple-page-master master-name="lot-even-draft"
928                              page-width="{$page.width}"
929                              page-height="{$page.height}"
930                              margin-top="{$page.margin.top}"
931                              margin-bottom="{$page.margin.bottom}">
932         <xsl:attribute name="margin-{$direction.align.start}">
933           <xsl:value-of select="$page.margin.outer"/>
934           <xsl:if test="$fop.extensions != 0">
935             <xsl:value-of select="concat(' - (',$title.margin.left,')')"/>
936           </xsl:if>
937         </xsl:attribute>
938         <xsl:attribute name="margin-{$direction.align.end}">
939           <xsl:value-of select="$page.margin.inner"/>
940         </xsl:attribute>
941         <xsl:if test="$axf.extensions != 0">
942           <xsl:call-template name="axf-page-master-properties">
943             <xsl:with-param name="page.master">lot-even-draft</xsl:with-param>
944           </xsl:call-template>
945         </xsl:if>
946         <fo:region-body margin-bottom="{$body.margin.bottom}"
947                         margin-top="{$body.margin.top}"
948                         column-gap="{$column.gap.lot}"
949                         column-count="{$column.count.lot}">
950           <xsl:if test="$draft.watermark.image != ''">
951             <xsl:attribute name="background-image">
952               <xsl:call-template name="fo-external-image">
953                 <xsl:with-param name="filename" select="$draft.watermark.image"/>
954               </xsl:call-template>
955             </xsl:attribute>
956             <xsl:attribute name="background-attachment">fixed</xsl:attribute>
957             <xsl:attribute name="background-repeat">no-repeat</xsl:attribute>
958             <xsl:attribute name="background-position-horizontal">center</xsl:attribute>
959             <xsl:attribute name="background-position-vertical">center</xsl:attribute>
960           </xsl:if>
961         </fo:region-body>
962         <fo:region-before region-name="xsl-region-before-even"
963                           extent="{$region.before.extent}"
964                           display-align="before"/>
965         <fo:region-after region-name="xsl-region-after-even"
966                          extent="{$region.after.extent}"
967                          display-align="after"/>
968       </fo:simple-page-master>
969
970       <!-- draft frontmatter pages -->
971       <fo:simple-page-master master-name="front-first-draft"
972                              page-width="{$page.width}"
973                              page-height="{$page.height}"
974                              margin-top="{$page.margin.top}"
975                              margin-bottom="{$page.margin.bottom}">
976         <xsl:attribute name="margin-{$direction.align.start}">
977           <xsl:value-of select="$page.margin.inner"/>
978           <xsl:if test="$fop.extensions != 0">
979             <xsl:value-of select="concat(' - (',$title.margin.left,')')"/>
980           </xsl:if>
981         </xsl:attribute>
982         <xsl:attribute name="margin-{$direction.align.end}">
983           <xsl:value-of select="$page.margin.outer"/>
984         </xsl:attribute>
985         <xsl:if test="$axf.extensions != 0">
986           <xsl:call-template name="axf-page-master-properties">
987             <xsl:with-param name="page.master">front-first-draft</xsl:with-param>
988           </xsl:call-template>
989         </xsl:if>
990         <fo:region-body margin-bottom="{$body.margin.bottom}"
991                         margin-top="{$body.margin.top}"
992                         column-gap="{$column.gap.front}"
993                         column-count="{$column.count.front}">
994           <xsl:if test="$draft.watermark.image != ''">
995             <xsl:attribute name="background-image">
996               <xsl:call-template name="fo-external-image">
997                 <xsl:with-param name="filename" select="$draft.watermark.image"/>
998               </xsl:call-template>
999             </xsl:attribute>
1000             <xsl:attribute name="background-attachment">fixed</xsl:attribute>
1001             <xsl:attribute name="background-repeat">no-repeat</xsl:attribute>
1002             <xsl:attribute name="background-position-horizontal">center</xsl:attribute>
1003             <xsl:attribute name="background-position-vertical">center</xsl:attribute>
1004           </xsl:if>
1005         </fo:region-body>
1006         <fo:region-before region-name="xsl-region-before-first"
1007                           extent="{$region.before.extent}"
1008                           display-align="before"/>
1009         <fo:region-after region-name="xsl-region-after-first"
1010                          extent="{$region.after.extent}"
1011                          display-align="after"/>
1012       </fo:simple-page-master>
1013
1014       <fo:simple-page-master master-name="front-odd-draft"
1015                              page-width="{$page.width}"
1016                              page-height="{$page.height}"
1017                              margin-top="{$page.margin.top}"
1018                              margin-bottom="{$page.margin.bottom}">
1019         <xsl:attribute name="margin-{$direction.align.start}">
1020           <xsl:value-of select="$page.margin.inner"/>
1021           <xsl:if test="$fop.extensions != 0">
1022             <xsl:value-of select="concat(' - (',$title.margin.left,')')"/>
1023           </xsl:if>
1024         </xsl:attribute>
1025         <xsl:attribute name="margin-{$direction.align.end}">
1026           <xsl:value-of select="$page.margin.outer"/>
1027         </xsl:attribute>
1028         <xsl:if test="$axf.extensions != 0">
1029           <xsl:call-template name="axf-page-master-properties">
1030             <xsl:with-param name="page.master">front-odd-draft</xsl:with-param>
1031           </xsl:call-template>
1032         </xsl:if>
1033         <fo:region-body margin-bottom="{$body.margin.bottom}"
1034                         margin-top="{$body.margin.top}"
1035                         column-gap="{$column.gap.front}"
1036                         column-count="{$column.count.front}">
1037           <xsl:if test="$draft.watermark.image != ''">
1038             <xsl:attribute name="background-image">
1039               <xsl:call-template name="fo-external-image">
1040                 <xsl:with-param name="filename" select="$draft.watermark.image"/>
1041               </xsl:call-template>
1042             </xsl:attribute>
1043             <xsl:attribute name="background-attachment">fixed</xsl:attribute>
1044             <xsl:attribute name="background-repeat">no-repeat</xsl:attribute>
1045             <xsl:attribute name="background-position-horizontal">center</xsl:attribute>
1046             <xsl:attribute name="background-position-vertical">center</xsl:attribute>
1047           </xsl:if>
1048         </fo:region-body>
1049         <fo:region-before region-name="xsl-region-before-odd"
1050                           extent="{$region.before.extent}"
1051                           display-align="before"/>
1052         <fo:region-after region-name="xsl-region-after-odd"
1053                          extent="{$region.after.extent}"
1054                          display-align="after"/>
1055       </fo:simple-page-master>
1056
1057       <fo:simple-page-master master-name="front-even-draft"
1058                              page-width="{$page.width}"
1059                              page-height="{$page.height}"
1060                              margin-top="{$page.margin.top}"
1061                              margin-bottom="{$page.margin.bottom}">
1062         <xsl:attribute name="margin-{$direction.align.start}">
1063           <xsl:value-of select="$page.margin.outer"/>
1064           <xsl:if test="$fop.extensions != 0">
1065             <xsl:value-of select="concat(' - (',$title.margin.left,')')"/>
1066           </xsl:if>
1067         </xsl:attribute>
1068         <xsl:attribute name="margin-{$direction.align.end}">
1069           <xsl:value-of select="$page.margin.inner"/>
1070         </xsl:attribute>
1071         <xsl:if test="$axf.extensions != 0">
1072           <xsl:call-template name="axf-page-master-properties">
1073             <xsl:with-param name="page.master">front-even-draft</xsl:with-param>
1074           </xsl:call-template>
1075         </xsl:if>
1076         <fo:region-body margin-bottom="{$body.margin.bottom}"
1077                         margin-top="{$body.margin.top}"
1078                         column-gap="{$column.gap.front}"
1079                         column-count="{$column.count.front}">
1080           <xsl:if test="$draft.watermark.image != ''">
1081             <xsl:attribute name="background-image">
1082               <xsl:call-template name="fo-external-image">
1083                 <xsl:with-param name="filename" select="$draft.watermark.image"/>
1084               </xsl:call-template>
1085             </xsl:attribute>
1086             <xsl:attribute name="background-attachment">fixed</xsl:attribute>
1087             <xsl:attribute name="background-repeat">no-repeat</xsl:attribute>
1088             <xsl:attribute name="background-position-horizontal">center</xsl:attribute>
1089             <xsl:attribute name="background-position-vertical">center</xsl:attribute>
1090           </xsl:if>
1091         </fo:region-body>
1092         <fo:region-before region-name="xsl-region-before-even"
1093                           extent="{$region.before.extent}"
1094                           display-align="before"/>
1095         <fo:region-after region-name="xsl-region-after-even"
1096                          extent="{$region.after.extent}"
1097                          display-align="after"/>
1098       </fo:simple-page-master>
1099
1100       <!-- draft body pages -->
1101       <fo:simple-page-master master-name="body-first-draft"
1102                              page-width="{$page.width}"
1103                              page-height="{$page.height}"
1104                              margin-top="{$page.margin.top}"
1105                              margin-bottom="{$page.margin.bottom}">
1106         <xsl:attribute name="margin-{$direction.align.start}">
1107           <xsl:value-of select="$page.margin.inner"/>
1108           <xsl:if test="$fop.extensions != 0">
1109             <xsl:value-of select="concat(' - (',$title.margin.left,')')"/>
1110           </xsl:if>
1111         </xsl:attribute>
1112         <xsl:attribute name="margin-{$direction.align.end}">
1113           <xsl:value-of select="$page.margin.outer"/>
1114         </xsl:attribute>
1115         <xsl:if test="$axf.extensions != 0">
1116           <xsl:call-template name="axf-page-master-properties">
1117             <xsl:with-param name="page.master">body-first-draft</xsl:with-param>
1118           </xsl:call-template>
1119         </xsl:if>
1120         <fo:region-body margin-bottom="{$body.margin.bottom}"
1121                         margin-top="{$body.margin.top}"
1122                         column-gap="{$column.gap.body}"
1123                         column-count="{$column.count.body}">
1124           <xsl:if test="$draft.watermark.image != ''">
1125             <xsl:attribute name="background-image">
1126               <xsl:call-template name="fo-external-image">
1127                 <xsl:with-param name="filename" select="$draft.watermark.image"/>
1128               </xsl:call-template>
1129             </xsl:attribute>
1130             <xsl:attribute name="background-attachment">fixed</xsl:attribute>
1131             <xsl:attribute name="background-repeat">no-repeat</xsl:attribute>
1132             <xsl:attribute name="background-position-horizontal">center</xsl:attribute>
1133             <xsl:attribute name="background-position-vertical">center</xsl:attribute>
1134           </xsl:if>
1135         </fo:region-body>
1136         <fo:region-before region-name="xsl-region-before-first"
1137                           extent="{$region.before.extent}"
1138                           display-align="before"/>
1139         <fo:region-after region-name="xsl-region-after-first"
1140                          extent="{$region.after.extent}"
1141                          display-align="after"/>
1142       </fo:simple-page-master>
1143
1144       <fo:simple-page-master master-name="body-odd-draft"
1145                              page-width="{$page.width}"
1146                              page-height="{$page.height}"
1147                              margin-top="{$page.margin.top}"
1148                              margin-bottom="{$page.margin.bottom}">
1149         <xsl:attribute name="margin-{$direction.align.start}">
1150           <xsl:value-of select="$page.margin.inner"/>
1151           <xsl:if test="$fop.extensions != 0">
1152             <xsl:value-of select="concat(' - (',$title.margin.left,')')"/>
1153           </xsl:if>
1154         </xsl:attribute>
1155         <xsl:attribute name="margin-{$direction.align.end}">
1156           <xsl:value-of select="$page.margin.outer"/>
1157         </xsl:attribute>
1158         <xsl:if test="$axf.extensions != 0">
1159           <xsl:call-template name="axf-page-master-properties">
1160             <xsl:with-param name="page.master">body-odd-draft</xsl:with-param>
1161           </xsl:call-template>
1162         </xsl:if>
1163         <fo:region-body margin-bottom="{$body.margin.bottom}"
1164                         margin-top="{$body.margin.top}"
1165                         column-gap="{$column.gap.body}"
1166                         column-count="{$column.count.body}">
1167           <xsl:if test="$draft.watermark.image != ''">
1168             <xsl:attribute name="background-image">
1169               <xsl:call-template name="fo-external-image">
1170                 <xsl:with-param name="filename" select="$draft.watermark.image"/>
1171               </xsl:call-template>
1172             </xsl:attribute>
1173             <xsl:attribute name="background-attachment">fixed</xsl:attribute>
1174             <xsl:attribute name="background-repeat">no-repeat</xsl:attribute>
1175             <xsl:attribute name="background-position-horizontal">center</xsl:attribute>
1176             <xsl:attribute name="background-position-vertical">center</xsl:attribute>
1177           </xsl:if>
1178         </fo:region-body>
1179         <fo:region-before region-name="xsl-region-before-odd"
1180                           extent="{$region.before.extent}"
1181                           display-align="before"/>
1182         <fo:region-after region-name="xsl-region-after-odd"
1183                          extent="{$region.after.extent}"
1184                          display-align="after"/>
1185       </fo:simple-page-master>
1186
1187       <fo:simple-page-master master-name="body-even-draft"
1188                              page-width="{$page.width}"
1189                              page-height="{$page.height}"
1190                              margin-top="{$page.margin.top}"
1191                              margin-bottom="{$page.margin.bottom}">
1192         <xsl:attribute name="margin-{$direction.align.start}">
1193           <xsl:value-of select="$page.margin.outer"/>
1194           <xsl:if test="$fop.extensions != 0">
1195             <xsl:value-of select="concat(' - (',$title.margin.left,')')"/>
1196           </xsl:if>
1197         </xsl:attribute>
1198         <xsl:attribute name="margin-{$direction.align.end}">
1199           <xsl:value-of select="$page.margin.inner"/>
1200         </xsl:attribute>
1201         <xsl:if test="$axf.extensions != 0">
1202           <xsl:call-template name="axf-page-master-properties">
1203             <xsl:with-param name="page.master">body-even-draft</xsl:with-param>
1204           </xsl:call-template>
1205         </xsl:if>
1206         <fo:region-body margin-bottom="{$body.margin.bottom}"
1207                         margin-top="{$body.margin.top}"
1208                         column-gap="{$column.gap.body}"
1209                         column-count="{$column.count.body}">
1210           <xsl:if test="$draft.watermark.image != ''">
1211             <xsl:attribute name="background-image">
1212               <xsl:call-template name="fo-external-image">
1213                 <xsl:with-param name="filename" select="$draft.watermark.image"/>
1214               </xsl:call-template>
1215             </xsl:attribute>
1216             <xsl:attribute name="background-attachment">fixed</xsl:attribute>
1217             <xsl:attribute name="background-repeat">no-repeat</xsl:attribute>
1218             <xsl:attribute name="background-position-horizontal">center</xsl:attribute>
1219             <xsl:attribute name="background-position-vertical">center</xsl:attribute>
1220           </xsl:if>
1221         </fo:region-body>
1222         <fo:region-before region-name="xsl-region-before-even"
1223                           extent="{$region.before.extent}"
1224                           display-align="before"/>
1225         <fo:region-after region-name="xsl-region-after-even"
1226                          extent="{$region.after.extent}"
1227                          display-align="after"/>
1228       </fo:simple-page-master>
1229
1230       <!-- draft backmatter pages -->
1231       <fo:simple-page-master master-name="back-first-draft"
1232                              page-width="{$page.width}"
1233                              page-height="{$page.height}"
1234                              margin-top="{$page.margin.top}"
1235                              margin-bottom="{$page.margin.bottom}">
1236         <xsl:attribute name="margin-{$direction.align.start}">
1237           <xsl:value-of select="$page.margin.inner"/>
1238           <xsl:if test="$fop.extensions != 0">
1239             <xsl:value-of select="concat(' - (',$title.margin.left,')')"/>
1240           </xsl:if>
1241         </xsl:attribute>
1242         <xsl:attribute name="margin-{$direction.align.end}">
1243           <xsl:value-of select="$page.margin.outer"/>
1244         </xsl:attribute>
1245         <xsl:if test="$axf.extensions != 0">
1246           <xsl:call-template name="axf-page-master-properties">
1247             <xsl:with-param name="page.master">back-first-draft</xsl:with-param>
1248           </xsl:call-template>
1249         </xsl:if>
1250         <fo:region-body margin-bottom="{$body.margin.bottom}"
1251                         margin-top="{$body.margin.top}"
1252                         column-gap="{$column.gap.back}"
1253                         column-count="{$column.count.back}">
1254           <xsl:if test="$draft.watermark.image != ''">
1255             <xsl:attribute name="background-image">
1256               <xsl:call-template name="fo-external-image">
1257                 <xsl:with-param name="filename" select="$draft.watermark.image"/>
1258               </xsl:call-template>
1259             </xsl:attribute>
1260             <xsl:attribute name="background-attachment">fixed</xsl:attribute>
1261             <xsl:attribute name="background-repeat">no-repeat</xsl:attribute>
1262             <xsl:attribute name="background-position-horizontal">center</xsl:attribute>
1263             <xsl:attribute name="background-position-vertical">center</xsl:attribute>
1264           </xsl:if>
1265         </fo:region-body>
1266         <fo:region-before region-name="xsl-region-before-first"
1267                           extent="{$region.before.extent}"
1268                           display-align="before"/>
1269         <fo:region-after region-name="xsl-region-after-first"
1270                          extent="{$region.after.extent}"
1271                          display-align="after"/>
1272       </fo:simple-page-master>
1273
1274       <fo:simple-page-master master-name="back-odd-draft"
1275                              page-width="{$page.width}"
1276                              page-height="{$page.height}"
1277                              margin-top="{$page.margin.top}"
1278                              margin-bottom="{$page.margin.bottom}">
1279         <xsl:attribute name="margin-{$direction.align.start}">
1280           <xsl:value-of select="$page.margin.inner"/>
1281           <xsl:if test="$fop.extensions != 0">
1282             <xsl:value-of select="concat(' - (',$title.margin.left,')')"/>
1283           </xsl:if>
1284         </xsl:attribute>
1285         <xsl:attribute name="margin-{$direction.align.end}">
1286           <xsl:value-of select="$page.margin.outer"/>
1287         </xsl:attribute>
1288         <xsl:if test="$axf.extensions != 0">
1289           <xsl:call-template name="axf-page-master-properties">
1290             <xsl:with-param name="page.master">back-odd-draft</xsl:with-param>
1291           </xsl:call-template>
1292         </xsl:if>
1293         <fo:region-body margin-bottom="{$body.margin.bottom}"
1294                         margin-top="{$body.margin.top}"
1295                         column-gap="{$column.gap.back}"
1296                         column-count="{$column.count.back}">
1297           <xsl:if test="$draft.watermark.image != ''">
1298             <xsl:attribute name="background-image">
1299               <xsl:call-template name="fo-external-image">
1300                 <xsl:with-param name="filename" select="$draft.watermark.image"/>
1301               </xsl:call-template>
1302             </xsl:attribute>
1303             <xsl:attribute name="background-attachment">fixed</xsl:attribute>
1304             <xsl:attribute name="background-repeat">no-repeat</xsl:attribute>
1305             <xsl:attribute name="background-position-horizontal">center</xsl:attribute>
1306             <xsl:attribute name="background-position-vertical">center</xsl:attribute>
1307           </xsl:if>
1308         </fo:region-body>
1309         <fo:region-before region-name="xsl-region-before-odd"
1310                           extent="{$region.before.extent}"
1311                           display-align="before"/>
1312         <fo:region-after region-name="xsl-region-after-odd"
1313                          extent="{$region.after.extent}"
1314                          display-align="after"/>
1315       </fo:simple-page-master>
1316
1317       <fo:simple-page-master master-name="back-even-draft"
1318                              page-width="{$page.width}"
1319                              page-height="{$page.height}"
1320                              margin-top="{$page.margin.top}"
1321                              margin-bottom="{$page.margin.bottom}">
1322         <xsl:attribute name="margin-{$direction.align.start}">
1323           <xsl:value-of select="$page.margin.outer"/>
1324           <xsl:if test="$fop.extensions != 0">
1325             <xsl:value-of select="concat(' - (',$title.margin.left,')')"/>
1326           </xsl:if>
1327         </xsl:attribute>
1328         <xsl:attribute name="margin-{$direction.align.end}">
1329           <xsl:value-of select="$page.margin.inner"/>
1330         </xsl:attribute>
1331         <xsl:if test="$axf.extensions != 0">
1332           <xsl:call-template name="axf-page-master-properties">
1333             <xsl:with-param name="page.master">back-even-draft</xsl:with-param>
1334           </xsl:call-template>
1335         </xsl:if>
1336         <fo:region-body margin-bottom="{$body.margin.bottom}"
1337                         margin-top="{$body.margin.top}"
1338                         column-gap="{$column.gap.back}"
1339                         column-count="{$column.count.back}">
1340           <xsl:if test="$draft.watermark.image != ''">
1341             <xsl:attribute name="background-image">
1342               <xsl:call-template name="fo-external-image">
1343                 <xsl:with-param name="filename" select="$draft.watermark.image"/>
1344               </xsl:call-template>
1345             </xsl:attribute>
1346             <xsl:attribute name="background-attachment">fixed</xsl:attribute>
1347             <xsl:attribute name="background-repeat">no-repeat</xsl:attribute>
1348             <xsl:attribute name="background-position-horizontal">center</xsl:attribute>
1349             <xsl:attribute name="background-position-vertical">center</xsl:attribute>
1350           </xsl:if>
1351         </fo:region-body>
1352         <fo:region-before region-name="xsl-region-before-even"
1353                           extent="{$region.before.extent}"
1354                           display-align="before"/>
1355         <fo:region-after region-name="xsl-region-after-even"
1356                          extent="{$region.after.extent}"
1357                          display-align="after"/>
1358       </fo:simple-page-master>
1359
1360       <!-- draft index pages -->
1361       <fo:simple-page-master master-name="index-first-draft"
1362                              page-width="{$page.width}"
1363                              page-height="{$page.height}"
1364                              margin-top="{$page.margin.top}"
1365                              margin-bottom="{$page.margin.bottom}">
1366         <xsl:attribute name="margin-{$direction.align.start}">
1367           <xsl:value-of select="$page.margin.inner"/>
1368           <xsl:if test="$fop.extensions != 0">
1369             <xsl:value-of select="concat(' - (',$title.margin.left,')')"/>
1370           </xsl:if>
1371         </xsl:attribute>
1372         <xsl:attribute name="margin-{$direction.align.end}">
1373           <xsl:value-of select="$page.margin.outer"/>
1374         </xsl:attribute>
1375         <xsl:if test="$axf.extensions != 0">
1376           <xsl:call-template name="axf-page-master-properties">
1377             <xsl:with-param name="page.master">index-first-draft</xsl:with-param>
1378           </xsl:call-template>
1379         </xsl:if>
1380         <fo:region-body margin-bottom="{$body.margin.bottom}"
1381                         margin-top="{$body.margin.top}"
1382                         column-gap="{$column.gap.index}"
1383                         column-count="{$column.count.index}">
1384           <xsl:if test="$draft.watermark.image != ''">
1385             <xsl:attribute name="background-image">
1386               <xsl:call-template name="fo-external-image">
1387                 <xsl:with-param name="filename" select="$draft.watermark.image"/>
1388               </xsl:call-template>
1389             </xsl:attribute>
1390             <xsl:attribute name="background-attachment">fixed</xsl:attribute>
1391             <xsl:attribute name="background-repeat">no-repeat</xsl:attribute>
1392             <xsl:attribute name="background-position-horizontal">center</xsl:attribute>
1393             <xsl:attribute name="background-position-vertical">center</xsl:attribute>
1394           </xsl:if>
1395         </fo:region-body>
1396         <fo:region-before region-name="xsl-region-before-first"
1397                           extent="{$region.before.extent}"
1398                           display-align="before"/>
1399         <fo:region-after region-name="xsl-region-after-first"
1400                          extent="{$region.after.extent}"
1401                          display-align="after"/>
1402       </fo:simple-page-master>
1403
1404       <fo:simple-page-master master-name="index-odd-draft"
1405                              page-width="{$page.width}"
1406                              page-height="{$page.height}"
1407                              margin-top="{$page.margin.top}"
1408                              margin-bottom="{$page.margin.bottom}">
1409         <xsl:attribute name="margin-{$direction.align.start}">
1410           <xsl:value-of select="$page.margin.inner"/>
1411           <xsl:if test="$fop.extensions != 0">
1412             <xsl:value-of select="concat(' - (',$title.margin.left,')')"/>
1413           </xsl:if>
1414         </xsl:attribute>
1415         <xsl:attribute name="margin-{$direction.align.end}">
1416           <xsl:value-of select="$page.margin.outer"/>
1417         </xsl:attribute>
1418         <xsl:if test="$axf.extensions != 0">
1419           <xsl:call-template name="axf-page-master-properties">
1420             <xsl:with-param name="page.master">index-odd-draft</xsl:with-param>
1421           </xsl:call-template>
1422         </xsl:if>
1423         <fo:region-body margin-bottom="{$body.margin.bottom}"
1424                         margin-top="{$body.margin.top}"
1425                         column-gap="{$column.gap.index}"
1426                         column-count="{$column.count.index}">
1427           <xsl:if test="$draft.watermark.image != ''">
1428             <xsl:attribute name="background-image">
1429               <xsl:call-template name="fo-external-image">
1430                 <xsl:with-param name="filename" select="$draft.watermark.image"/>
1431               </xsl:call-template>
1432             </xsl:attribute>
1433             <xsl:attribute name="background-attachment">fixed</xsl:attribute>
1434             <xsl:attribute name="background-repeat">no-repeat</xsl:attribute>
1435             <xsl:attribute name="background-position-horizontal">center</xsl:attribute>
1436             <xsl:attribute name="background-position-vertical">center</xsl:attribute>
1437           </xsl:if>
1438         </fo:region-body>
1439         <fo:region-before region-name="xsl-region-before-odd"
1440                           extent="{$region.before.extent}"
1441                           display-align="before"/>
1442         <fo:region-after region-name="xsl-region-after-odd"
1443                          extent="{$region.after.extent}"
1444                          display-align="after"/>
1445       </fo:simple-page-master>
1446
1447       <fo:simple-page-master master-name="index-even-draft"
1448                              page-width="{$page.width}"
1449                              page-height="{$page.height}"
1450                              margin-top="{$page.margin.top}"
1451                              margin-bottom="{$page.margin.bottom}">
1452         <xsl:attribute name="margin-{$direction.align.start}">
1453           <xsl:value-of select="$page.margin.outer"/>
1454           <xsl:if test="$fop.extensions != 0">
1455             <xsl:value-of select="concat(' - (',$title.margin.left,')')"/>
1456           </xsl:if>
1457         </xsl:attribute>
1458         <xsl:attribute name="margin-{$direction.align.end}">
1459           <xsl:value-of select="$page.margin.inner"/>
1460         </xsl:attribute>
1461         <xsl:if test="$axf.extensions != 0">
1462           <xsl:call-template name="axf-page-master-properties">
1463             <xsl:with-param name="page.master">index-even-draft</xsl:with-param>
1464           </xsl:call-template>
1465         </xsl:if>
1466         <fo:region-body margin-bottom="{$body.margin.bottom}"
1467                         margin-top="{$body.margin.top}"
1468                         column-gap="{$column.gap.index}"
1469                         column-count="{$column.count.index}">
1470           <xsl:if test="$draft.watermark.image != ''">
1471             <xsl:attribute name="background-image">
1472               <xsl:call-template name="fo-external-image">
1473                 <xsl:with-param name="filename" select="$draft.watermark.image"/>
1474               </xsl:call-template>
1475             </xsl:attribute>
1476             <xsl:attribute name="background-attachment">fixed</xsl:attribute>
1477             <xsl:attribute name="background-repeat">no-repeat</xsl:attribute>
1478             <xsl:attribute name="background-position-horizontal">center</xsl:attribute>
1479             <xsl:attribute name="background-position-vertical">center</xsl:attribute>
1480           </xsl:if>
1481         </fo:region-body>
1482         <fo:region-before region-name="xsl-region-before-even"
1483                           extent="{$region.before.extent}"
1484                           display-align="before"/>
1485         <fo:region-after region-name="xsl-region-after-even"
1486                          extent="{$region.after.extent}"
1487                          display-align="after"/>
1488       </fo:simple-page-master>
1489     </xsl:if>
1490
1491     <!-- setup for title page(s) -->
1492     <fo:page-sequence-master master-name="titlepage">
1493       <fo:repeatable-page-master-alternatives>
1494         <fo:conditional-page-master-reference master-reference="blank"
1495                                               blank-or-not-blank="blank"/>
1496         <fo:conditional-page-master-reference master-reference="titlepage-first"
1497                                               page-position="first"/>
1498         <fo:conditional-page-master-reference master-reference="titlepage-odd"
1499                                               odd-or-even="odd"/>
1500         <fo:conditional-page-master-reference 
1501                                               odd-or-even="even">
1502           <xsl:attribute name="master-reference">
1503             <xsl:choose>
1504               <xsl:when test="$double.sided != 0">titlepage-even</xsl:when>
1505               <xsl:otherwise>titlepage-odd</xsl:otherwise>
1506             </xsl:choose>
1507           </xsl:attribute>
1508         </fo:conditional-page-master-reference>
1509       </fo:repeatable-page-master-alternatives>
1510     </fo:page-sequence-master>
1511
1512     <!-- setup for lots -->
1513     <fo:page-sequence-master master-name="lot">
1514       <fo:repeatable-page-master-alternatives>
1515         <fo:conditional-page-master-reference master-reference="blank"
1516                                               blank-or-not-blank="blank"/>
1517         <fo:conditional-page-master-reference master-reference="lot-first"
1518                                               page-position="first"/>
1519         <fo:conditional-page-master-reference master-reference="lot-odd"
1520                                               odd-or-even="odd"/>
1521         <fo:conditional-page-master-reference 
1522                                               odd-or-even="even">
1523           <xsl:attribute name="master-reference">
1524             <xsl:choose>
1525               <xsl:when test="$double.sided != 0">lot-even</xsl:when>
1526               <xsl:otherwise>lot-odd</xsl:otherwise>
1527             </xsl:choose>
1528           </xsl:attribute>
1529         </fo:conditional-page-master-reference>
1530       </fo:repeatable-page-master-alternatives>
1531     </fo:page-sequence-master>
1532
1533     <!-- setup front matter -->
1534     <fo:page-sequence-master master-name="front">
1535       <fo:repeatable-page-master-alternatives>
1536         <fo:conditional-page-master-reference master-reference="blank"
1537                                               blank-or-not-blank="blank"/>
1538         <fo:conditional-page-master-reference master-reference="front-first"
1539                                               page-position="first"/>
1540         <fo:conditional-page-master-reference master-reference="front-odd"
1541                                               odd-or-even="odd"/>
1542         <fo:conditional-page-master-reference 
1543                                               odd-or-even="even">
1544           <xsl:attribute name="master-reference">
1545             <xsl:choose>
1546               <xsl:when test="$double.sided != 0">front-even</xsl:when>
1547               <xsl:otherwise>front-odd</xsl:otherwise>
1548             </xsl:choose>
1549           </xsl:attribute>
1550         </fo:conditional-page-master-reference>
1551       </fo:repeatable-page-master-alternatives>
1552     </fo:page-sequence-master>
1553
1554     <!-- setup for body pages -->
1555     <fo:page-sequence-master master-name="body">
1556       <fo:repeatable-page-master-alternatives>
1557         <fo:conditional-page-master-reference master-reference="blank"
1558                                               blank-or-not-blank="blank"/>
1559         <fo:conditional-page-master-reference master-reference="body-first"
1560                                               page-position="first"/>
1561         <fo:conditional-page-master-reference master-reference="body-odd"
1562                                               odd-or-even="odd"/>
1563         <fo:conditional-page-master-reference 
1564                                               odd-or-even="even">
1565           <xsl:attribute name="master-reference">
1566             <xsl:choose>
1567               <xsl:when test="$double.sided != 0">body-even</xsl:when>
1568               <xsl:otherwise>body-odd</xsl:otherwise>
1569             </xsl:choose>
1570           </xsl:attribute>
1571         </fo:conditional-page-master-reference>
1572       </fo:repeatable-page-master-alternatives>
1573     </fo:page-sequence-master>
1574
1575     <!-- setup back matter -->
1576     <fo:page-sequence-master master-name="back">
1577       <fo:repeatable-page-master-alternatives>
1578         <fo:conditional-page-master-reference master-reference="blank"
1579                                               blank-or-not-blank="blank"/>
1580         <fo:conditional-page-master-reference master-reference="back-first"
1581                                               page-position="first"/>
1582         <fo:conditional-page-master-reference master-reference="back-odd"
1583                                               odd-or-even="odd"/>
1584         <fo:conditional-page-master-reference 
1585                                               odd-or-even="even">
1586           <xsl:attribute name="master-reference">
1587             <xsl:choose>
1588               <xsl:when test="$double.sided != 0">back-even</xsl:when>
1589               <xsl:otherwise>back-odd</xsl:otherwise>
1590             </xsl:choose>
1591           </xsl:attribute>
1592         </fo:conditional-page-master-reference>
1593       </fo:repeatable-page-master-alternatives>
1594     </fo:page-sequence-master>
1595
1596     <!-- setup back matter -->
1597     <fo:page-sequence-master master-name="index">
1598       <fo:repeatable-page-master-alternatives>
1599         <fo:conditional-page-master-reference master-reference="blank"
1600                                               blank-or-not-blank="blank"/>
1601         <fo:conditional-page-master-reference master-reference="index-first"
1602                                               page-position="first"/>
1603         <fo:conditional-page-master-reference master-reference="index-odd"
1604                                               odd-or-even="odd"/>
1605         <fo:conditional-page-master-reference 
1606                                               odd-or-even="even">
1607           <xsl:attribute name="master-reference">
1608             <xsl:choose>
1609               <xsl:when test="$double.sided != 0">index-even</xsl:when>
1610               <xsl:otherwise>index-odd</xsl:otherwise>
1611             </xsl:choose>
1612           </xsl:attribute>
1613         </fo:conditional-page-master-reference>
1614       </fo:repeatable-page-master-alternatives>
1615     </fo:page-sequence-master>
1616
1617     <xsl:if test="$draft.mode != 'no'">
1618       <!-- setup for draft title page(s) -->
1619       <fo:page-sequence-master master-name="titlepage-draft">
1620         <fo:repeatable-page-master-alternatives>
1621           <fo:conditional-page-master-reference master-reference="blank-draft"
1622                                                 blank-or-not-blank="blank"/>
1623           <fo:conditional-page-master-reference master-reference="titlepage-first-draft"
1624                                                 page-position="first"/>
1625           <fo:conditional-page-master-reference master-reference="titlepage-odd-draft"
1626                                                 odd-or-even="odd"/>
1627           <fo:conditional-page-master-reference 
1628                                                 odd-or-even="even">
1629             <xsl:attribute name="master-reference">
1630               <xsl:choose>
1631                 <xsl:when test="$double.sided != 0">titlepage-even-draft</xsl:when>
1632                 <xsl:otherwise>titlepage-odd-draft</xsl:otherwise>
1633               </xsl:choose>
1634             </xsl:attribute>
1635           </fo:conditional-page-master-reference>
1636         </fo:repeatable-page-master-alternatives>
1637       </fo:page-sequence-master>
1638
1639       <!-- setup for draft lots -->
1640       <fo:page-sequence-master master-name="lot-draft">
1641         <fo:repeatable-page-master-alternatives>
1642           <fo:conditional-page-master-reference master-reference="blank-draft"
1643                                                 blank-or-not-blank="blank"/>
1644           <fo:conditional-page-master-reference master-reference="lot-first-draft"
1645                                                 page-position="first"/>
1646           <fo:conditional-page-master-reference master-reference="lot-odd-draft"
1647                                                 odd-or-even="odd"/>
1648           <fo:conditional-page-master-reference 
1649                                                 odd-or-even="even">
1650             <xsl:attribute name="master-reference">
1651               <xsl:choose>
1652                 <xsl:when test="$double.sided != 0">lot-even-draft</xsl:when>
1653                 <xsl:otherwise>lot-odd-draft</xsl:otherwise>
1654               </xsl:choose>
1655             </xsl:attribute>
1656           </fo:conditional-page-master-reference>
1657         </fo:repeatable-page-master-alternatives>
1658       </fo:page-sequence-master>
1659
1660       <!-- setup draft front matter -->
1661       <fo:page-sequence-master master-name="front-draft">
1662         <fo:repeatable-page-master-alternatives>
1663           <fo:conditional-page-master-reference master-reference="blank-draft"
1664                                                 blank-or-not-blank="blank"/>
1665           <fo:conditional-page-master-reference master-reference="front-first-draft"
1666                                                 page-position="first"/>
1667           <fo:conditional-page-master-reference master-reference="front-odd-draft"
1668                                                 odd-or-even="odd"/>
1669           <fo:conditional-page-master-reference 
1670                                                 odd-or-even="even">
1671             <xsl:attribute name="master-reference">
1672               <xsl:choose>
1673                 <xsl:when test="$double.sided != 0">front-even-draft</xsl:when>
1674                 <xsl:otherwise>front-odd-draft</xsl:otherwise>
1675               </xsl:choose>
1676             </xsl:attribute>
1677           </fo:conditional-page-master-reference>
1678         </fo:repeatable-page-master-alternatives>
1679       </fo:page-sequence-master>
1680
1681       <!-- setup for draft body pages -->
1682       <fo:page-sequence-master master-name="body-draft">
1683         <fo:repeatable-page-master-alternatives>
1684           <fo:conditional-page-master-reference master-reference="blank-draft"
1685                                                 blank-or-not-blank="blank"/>
1686           <fo:conditional-page-master-reference master-reference="body-first-draft"
1687                                                 page-position="first"/>
1688           <fo:conditional-page-master-reference master-reference="body-odd-draft"
1689                                                 odd-or-even="odd"/>
1690           <fo:conditional-page-master-reference 
1691                                                 odd-or-even="even">
1692             <xsl:attribute name="master-reference">
1693               <xsl:choose>
1694                 <xsl:when test="$double.sided != 0">body-even-draft</xsl:when>
1695                 <xsl:otherwise>body-odd-draft</xsl:otherwise>
1696               </xsl:choose>
1697             </xsl:attribute>
1698           </fo:conditional-page-master-reference>
1699         </fo:repeatable-page-master-alternatives>
1700       </fo:page-sequence-master>
1701
1702       <!-- setup draft back matter -->
1703       <fo:page-sequence-master master-name="back-draft">
1704         <fo:repeatable-page-master-alternatives>
1705           <fo:conditional-page-master-reference master-reference="blank-draft"
1706                                                 blank-or-not-blank="blank"/>
1707           <fo:conditional-page-master-reference master-reference="back-first-draft"
1708                                                 page-position="first"/>
1709           <fo:conditional-page-master-reference master-reference="back-odd-draft"
1710                                                 odd-or-even="odd"/>
1711           <fo:conditional-page-master-reference 
1712                                                 odd-or-even="even">
1713             <xsl:attribute name="master-reference">
1714               <xsl:choose>
1715                 <xsl:when test="$double.sided != 0">back-even-draft</xsl:when>
1716                 <xsl:otherwise>back-odd-draft</xsl:otherwise>
1717               </xsl:choose>
1718             </xsl:attribute>
1719           </fo:conditional-page-master-reference>
1720         </fo:repeatable-page-master-alternatives>
1721       </fo:page-sequence-master>
1722
1723       <!-- setup draft index pages -->
1724       <fo:page-sequence-master master-name="index-draft">
1725         <fo:repeatable-page-master-alternatives>
1726           <fo:conditional-page-master-reference master-reference="blank-draft"
1727                                                 blank-or-not-blank="blank"/>
1728           <fo:conditional-page-master-reference master-reference="index-first-draft"
1729                                                 page-position="first"/>
1730           <fo:conditional-page-master-reference master-reference="index-odd-draft"
1731                                                 odd-or-even="odd"/>
1732           <fo:conditional-page-master-reference 
1733                                                 odd-or-even="even">
1734             <xsl:attribute name="master-reference">
1735               <xsl:choose>
1736                 <xsl:when test="$double.sided != 0">index-even-draft</xsl:when>
1737                 <xsl:otherwise>index-odd-draft</xsl:otherwise>
1738               </xsl:choose>
1739             </xsl:attribute>
1740           </fo:conditional-page-master-reference>
1741         </fo:repeatable-page-master-alternatives>
1742       </fo:page-sequence-master>
1743     </xsl:if>
1744
1745     <xsl:call-template name="user.pagemasters"/>
1746
1747     </fo:layout-master-set>
1748 </xsl:template>
1749
1750 <!-- ==================================================================== -->
1751
1752 <xsl:template name="user.pagemasters"/> <!-- intentionally empty -->
1753
1754 <!-- ==================================================================== -->
1755
1756 <xsl:template name="select.pagemaster">
1757   <xsl:param name="element" select="local-name(.)"/>
1758   <xsl:param name="pageclass" select="''"/>
1759
1760   <xsl:variable name="pagemaster">
1761     <xsl:choose>
1762       <xsl:when test="$pageclass != ''">
1763         <xsl:value-of select="$pageclass"/>
1764       </xsl:when>
1765       <xsl:when test="$pageclass = 'lot'">lot</xsl:when>
1766       <xsl:when test="$element = 'dedication'">front</xsl:when>
1767       <xsl:when test="$element = 'acknowledgements'">front</xsl:when>
1768       <xsl:when test="$element = 'preface'">front</xsl:when>
1769       <xsl:when test="$element = 'appendix'">back</xsl:when>
1770       <xsl:when test="$element = 'glossary'">back</xsl:when>
1771       <xsl:when test="$element = 'bibliography'">back</xsl:when>
1772       <xsl:when test="$element = 'index'">index</xsl:when>
1773       <xsl:when test="$element = 'colophon'">back</xsl:when>
1774       <xsl:otherwise>body</xsl:otherwise>
1775     </xsl:choose>
1776
1777     <xsl:choose>
1778       <xsl:when test="$draft.mode = 'yes'">
1779         <xsl:text>-draft</xsl:text>
1780       </xsl:when>
1781       <xsl:when test="$draft.mode = 'no'">
1782         <!-- nop -->
1783       </xsl:when>
1784       <xsl:when test="ancestor-or-self::*[@status][1]/@status = 'draft'">
1785         <xsl:text>-draft</xsl:text>
1786       </xsl:when>
1787       <xsl:otherwise>
1788         <!-- nop -->
1789       </xsl:otherwise>
1790     </xsl:choose>
1791   </xsl:variable>
1792
1793   <xsl:call-template name="select.user.pagemaster">
1794     <xsl:with-param name="element" select="$element"/>
1795     <xsl:with-param name="pageclass" select="$pageclass"/>
1796     <xsl:with-param name="default-pagemaster" select="$pagemaster"/>
1797   </xsl:call-template>
1798 </xsl:template>
1799
1800 <xsl:template name="select.user.pagemaster">
1801   <xsl:param name="element"/>
1802   <xsl:param name="pageclass"/>
1803   <xsl:param name="default-pagemaster"/>
1804
1805   <!-- by default, return the default. But if you've created your own
1806        pagemasters in user.pagemasters, you might want to select one here. -->
1807   <xsl:value-of select="$default-pagemaster"/>
1808 </xsl:template>
1809
1810 <!-- ==================================================================== -->
1811
1812 <xsl:template name="head.sep.rule">
1813   <xsl:param name="pageclass"/>
1814   <xsl:param name="sequence"/>
1815   <xsl:param name="gentext-key"/>
1816
1817   <xsl:if test="$header.rule != 0">
1818     <xsl:attribute name="border-bottom-width">0.5pt</xsl:attribute>
1819     <xsl:attribute name="border-bottom-style">solid</xsl:attribute>
1820     <xsl:attribute name="border-bottom-color">black</xsl:attribute>
1821   </xsl:if>
1822 </xsl:template>
1823
1824 <xsl:template name="foot.sep.rule">
1825   <xsl:param name="pageclass"/>
1826   <xsl:param name="sequence"/>
1827   <xsl:param name="gentext-key"/>
1828
1829   <xsl:if test="$footer.rule != 0">
1830     <xsl:attribute name="border-top-width">0.5pt</xsl:attribute>
1831     <xsl:attribute name="border-top-style">solid</xsl:attribute>
1832     <xsl:attribute name="border-top-color">black</xsl:attribute>
1833   </xsl:if>
1834 </xsl:template>
1835
1836 <!-- ==================================================================== -->
1837
1838 <xsl:template match="*" mode="running.head.mode">
1839   <xsl:param name="master-reference" select="'unknown'"/>
1840   <xsl:param name="gentext-key" select="local-name(.)"/>
1841
1842   <!-- remove -draft from reference -->
1843   <xsl:variable name="pageclass">
1844     <xsl:choose>
1845       <xsl:when test="contains($master-reference, '-draft')">
1846         <xsl:value-of select="substring-before($master-reference, '-draft')"/>
1847       </xsl:when>
1848       <xsl:otherwise>
1849         <xsl:value-of select="$master-reference"/>
1850       </xsl:otherwise>
1851     </xsl:choose>
1852   </xsl:variable>
1853
1854   <fo:static-content flow-name="xsl-region-before-first">
1855     <fo:block xsl:use-attribute-sets="header.content.properties">
1856       <xsl:call-template name="header.table">
1857         <xsl:with-param name="pageclass" select="$pageclass"/>
1858         <xsl:with-param name="sequence" select="'first'"/>
1859         <xsl:with-param name="gentext-key" select="$gentext-key"/>
1860       </xsl:call-template>
1861     </fo:block>
1862   </fo:static-content>
1863
1864   <fo:static-content flow-name="xsl-region-before-odd">
1865     <fo:block xsl:use-attribute-sets="header.content.properties">
1866       <xsl:call-template name="header.table">
1867         <xsl:with-param name="pageclass" select="$pageclass"/>
1868         <xsl:with-param name="sequence" select="'odd'"/>
1869         <xsl:with-param name="gentext-key" select="$gentext-key"/>
1870       </xsl:call-template>
1871     </fo:block>
1872   </fo:static-content>
1873
1874   <fo:static-content flow-name="xsl-region-before-even">
1875     <fo:block xsl:use-attribute-sets="header.content.properties">
1876       <xsl:call-template name="header.table">
1877         <xsl:with-param name="pageclass" select="$pageclass"/>
1878         <xsl:with-param name="sequence" select="'even'"/>
1879         <xsl:with-param name="gentext-key" select="$gentext-key"/>
1880       </xsl:call-template>
1881     </fo:block>
1882   </fo:static-content>
1883
1884   <fo:static-content flow-name="xsl-region-before-blank">
1885     <fo:block xsl:use-attribute-sets="header.content.properties">
1886       <xsl:call-template name="header.table">
1887         <xsl:with-param name="pageclass" select="$pageclass"/>
1888         <xsl:with-param name="sequence" select="'blank'"/>
1889         <xsl:with-param name="gentext-key" select="$gentext-key"/>
1890       </xsl:call-template>
1891     </fo:block>
1892   </fo:static-content>
1893
1894   <xsl:call-template name="footnote-separator"/>
1895
1896   <xsl:if test="$fop.extensions = 0 and $fop1.extensions = 0">
1897     <xsl:call-template name="blank.page.content"/>
1898   </xsl:if>
1899 </xsl:template>
1900
1901 <xsl:template name="footnote-separator">
1902   <fo:static-content flow-name="xsl-footnote-separator">
1903     <fo:block>
1904       <fo:leader xsl:use-attribute-sets="footnote.sep.leader.properties"/>
1905     </fo:block>
1906   </fo:static-content>
1907 </xsl:template>
1908
1909 <xsl:template name="blank.page.content">
1910   <fo:static-content flow-name="blank-body">
1911     <fo:block text-align="center"/>
1912   </fo:static-content>
1913 </xsl:template>
1914
1915 <xsl:template name="header.table">
1916   <xsl:param name="pageclass" select="''"/>
1917   <xsl:param name="sequence" select="''"/>
1918   <xsl:param name="gentext-key" select="''"/>
1919
1920   <!-- default is a single table style for all headers -->
1921   <!-- Customize it for different page classes or sequence location -->
1922
1923   <xsl:choose>
1924       <xsl:when test="$pageclass = 'index'">
1925           <xsl:attribute name="margin-{$direction.align.start}">0pt</xsl:attribute>
1926       </xsl:when>
1927   </xsl:choose>
1928
1929   <xsl:variable name="column1">
1930     <xsl:choose>
1931       <xsl:when test="$double.sided = 0">1</xsl:when>
1932       <xsl:when test="$sequence = 'first' or $sequence = 'odd'">1</xsl:when>
1933       <xsl:otherwise>3</xsl:otherwise>
1934     </xsl:choose>
1935   </xsl:variable>
1936
1937   <xsl:variable name="column3">
1938     <xsl:choose>
1939       <xsl:when test="$double.sided = 0">3</xsl:when>
1940       <xsl:when test="$sequence = 'first' or $sequence = 'odd'">3</xsl:when>
1941       <xsl:otherwise>1</xsl:otherwise>
1942     </xsl:choose>
1943   </xsl:variable>
1944
1945   <xsl:variable name="candidate">
1946     <fo:table xsl:use-attribute-sets="header.table.properties">
1947       <xsl:call-template name="head.sep.rule">
1948         <xsl:with-param name="pageclass" select="$pageclass"/>
1949         <xsl:with-param name="sequence" select="$sequence"/>
1950         <xsl:with-param name="gentext-key" select="$gentext-key"/>
1951       </xsl:call-template>
1952
1953       <fo:table-column column-number="1">
1954         <xsl:attribute name="column-width">
1955           <xsl:text>proportional-column-width(</xsl:text>
1956           <xsl:call-template name="header.footer.width">
1957             <xsl:with-param name="location">header</xsl:with-param>
1958             <xsl:with-param name="position" select="$column1"/>
1959           </xsl:call-template>
1960           <xsl:text>)</xsl:text>
1961         </xsl:attribute>
1962       </fo:table-column>
1963       <fo:table-column column-number="2">
1964         <xsl:attribute name="column-width">
1965           <xsl:text>proportional-column-width(</xsl:text>
1966           <xsl:call-template name="header.footer.width">
1967             <xsl:with-param name="location">header</xsl:with-param>
1968             <xsl:with-param name="position" select="2"/>
1969           </xsl:call-template>
1970           <xsl:text>)</xsl:text>
1971         </xsl:attribute>
1972       </fo:table-column>
1973       <fo:table-column column-number="3">
1974         <xsl:attribute name="column-width">
1975           <xsl:text>proportional-column-width(</xsl:text>
1976           <xsl:call-template name="header.footer.width">
1977             <xsl:with-param name="location">header</xsl:with-param>
1978             <xsl:with-param name="position" select="$column3"/>
1979           </xsl:call-template>
1980           <xsl:text>)</xsl:text>
1981         </xsl:attribute>
1982       </fo:table-column>
1983
1984       <fo:table-body>
1985         <fo:table-row>
1986           <xsl:attribute name="block-progression-dimension.minimum">
1987             <xsl:value-of select="$header.table.height"/>
1988           </xsl:attribute>
1989           <fo:table-cell text-align="start"
1990                          display-align="before">
1991             <xsl:if test="$fop.extensions = 0">
1992               <xsl:attribute name="relative-align">baseline</xsl:attribute>
1993             </xsl:if>
1994             <fo:block>
1995               <xsl:call-template name="header.content">
1996                 <xsl:with-param name="pageclass" select="$pageclass"/>
1997                 <xsl:with-param name="sequence" select="$sequence"/>
1998                 <xsl:with-param name="position" select="$direction.align.start"/>
1999                 <xsl:with-param name="gentext-key" select="$gentext-key"/>
2000               </xsl:call-template>
2001             </fo:block>
2002           </fo:table-cell>
2003           <fo:table-cell text-align="center"
2004                          display-align="before">
2005             <xsl:if test="$fop.extensions = 0">
2006               <xsl:attribute name="relative-align">baseline</xsl:attribute>
2007             </xsl:if>
2008             <fo:block>
2009               <xsl:call-template name="header.content">
2010                 <xsl:with-param name="pageclass" select="$pageclass"/>
2011                 <xsl:with-param name="sequence" select="$sequence"/>
2012                 <xsl:with-param name="position" select="'center'"/>
2013                 <xsl:with-param name="gentext-key" select="$gentext-key"/>
2014               </xsl:call-template>
2015             </fo:block>
2016           </fo:table-cell>
2017           <fo:table-cell text-align="right"
2018                          display-align="before">
2019             <xsl:if test="$fop.extensions = 0">
2020               <xsl:attribute name="relative-align">baseline</xsl:attribute>
2021             </xsl:if>
2022             <fo:block>
2023               <xsl:call-template name="header.content">
2024                 <xsl:with-param name="pageclass" select="$pageclass"/>
2025                 <xsl:with-param name="sequence" select="$sequence"/>
2026                 <xsl:with-param name="position" select="$direction.align.end"/>
2027                 <xsl:with-param name="gentext-key" select="$gentext-key"/>
2028               </xsl:call-template>
2029             </fo:block>
2030           </fo:table-cell>
2031         </fo:table-row>
2032       </fo:table-body>
2033     </fo:table>
2034   </xsl:variable>
2035
2036   <!-- Really output a header? -->
2037   <xsl:choose>
2038     <xsl:when test="$pageclass = 'titlepage' and $gentext-key = 'book'
2039                     and $sequence='first'">
2040       <!-- no, book titlepages have no headers at all -->
2041     </xsl:when>
2042     <xsl:when test="$sequence = 'blank' and $headers.on.blank.pages = 0">
2043       <!-- no output -->
2044     </xsl:when>
2045     <xsl:otherwise>
2046       <xsl:copy-of select="$candidate"/>
2047     </xsl:otherwise>
2048   </xsl:choose>
2049 </xsl:template>
2050
2051 <xsl:template name="header.content">
2052   <xsl:param name="pageclass" select="''"/>
2053   <xsl:param name="sequence" select="''"/>
2054   <xsl:param name="position" select="''"/>
2055   <xsl:param name="gentext-key" select="''"/>
2056
2057 <!--
2058   <fo:block>
2059     <xsl:value-of select="$pageclass"/>
2060     <xsl:text>, </xsl:text>
2061     <xsl:value-of select="$sequence"/>
2062     <xsl:text>, </xsl:text>
2063     <xsl:value-of select="$position"/>
2064     <xsl:text>, </xsl:text>
2065     <xsl:value-of select="$gentext-key"/>
2066   </fo:block>
2067 -->
2068
2069   <fo:block>
2070
2071     <!-- sequence can be odd, even, first, blank -->
2072     <!-- position can be left, center, right -->
2073     <xsl:choose>
2074       <xsl:when test="$sequence = 'blank'">
2075         <!-- nothing -->
2076       </xsl:when>
2077
2078       <xsl:when test="$position='left'">
2079         <!-- Same for odd, even, empty, and blank sequences -->
2080         <xsl:call-template name="draft.text"/>
2081       </xsl:when>
2082
2083       <xsl:when test="($sequence='odd' or $sequence='even') and $position='center'">
2084         <xsl:if test="$pageclass != 'titlepage'">
2085           <xsl:choose>
2086             <xsl:when test="ancestor::book and ($double.sided != 0)">
2087               <fo:retrieve-marker retrieve-class-name="section.head.marker"
2088                                   retrieve-position="first-including-carryover"
2089                                   retrieve-boundary="page-sequence"/>
2090             </xsl:when>
2091             <xsl:otherwise>
2092               <xsl:apply-templates select="." mode="titleabbrev.markup"/>
2093             </xsl:otherwise>
2094           </xsl:choose>
2095         </xsl:if>
2096       </xsl:when>
2097
2098       <xsl:when test="$position='center'">
2099         <!-- nothing for empty and blank sequences -->
2100       </xsl:when>
2101
2102       <xsl:when test="$position='right'">
2103         <!-- Same for odd, even, empty, and blank sequences -->
2104         <xsl:call-template name="draft.text"/>
2105       </xsl:when>
2106
2107       <xsl:when test="$sequence = 'first'">
2108         <!-- nothing for first pages -->
2109       </xsl:when>
2110
2111       <xsl:when test="$sequence = 'blank'">
2112         <!-- nothing for blank pages -->
2113       </xsl:when>
2114     </xsl:choose>
2115   </fo:block>
2116 </xsl:template>
2117
2118 <xsl:template name="header.footer.width">
2119   <xsl:param name="location" select="'header'"/>
2120   <xsl:param name="position" select="1"/>
2121
2122   <xsl:variable name="width.set">
2123     <xsl:choose>
2124       <xsl:when test="$location = 'header'">
2125         <xsl:value-of select="normalize-space($header.column.widths)"/>
2126       </xsl:when>
2127       <xsl:otherwise>
2128         <xsl:value-of select="normalize-space($footer.column.widths)"/>
2129       </xsl:otherwise>
2130     </xsl:choose>
2131   </xsl:variable>
2132
2133
2134   <xsl:variable name="width">
2135     <xsl:choose>
2136       <xsl:when test="$position = 1">
2137         <xsl:value-of select="substring-before($width.set, ' ')"/>
2138       </xsl:when>
2139       <xsl:when test="$position = 2">
2140         <xsl:value-of select="substring-before(substring-after($width.set, ' '), ' ')"/>
2141       </xsl:when>
2142       <xsl:otherwise>
2143         <xsl:value-of select="substring-after(substring-after($width.set, ' '), ' ')"/>
2144       </xsl:otherwise>
2145     </xsl:choose>
2146   </xsl:variable>
2147
2148   <!-- Make sure it is a number -->
2149   <xsl:choose>
2150     <xsl:when test = "$width = number($width)">
2151       <xsl:value-of select="$width"/>
2152     </xsl:when>
2153     <xsl:otherwise>
2154       <xsl:message>Error: value in <xsl:value-of select="$location"/>.column.widths at position <xsl:value-of select="$position"/> is not a number.</xsl:message>
2155       <xsl:text>1</xsl:text>
2156     </xsl:otherwise>
2157   </xsl:choose>
2158 </xsl:template>
2159
2160 <xsl:template name="draft.text">
2161   <xsl:choose>
2162     <xsl:when test="$draft.mode = 'yes'">
2163       <xsl:call-template name="gentext">
2164         <xsl:with-param name="key" select="'Draft'"/>
2165       </xsl:call-template>
2166     </xsl:when>
2167     <xsl:when test="$draft.mode = 'no'">
2168       <!-- nop -->
2169     </xsl:when>
2170     <xsl:when test="ancestor-or-self::*[@status][1]/@status = 'draft'">
2171       <xsl:call-template name="gentext">
2172         <xsl:with-param name="key" select="'Draft'"/>
2173       </xsl:call-template>
2174     </xsl:when>
2175     <xsl:otherwise>
2176       <!-- nop -->
2177     </xsl:otherwise>
2178   </xsl:choose>
2179 </xsl:template>
2180
2181 <!-- ==================================================================== -->
2182
2183 <xsl:template match="*" mode="running.foot.mode">
2184   <xsl:param name="master-reference" select="'unknown'"/>
2185   <xsl:param name="gentext-key" select="local-name(.)"/>
2186
2187   <!-- remove -draft from reference -->
2188   <xsl:variable name="pageclass">
2189     <xsl:choose>
2190       <xsl:when test="contains($master-reference, '-draft')">
2191         <xsl:value-of select="substring-before($master-reference, '-draft')"/>
2192       </xsl:when>
2193       <xsl:otherwise>
2194         <xsl:value-of select="$master-reference"/>
2195       </xsl:otherwise>
2196     </xsl:choose>
2197   </xsl:variable>
2198
2199   <fo:static-content flow-name="xsl-region-after-first">
2200     <fo:block xsl:use-attribute-sets="footer.content.properties">
2201       <xsl:call-template name="footer.table">
2202         <xsl:with-param name="pageclass" select="$pageclass"/>
2203         <xsl:with-param name="sequence" select="'first'"/>
2204         <xsl:with-param name="gentext-key" select="$gentext-key"/>
2205       </xsl:call-template>
2206     </fo:block>
2207   </fo:static-content>
2208
2209   <fo:static-content flow-name="xsl-region-after-odd">
2210     <fo:block xsl:use-attribute-sets="footer.content.properties">
2211       <xsl:call-template name="footer.table">
2212         <xsl:with-param name="pageclass" select="$pageclass"/>
2213         <xsl:with-param name="sequence" select="'odd'"/>
2214         <xsl:with-param name="gentext-key" select="$gentext-key"/>
2215       </xsl:call-template>
2216     </fo:block>
2217   </fo:static-content>
2218
2219   <fo:static-content flow-name="xsl-region-after-even">
2220     <fo:block xsl:use-attribute-sets="footer.content.properties">
2221       <xsl:call-template name="footer.table">
2222         <xsl:with-param name="pageclass" select="$pageclass"/>
2223         <xsl:with-param name="sequence" select="'even'"/>
2224         <xsl:with-param name="gentext-key" select="$gentext-key"/>
2225       </xsl:call-template>
2226     </fo:block>
2227   </fo:static-content>
2228
2229   <fo:static-content flow-name="xsl-region-after-blank">
2230     <fo:block xsl:use-attribute-sets="footer.content.properties">
2231       <xsl:call-template name="footer.table">
2232         <xsl:with-param name="pageclass" select="$pageclass"/>
2233         <xsl:with-param name="sequence" select="'blank'"/>
2234         <xsl:with-param name="gentext-key" select="$gentext-key"/>
2235       </xsl:call-template>
2236     </fo:block>
2237   </fo:static-content>
2238 </xsl:template>
2239
2240 <xsl:template name="footer.table">
2241   <xsl:param name="pageclass" select="''"/>
2242   <xsl:param name="sequence" select="''"/>
2243   <xsl:param name="gentext-key" select="''"/>
2244
2245   <!-- default is a single table style for all footers -->
2246   <!-- Customize it for different page classes or sequence location -->
2247
2248   <xsl:choose>
2249       <xsl:when test="$pageclass = 'index'">
2250           <xsl:attribute name="margin-{$direction.align.start}">0pt</xsl:attribute>
2251       </xsl:when>
2252   </xsl:choose>
2253
2254   <xsl:variable name="column1">
2255     <xsl:choose>
2256       <xsl:when test="$double.sided = 0">1</xsl:when>
2257       <xsl:when test="$sequence = 'first' or $sequence = 'odd'">1</xsl:when>
2258       <xsl:otherwise>3</xsl:otherwise>
2259     </xsl:choose>
2260   </xsl:variable>
2261
2262   <xsl:variable name="column3">
2263     <xsl:choose>
2264       <xsl:when test="$double.sided = 0">3</xsl:when>
2265       <xsl:when test="$sequence = 'first' or $sequence = 'odd'">3</xsl:when>
2266       <xsl:otherwise>1</xsl:otherwise>
2267     </xsl:choose>
2268   </xsl:variable>
2269
2270   <xsl:variable name="candidate">
2271     <fo:table xsl:use-attribute-sets="footer.table.properties">
2272       <xsl:call-template name="foot.sep.rule">
2273         <xsl:with-param name="pageclass" select="$pageclass"/>
2274         <xsl:with-param name="sequence" select="$sequence"/>
2275         <xsl:with-param name="gentext-key" select="$gentext-key"/>
2276       </xsl:call-template>
2277       <fo:table-column column-number="1">
2278         <xsl:attribute name="column-width">
2279           <xsl:text>proportional-column-width(</xsl:text>
2280           <xsl:call-template name="header.footer.width">
2281             <xsl:with-param name="location">footer</xsl:with-param>
2282             <xsl:with-param name="position" select="$column1"/>
2283           </xsl:call-template>
2284           <xsl:text>)</xsl:text>
2285         </xsl:attribute>
2286       </fo:table-column>
2287       <fo:table-column column-number="2">
2288         <xsl:attribute name="column-width">
2289           <xsl:text>proportional-column-width(</xsl:text>
2290           <xsl:call-template name="header.footer.width">
2291             <xsl:with-param name="location">footer</xsl:with-param>
2292             <xsl:with-param name="position" select="2"/>
2293           </xsl:call-template>
2294           <xsl:text>)</xsl:text>
2295         </xsl:attribute>
2296       </fo:table-column>
2297       <fo:table-column column-number="3">
2298         <xsl:attribute name="column-width">
2299           <xsl:text>proportional-column-width(</xsl:text>
2300           <xsl:call-template name="header.footer.width">
2301             <xsl:with-param name="location">footer</xsl:with-param>
2302             <xsl:with-param name="position" select="$column3"/>
2303           </xsl:call-template>
2304           <xsl:text>)</xsl:text>
2305         </xsl:attribute>
2306       </fo:table-column>
2307
2308       <fo:table-body>
2309         <fo:table-row>
2310           <xsl:attribute name="block-progression-dimension.minimum">
2311             <xsl:value-of select="$footer.table.height"/>
2312           </xsl:attribute>
2313           <fo:table-cell text-align="start"
2314                          display-align="after">
2315             <xsl:if test="$fop.extensions = 0">
2316               <xsl:attribute name="relative-align">baseline</xsl:attribute>
2317             </xsl:if>
2318             <fo:block>
2319               <xsl:call-template name="footer.content">
2320                 <xsl:with-param name="pageclass" select="$pageclass"/>
2321                 <xsl:with-param name="sequence" select="$sequence"/>
2322                 <xsl:with-param name="position" select="$direction.align.start"/>
2323                 <xsl:with-param name="gentext-key" select="$gentext-key"/>
2324               </xsl:call-template>
2325             </fo:block>
2326           </fo:table-cell>
2327           <fo:table-cell text-align="center"
2328                          display-align="after">
2329             <xsl:if test="$fop.extensions = 0">
2330               <xsl:attribute name="relative-align">baseline</xsl:attribute>
2331             </xsl:if>
2332             <fo:block>
2333               <xsl:call-template name="footer.content">
2334                 <xsl:with-param name="pageclass" select="$pageclass"/>
2335                 <xsl:with-param name="sequence" select="$sequence"/>
2336                 <xsl:with-param name="position" select="'center'"/>
2337                 <xsl:with-param name="gentext-key" select="$gentext-key"/>
2338               </xsl:call-template>
2339             </fo:block>
2340           </fo:table-cell>
2341           <fo:table-cell text-align="end"
2342                          display-align="after">
2343             <xsl:if test="$fop.extensions = 0">
2344               <xsl:attribute name="relative-align">baseline</xsl:attribute>
2345             </xsl:if>
2346             <fo:block>
2347               <xsl:call-template name="footer.content">
2348                 <xsl:with-param name="pageclass" select="$pageclass"/>
2349                 <xsl:with-param name="sequence" select="$sequence"/>
2350                 <xsl:with-param name="position" select="$direction.align.end"/>
2351                 <xsl:with-param name="gentext-key" select="$gentext-key"/>
2352               </xsl:call-template>
2353             </fo:block>
2354           </fo:table-cell>
2355         </fo:table-row>
2356       </fo:table-body>
2357     </fo:table>
2358   </xsl:variable>
2359
2360   <!-- Really output a footer? -->
2361   <xsl:choose>
2362     <xsl:when test="$pageclass='titlepage' and $gentext-key='book'
2363                     and $sequence='first'">
2364       <!-- no, book titlepages have no footers at all -->
2365     </xsl:when>
2366     <xsl:when test="$sequence = 'blank' and $footers.on.blank.pages = 0">
2367       <!-- no output -->
2368     </xsl:when>
2369     <xsl:otherwise>
2370       <xsl:copy-of select="$candidate"/>
2371     </xsl:otherwise>
2372   </xsl:choose>
2373 </xsl:template>
2374
2375 <xsl:template name="footer.content">
2376   <xsl:param name="pageclass" select="''"/>
2377   <xsl:param name="sequence" select="''"/>
2378   <xsl:param name="position" select="''"/>
2379   <xsl:param name="gentext-key" select="''"/>
2380
2381 <!--
2382   <fo:block>
2383     <xsl:value-of select="$pageclass"/>
2384     <xsl:text>, </xsl:text>
2385     <xsl:value-of select="$sequence"/>
2386     <xsl:text>, </xsl:text>
2387     <xsl:value-of select="$position"/>
2388     <xsl:text>, </xsl:text>
2389     <xsl:value-of select="$gentext-key"/>
2390   </fo:block>
2391 -->
2392
2393   <fo:block>
2394     <!-- pageclass can be front, body, back -->
2395     <!-- sequence can be odd, even, first, blank -->
2396     <!-- position can be left, center, right -->
2397     <xsl:choose>
2398       <xsl:when test="$pageclass = 'titlepage'">
2399         <!-- nop; no footer on title pages -->
2400       </xsl:when>
2401
2402       <xsl:when test="$double.sided != 0 and $sequence = 'even'
2403                       and $position='left'">
2404         <fo:page-number/>
2405       </xsl:when>
2406
2407       <xsl:when test="$double.sided != 0 and ($sequence = 'odd' or $sequence = 'first')
2408                       and $position='right'">
2409         <fo:page-number/>
2410       </xsl:when>
2411
2412       <xsl:when test="$double.sided = 0 and $position='center'">
2413         <fo:page-number/>
2414       </xsl:when>
2415
2416       <xsl:when test="$sequence='blank'">
2417         <xsl:choose>
2418           <xsl:when test="$double.sided != 0 and $position = 'left'">
2419             <fo:page-number/>
2420           </xsl:when>
2421           <xsl:when test="$double.sided = 0 and $position = 'center'">
2422             <fo:page-number/>
2423           </xsl:when>
2424           <xsl:otherwise>
2425             <!-- nop -->
2426           </xsl:otherwise>
2427         </xsl:choose>
2428       </xsl:when>
2429
2430
2431       <xsl:otherwise>
2432         <!-- nop -->
2433       </xsl:otherwise>
2434     </xsl:choose>
2435   </fo:block>
2436 </xsl:template>
2437
2438 <!-- ==================================================================== -->
2439
2440 <xsl:template name="page.number.format">
2441   <xsl:param name="element" select="local-name(.)"/>
2442   <xsl:param name="master-reference" select="''"/>
2443
2444   <xsl:choose>
2445     <xsl:when test="$element = 'toc' and self::book">i</xsl:when>
2446     <xsl:when test="$element = 'preface'">i</xsl:when>
2447     <xsl:when test="$element = 'dedication'">i</xsl:when>
2448     <xsl:when test="$element = 'acknowledgements'">i</xsl:when>
2449     <xsl:otherwise>1</xsl:otherwise>
2450   </xsl:choose>
2451 </xsl:template>
2452
2453 <xsl:template name="initial.page.number">
2454   <xsl:param name="element" select="local-name(.)"/>
2455   <xsl:param name="master-reference" select="''"/>
2456
2457   <!-- Select the first content that the stylesheet places
2458        after the TOC -->
2459   <xsl:variable name="first.book.content" 
2460                 select="ancestor::book/*[
2461                           not(self::title or
2462                               self::subtitle or
2463                               self::titleabbrev or
2464                               self::bookinfo or
2465                               self::info or
2466                               self::dedication or
2467                               self::acknowledgements or
2468                               self::preface or
2469                               self::toc or
2470                               self::lot)][1]"/>
2471   <xsl:choose>
2472     <!-- double-sided output -->
2473     <xsl:when test="$double.sided != 0">
2474       <xsl:choose>
2475         <xsl:when test="$element = 'toc'">auto-odd</xsl:when>
2476         <xsl:when test="$element = 'book'">1</xsl:when>
2477         <!-- preface typically continues TOC roman numerals -->
2478         <!-- Change page.number.format if not -->
2479         <xsl:when test="$element = 'preface'">auto-odd</xsl:when>
2480         <xsl:when test="($element = 'dedication' or $element = 'article') 
2481                     and not(preceding::chapter
2482                             or preceding::preface
2483                             or preceding::appendix
2484                             or preceding::article
2485                             or preceding::dedication
2486                             or parent::part
2487                             or parent::reference)">1</xsl:when>
2488         <xsl:when test="generate-id($first.book.content) =
2489                         generate-id(.)">1</xsl:when>
2490         <xsl:otherwise>auto-odd</xsl:otherwise>
2491       </xsl:choose>
2492     </xsl:when>
2493
2494     <!-- single-sided output -->
2495     <xsl:otherwise>
2496       <xsl:choose>
2497         <xsl:when test="$element = 'toc'">auto</xsl:when>
2498         <xsl:when test="$element = 'book'">1</xsl:when>
2499         <xsl:when test="$element = 'preface'">auto</xsl:when>
2500        <xsl:when test="($element = 'dedication' or $element = 'article') and
2501                         not(preceding::chapter
2502                             or preceding::preface
2503                             or preceding::appendix
2504                             or preceding::article
2505                             or preceding::dedication
2506                             or parent::part
2507                             or parent::reference)">1</xsl:when>
2508         <xsl:when test="generate-id($first.book.content) =
2509                         generate-id(.)">1</xsl:when>
2510         <xsl:otherwise>auto</xsl:otherwise>
2511       </xsl:choose>
2512     </xsl:otherwise>
2513   </xsl:choose>
2514 </xsl:template>
2515
2516 <xsl:template name="force.page.count">
2517   <xsl:param name="element" select="local-name(.)"/>
2518   <xsl:param name="master-reference" select="''"/>
2519
2520   <xsl:choose>
2521     <!-- double-sided output -->
2522     <xsl:when test="$double.sided != 0">end-on-even</xsl:when>
2523     <!-- single-sided output -->
2524     <xsl:otherwise>no-force</xsl:otherwise>
2525   </xsl:choose>
2526 </xsl:template>
2527
2528 <xsl:template name="set.flow.properties">
2529   <xsl:param name="element" select="local-name(.)"/>
2530   <xsl:param name="master-reference" select="''"/>
2531
2532   <!-- This template is called after each <fo:flow> starts. -->
2533   <!-- Customize this template to set attributes on fo:flow -->
2534
2535   <!-- remove -draft from reference -->
2536   <xsl:variable name="pageclass">
2537     <xsl:choose>
2538       <xsl:when test="contains($master-reference, '-draft')">
2539         <xsl:value-of select="substring-before($master-reference, '-draft')"/>
2540       </xsl:when>
2541       <xsl:otherwise>
2542         <xsl:value-of select="$master-reference"/>
2543       </xsl:otherwise>
2544     </xsl:choose>
2545   </xsl:variable>
2546
2547   <xsl:choose>
2548     <xsl:when test="$fop.extensions != 0 or $passivetex.extensions != 0">
2549       <!-- body.start.indent does not work well with these processors -->
2550     </xsl:when>
2551     <xsl:when test="starts-with($pageclass, 'body') or
2552                     starts-with($pageclass, 'lot') or
2553                     starts-with($pageclass, 'front') or
2554                     $element = 'preface' or
2555                     (starts-with($pageclass, 'back') and
2556                     $element = 'appendix')">
2557       <xsl:attribute name="start-indent">
2558         <xsl:value-of select="$body.start.indent"/>
2559       </xsl:attribute>
2560       <xsl:attribute name="end-indent">
2561         <xsl:value-of select="$body.end.indent"/>
2562       </xsl:attribute>
2563     </xsl:when>
2564   </xsl:choose>
2565
2566 </xsl:template>
2567 <!-- ==================================================================== -->
2568
2569 </xsl:stylesheet>