Statistics
| Revision:

root / tmp / org.txm.core / res / org / txm / xml / xsl / tei / fo2 / textstructure.xsl @ 187

History | View | Annotate | Download (58.6 kB)

1
<?xml version="1.0" encoding="utf-8"?>
2
<xsl:stylesheet 
3
                xmlns:fotex="http://www.tug.org/fotex"
4
                xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0"
5
                xmlns="http://www.w3.org/1999/XSL/Format"
6
                xmlns:rng="http://relaxng.org/ns/structure/1.0"
7
                xmlns:tei="http://www.tei-c.org/ns/1.0"
8
                xmlns:teix="http://www.tei-c.org/ns/Examples"
9
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
10
                exclude-result-prefixes="fotex a rng tei teix"
11
                version="2.0">
12
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl" scope="stylesheet" type="stylesheet">
13
      <desc>
14
         <p>
15
    TEI stylesheet
16
    dealing  with elements from the
17
      textstructure module, making XSL-FO output.
18
      </p>
19
         <p>This software is dual-licensed:
20

    
21
1. Distributed under a Creative Commons Attribution-ShareAlike 3.0
22
Unported License http://creativecommons.org/licenses/by-sa/3.0/ 
23

    
24
2. http://www.opensource.org/licenses/BSD-2-Clause
25
		
26
All rights reserved.
27

    
28
Redistribution and use in source and binary forms, with or without
29
modification, are permitted provided that the following conditions are
30
met:
31

    
32
* Redistributions of source code must retain the above copyright
33
notice, this list of conditions and the following disclaimer.
34

    
35
* Redistributions in binary form must reproduce the above copyright
36
notice, this list of conditions and the following disclaimer in the
37
documentation and/or other materials provided with the distribution.
38

    
39
This software is provided by the copyright holders and contributors
40
"as is" and any express or implied warranties, including, but not
41
limited to, the implied warranties of merchantability and fitness for
42
a particular purpose are disclaimed. In no event shall the copyright
43
holder or contributors be liable for any direct, indirect, incidental,
44
special, exemplary, or consequential damages (including, but not
45
limited to, procurement of substitute goods or services; loss of use,
46
data, or profits; or business interruption) however caused and on any
47
theory of liability, whether in contract, strict liability, or tort
48
(including negligence or otherwise) arising in any way out of the use
49
of this software, even if advised of the possibility of such damage.
50
</p>
51
         <p>Author: See AUTHORS</p>
52
         <p>Id: $Id: textstructure.xsl 9646 2011-11-05 23:39:08Z rahtz $</p>
53
         <p>Copyright: 2011, TEI Consortium</p>
54
      </desc>
55
   </doc>
56
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
57
      <desc>Process elements  * in inner mode</desc>
58
   </doc>
59
  <xsl:template match="*" mode="innertext">
60
      <xsl:apply-templates select="."/>
61
  </xsl:template>
62
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
63
      <desc/>
64
   </doc>
65
  <xsl:template match="tei:*" mode="heading">
66
      <xsl:apply-templates/>
67
  </xsl:template>
68
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
69
      <desc/>
70
   </doc>
71
  <xsl:template match="tei:TEI">
72
      <root>
73
         <xsl:call-template name="setupPagemasters"/>
74
         <xsl:call-template name="mainAction"/>
75
      </root>
76
  </xsl:template>
77
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
78
      <desc/>
79
   </doc>
80
  <xsl:template match="tei:back">
81
      <xsl:comment>Back matter</xsl:comment>
82
      <xsl:choose>
83
         <xsl:when test="ancestor::tei:group">
84
            <xsl:apply-templates/>
85
         </xsl:when>
86
         <xsl:otherwise>
87
            <page-sequence format="{$formatBackpage}" text-align="{$alignment}" hyphenate="{$hyphenate}"
88
                           language="{$language}">
89
               <xsl:call-template name="choosePageMaster">
90
                  <xsl:with-param name="where">
91
                     <xsl:value-of select="$backMulticolumns"/>
92
                  </xsl:with-param>
93
               </xsl:call-template>
94
               <!-- static areas -->
95
          <xsl:choose>
96
                  <xsl:when test="$twoSided='true'">
97
                     <xsl:call-template name="headers-footers-twoside-back"/>
98
                  </xsl:when>
99
                  <xsl:otherwise>
100
                     <xsl:call-template name="headers-footers-oneside-back"/>
101
                  </xsl:otherwise>
102
               </xsl:choose>
103
               <!-- now start the main flow -->
104
          <flow flow-name="xsl-region-body" font-family="{$bodyFont}" font-size="{$bodySize}">
105
                  <xsl:apply-templates/>
106
                  <xsl:call-template name="afterBodyHook"/>
107
               </flow>
108
            </page-sequence>
109
         </xsl:otherwise>
110
      </xsl:choose>
111
  </xsl:template>
112
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
113
      <desc/>
114
   </doc>
115
  <xsl:template match="tei:body">
116
      <xsl:choose>
117
         <xsl:when test="ancestor::tei:floatingText">
118
            <xsl:apply-templates/>
119
         </xsl:when>
120
         <xsl:when test="ancestor::tei:p">
121
            <xsl:apply-templates/>
122
         </xsl:when>
123
         <xsl:when test="ancestor::tei:group">
124
            <xsl:apply-templates/>
125
         </xsl:when>
126
         <xsl:otherwise>
127
<!-- start page sequence -->
128
        <page-sequence format="{$formatBodypage}" text-align="{$alignment}" hyphenate="{$hyphenate}"
129
                           language="{$language}"
130
                           initial-page-number="1">
131
               <xsl:call-template name="choosePageMaster">
132
                  <xsl:with-param name="where">
133
                     <xsl:value-of select="$bodyMulticolumns"/>
134
                  </xsl:with-param>
135
               </xsl:call-template>
136
               <!-- static areas -->
137
          <xsl:choose>
138
                  <xsl:when test="$twoSided='true'">
139
                     <xsl:call-template name="headers-footers-twoside"/>
140
                  </xsl:when>
141
                  <xsl:otherwise>
142
                     <xsl:call-template name="headers-footers-oneside"/>
143
                  </xsl:otherwise>
144
               </xsl:choose>
145
               <!-- now start the main  flow -->
146
          <flow flow-name="xsl-region-body" font-family="{$bodyFont}" font-size="{$bodySize}">
147
                  <xsl:if test="not($flowMarginLeft='')">
148
                     <xsl:attribute name="margin-left">
149
                        <xsl:value-of select="$flowMarginLeft"/>
150
                     </xsl:attribute>
151
                  </xsl:if>
152
                  <!--include front matter if there is no separate titlepage -->
153
            <xsl:if test="not($titlePage='true') and not(preceding-sibling::tei:front)">
154
                     <xsl:call-template name="Header"/>
155
                  </xsl:if>
156
                  <xsl:apply-templates/>
157
                  <xsl:if test=".//tei:note[@place='end']">
158
                     <block>
159
                        <xsl:call-template name="setupDiv2"/>
160
                        <xsl:text>Notes</xsl:text>
161
                     </block>
162
                     <xsl:apply-templates select=".//tei:note[@place='end']" mode="endnote"/>
163
                  </xsl:if>
164
               </flow>
165
            </page-sequence>
166
         </xsl:otherwise>
167
      </xsl:choose>
168
  </xsl:template>
169
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
170
      <desc/>
171
   </doc>
172
  <xsl:template match="tei:closer">
173
      <block space-before.optimum="4pt" space-after.optimum="4pt"
174
             end-indent="{$exampleMargin}"
175
             start-indent="{$exampleMargin}">
176
         <xsl:apply-templates/>
177
      </block>
178
  </xsl:template>
179
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
180
      <desc/>
181
   </doc>
182
  <xsl:template match="tei:dateline">
183
      <block text-align="end">
184
         <xsl:apply-templates/>
185
      </block>
186
  </xsl:template>
187
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
188
      <desc>
189
    
190
         <p xmlns="http://www.w3.org/1999/XSL/Format"> Normal headings </p>
191
    
192
      </desc>
193
   </doc>
194
  <xsl:template match="tei:div">
195
      <xsl:text>&#10;</xsl:text>
196
      <xsl:choose>
197
         <xsl:when test="@type='bibliog'">
198
            <xsl:apply-templates/>
199
         </xsl:when>
200
         <xsl:when test="@type='abstract'">
201
            <block keep-with-next.within-page="always" end-indent="{$exampleMargin}"
202
                   start-indent="{$exampleMargin}">
203
               <xsl:attribute name="text-align">center</xsl:attribute>
204
               <xsl:call-template name="setupDiv2"/>
205
               <inline font-style="italic">Abstract</inline>
206
            </block>
207
            <xsl:apply-templates/>
208
         </xsl:when>
209
         <xsl:when test="@type='ack'">
210
            <block keep-with-next.within-page="always">
211
               <xsl:attribute name="text-align">start</xsl:attribute>
212
               <xsl:call-template name="setupDiv3"/>
213
               <inline font-style="italic">Acknowledgements</inline>
214
            </block>
215
            <xsl:apply-templates/>
216
         </xsl:when>
217
         <xsl:otherwise>
218
<!-- behaviour depends on the nesting level of <div> elements -->
219
        <xsl:variable name="divlevel" select="count(ancestor::tei:div)"/>
220
            <xsl:call-template name="NumberedHeading">
221
               <xsl:with-param name="level">
222
                  <xsl:value-of select="$divlevel"/>
223
               </xsl:with-param>
224
            </xsl:call-template>
225
            <xsl:apply-templates/>
226
         </xsl:otherwise>
227
      </xsl:choose>
228
  </xsl:template>
229
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
230
      <desc>
231
    
232
         <p xmlns="http://www.w3.org/1999/XSL/Format"> headings in TOC </p>
233
    
234
      </desc>
235
   </doc>
236
  <xsl:template match="tei:div" mode="toc">
237
      <xsl:variable name="divlevel">
238
         <xsl:value-of select="count(ancestor::tei:div)"/>
239
      </xsl:variable>
240
      <xsl:call-template name="tocheading">
241
         <xsl:with-param name="level">
242
            <xsl:value-of select="$divlevel"/>
243
         </xsl:with-param>
244
      </xsl:call-template>
245
  </xsl:template>
246
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
247
      <desc/>
248
   </doc>
249
  <xsl:template match="tei:div" mode="xref">
250
      <xsl:variable name="divlevel" select="count(ancestor::tei:div)"/>
251
      <xsl:call-template name="xheading">
252
         <xsl:with-param name="level">div<xsl:value-of select="$divlevel"/>
253
         </xsl:with-param>
254
      </xsl:call-template>
255
  </xsl:template>
256
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
257
      <desc/>
258
   </doc>
259
  <xsl:template match="tei:div1|tei:div2|tei:div3|tei:div4|tei:div5">
260
    <xsl:call-template name="NumberedHeading">
261
      <xsl:with-param name="level">
262
	<xsl:value-of select="substring-after(local-name(),'div')"/>
263
      </xsl:with-param>
264
    </xsl:call-template>
265
    <xsl:apply-templates/>
266
  </xsl:template>
267
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
268
      <desc>Process elements
269
      tei:div1|tei:div2|tei:div3|tei:div4|tei:div5 (toc mode)</desc>
270
   </doc>
271
  <xsl:template match="tei:div1|tei:div2|tei:div3|tei:div4|tei:div5" mode="toc">
272
      <xsl:call-template name="tocheading">
273
         <xsl:with-param name="level">
274
            <xsl:value-of select="substring-after(local-name(),'div')"/>
275
         </xsl:with-param>
276
      </xsl:call-template>
277
  </xsl:template>
278
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
279
      <desc/>
280
   </doc>
281
  <xsl:template mode="xref" match="tei:div1|tei:div2|tei:div3|tei:div4|tei:div5">
282
      <xsl:call-template name="xheading">
283
         <xsl:with-param name="level">
284
            <xsl:value-of select="local-name()"/>
285
         </xsl:with-param>
286
      </xsl:call-template>
287
  </xsl:template>
288
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
289
      <desc/>
290
   </doc>
291
  <xsl:template match="tei:div[@type='canto']">
292
      <xsl:variable name="divlevel" select="count(ancestor::tei:div)"/>
293
      <xsl:call-template name="NumberedHeading">
294
         <xsl:with-param name="level">
295
            <xsl:value-of select="$divlevel"/>
296
         </xsl:with-param>
297
      </xsl:call-template>
298
      <xsl:apply-templates/>
299
  </xsl:template>
300

    
301
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
302
      <desc>    
303
         <p xmlns="http://www.w3.org/1999/XSL/Format">Table of contents </p>
304
      </desc>
305
   </doc>
306
  <xsl:template match="tei:divGen">
307
      <xsl:choose>
308
         <xsl:when test="@type='toc' and ancestor::tei:text/tei:group">
309
            <xsl:call-template name="bookTOC"/>
310
         </xsl:when>
311
         <xsl:when test="@type='toc'">
312
            <xsl:call-template name="mainTOC"/>
313
         </xsl:when>
314
      </xsl:choose>
315
  </xsl:template>
316
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
317
      <desc/>
318
   </doc>
319
  <xsl:template match="tei:front">
320
      <xsl:comment>Front matter</xsl:comment>
321
      <xsl:choose>
322
         <xsl:when test="ancestor::tei:floatingText">
323
            <xsl:apply-templates/>
324
         </xsl:when>
325
         <xsl:when test="ancestor::tei:p">
326
            <xsl:apply-templates/>
327
         </xsl:when>
328
         <xsl:when test="ancestor::tei:group">
329
            <xsl:apply-templates/>
330
         </xsl:when>
331
         <xsl:otherwise>
332
            <xsl:if test="$titlePage='true'">
333
               <page-sequence format="{$formatFrontpage}" force-page-count="end-on-even"
334
                              hyphenate="{$hyphenate}"
335
                              language="{$language}">
336
                  <xsl:call-template name="choosePageMaster">
337
                     <xsl:with-param name="where">
338
                        <xsl:value-of select="$frontMulticolumns"/>
339
                     </xsl:with-param>
340
                  </xsl:call-template>
341
                  <static-content flow-name="xsl-region-before">
342
                     <block/>
343
                  </static-content>
344
                  <static-content flow-name="xsl-region-after">
345
                     <block/>
346
                  </static-content>
347
                  <flow flow-name="xsl-region-body" font-family="{$bodyFont}">
348
                     <xsl:call-template name="Header"/>
349
                  </flow>
350
               </page-sequence>
351
            </xsl:if>
352
            <page-sequence format="{$formatFrontpage}" text-align="{$alignment}" hyphenate="{$hyphenate}"
353
                           language="{$language}"
354
                           initial-page-number="1">
355
               <xsl:call-template name="choosePageMaster">
356
                  <xsl:with-param name="where">
357
                     <xsl:value-of select="$frontMulticolumns"/>
358
                  </xsl:with-param>
359
               </xsl:call-template>
360
               <!-- static areas -->
361
          <xsl:choose>
362
                  <xsl:when test="$twoSided='true'">
363
                     <xsl:call-template name="headers-footers-twoside"/>
364
                  </xsl:when>
365
                  <xsl:otherwise>
366
                     <xsl:call-template name="headers-footers-oneside"/>
367
                  </xsl:otherwise>
368
               </xsl:choose>
369
               <!-- now start the main flow -->
370
          <flow flow-name="xsl-region-body" font-family="{$bodyFont}" font-size="{$bodySize}">
371
                  <xsl:for-each select="tei:*">
372
                     <xsl:comment>Start <xsl:value-of select="name(.)"/>
373
                     </xsl:comment>
374
                     <xsl:apply-templates select="."/>
375
                     <xsl:comment>End <xsl:value-of select="name(.)"/>
376
                     </xsl:comment>
377
                  </xsl:for-each>
378
               </flow>
379
            </page-sequence>
380
         </xsl:otherwise>
381
      </xsl:choose>
382
  </xsl:template>
383
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
384
      <desc/>
385
   </doc>
386
  <xsl:template match="tei:group/tei:text">
387
      <xsl:variable name="N">
388
         <xsl:number/>
389
      </xsl:variable>
390
      <page-sequence format="1" text-align="{$alignment}" hyphenate="{$hyphenate}"
391
                     language="{$language}"
392
                     master-reference="twoside1">
393
         <xsl:attribute name="initial-page-number">
394
            <xsl:choose>
395
               <xsl:when test="$N = 1">1</xsl:when>
396
               <xsl:otherwise>auto-odd</xsl:otherwise>
397
            </xsl:choose>
398
         </xsl:attribute>
399
         <xsl:call-template name="grouptextStatic"/>
400
         <flow flow-name="xsl-region-body" font-family="{$bodyFont}">
401
            <xsl:call-template name="textTitle">
402
               <xsl:with-param name="N" select="$N"/>
403
            </xsl:call-template>
404
            <xsl:apply-templates select="tei:body"/>
405
            <xsl:apply-templates select="tei:back"/>
406
         </flow>
407
      </page-sequence>
408
  </xsl:template>
409
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
410
      <desc/>
411
   </doc>
412
  <xsl:template match="tei:group/tei:text/tei:body">
413
      <xsl:apply-templates/>
414
      <xsl:if test=".//tei:note[@place='end']">
415
         <block>
416
            <xsl:call-template name="setupDiv2"/>
417
            <xsl:text>Notes</xsl:text>
418
         </block>
419
         <xsl:apply-templates select=".//tei:note[@place='end']" mode="endnote"/>
420
      </xsl:if>
421
  </xsl:template>
422
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
423
      <desc>
424
    
425
         <p xmlns="http://www.w3.org/1999/XSL/Format"> Simple head </p>
426
    
427
      </desc>
428
   </doc>
429
  <xsl:template match="tei:head" mode="section">
430
<!-- if we have multiple <head> elements together, 
431
  separate by spaces -->
432
<!--
433
   <xsl:if test="preceding-sibling::tei:head">
434
	<xsl:text> </xsl:text>
435
     </xsl:if>
436
-->
437
    <xsl:apply-templates/>
438
  </xsl:template>
439

    
440
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
441
      <desc>Process element head in heading mode</desc>
442
   </doc>
443
  <xsl:template match="tei:head" mode="makeheading">
444
      <xsl:apply-templates/>
445
  </xsl:template>
446

    
447
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
448
      <desc>
449
    
450
         <p xmlns="http://www.w3.org/1999/XSL/Format"> unqualified &lt;head&gt; </p>
451
    
452
      </desc>
453
   </doc>
454
  <xsl:template match="tei:head"/>
455
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
456
      <desc/>
457
   </doc>
458
  <xsl:template match="tei:opener">
459
      <block space-before.optimum="4pt" space-after.optimum="4pt"
460
             end-indent="{$exampleMargin}"
461
             start-indent="{$exampleMargin}">
462
         <xsl:apply-templates/>
463
      </block>
464
  </xsl:template>
465
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
466
      <desc>
467
    
468
         <p xmlns="http://www.w3.org/1999/XSL/Format"> headings when cross-referenced </p>
469
    
470
      </desc>
471
   </doc>
472
  <xsl:template match="tei:text" mode="xref">
473
      <xsl:choose>
474
         <xsl:when test="@n">
475
            <xsl:value-of select="@n"/>
476
         </xsl:when>
477
         <xsl:otherwise>
478
            <xsl:number/>
479
         </xsl:otherwise>
480
      </xsl:choose>
481
  </xsl:template>
482
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
483
      <desc/>
484
   </doc>
485
  <xsl:template match="tei:text">
486
      <xsl:choose>
487
         <xsl:when test="parent::tei:TEI">
488
            <xsl:apply-templates/>
489
         </xsl:when>
490
         <xsl:when test="parent::tei:group">
491
            <xsl:apply-templates/>
492
         </xsl:when>
493
         <xsl:otherwise>
494
            <block text-align="start" text-indent="0pt" end-indent="{$exampleMargin}"
495
                   start-indent="{$exampleMargin}"
496
                   font-size="{$exampleSize}"
497
                   border-top-style="solid"
498
                   border-bottom-style="solid"
499
                   space-before.optimum="{$exampleBefore}"
500
                   space-after.optimum="{$exampleAfter}">
501
               <xsl:apply-templates mode="innertext"/>
502
            </block>
503
         </xsl:otherwise>
504
      </xsl:choose>
505
  </xsl:template>
506
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
507
      <desc/>
508
   </doc>
509
  <xsl:template match="tei:text" mode="toc">
510
      <block>
511
         <xsl:attribute name="font-weight">bold</xsl:attribute>
512
         <xsl:number/>
513
         <xsl:text> </xsl:text>
514
         <inline>
515
            <xsl:choose>
516
               <xsl:when test="tei:front/tei:docTitle[@n]">
517
                  <xsl:value-of select="tei:front/tei:docTitle/@n"/>
518
               </xsl:when>
519
               <xsl:otherwise>
520
                  <xsl:value-of select="tei:front/tei:docTitle"/>
521
               </xsl:otherwise>
522
            </xsl:choose>
523
         </inline>
524
         <leader rule-thickness="0pt"/>
525
         <inline>
526
            <xsl:call-template name="linkStyle"/>
527
            <xsl:variable name="pagref">
528
               <xsl:choose>
529
                  <xsl:when test="@xml:id">
530
                     <xsl:value-of select="@xml:id"/>
531
                  </xsl:when>
532
                  <xsl:otherwise>
533
                     <xsl:value-of select="generate-id()"/>
534
                  </xsl:otherwise>
535
               </xsl:choose>
536
            </xsl:variable>
537
            <basic-link internal-destination="{$pagref}">
538
               <page-number-citation ref-id="{$pagref}"/>
539
            </basic-link>
540
         </inline>
541
      </block>
542
      <block font-style="italic" space-after="10pt" space-before="6pt">
543
         <xsl:apply-templates select="tei:front//tei:docAuthor" mode="heading"/>
544
      </block>
545
  </xsl:template>
546
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
547
      <desc/>
548
   </doc>
549
  <xsl:template match="tei:titlePage">
550
      <block text-align="center">
551
         <xsl:apply-templates/>
552
      </block>
553
  </xsl:template>
554
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
555
      <desc/>
556
   </doc>
557
  <xsl:template match="tei:titlePage//tei:titlePart[@type='main']">
558
      <block font-size="{$titleSize}" space-after="8pt" text-align="center">
559
         <xsl:apply-templates/>
560
      </block>
561
  </xsl:template>
562
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
563
      <desc/>
564
   </doc>
565
  <xsl:template match="tei:titlePage//tei:titlePart[@type='sub']">
566
      <block>
567
         <block font-size="{$authorSize}" space-after="8pt" text-align="center">
568
            <xsl:apply-templates/>
569
         </block>
570
      </block>
571
  </xsl:template>
572
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
573
      <desc/>
574
   </doc>
575
  <xsl:template match="tei:titlePart">
576
      <xsl:apply-templates/>
577
  </xsl:template>
578
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
579
      <desc/>
580
   </doc>
581
  <xsl:template match="tei:titlePart[@type='running']"/>
582
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
583
      <desc/>
584
   </doc>
585
  <xsl:template match="tei:trailer">
586
      <block>
587
         <xsl:apply-templates/>
588
      </block>
589
  </xsl:template>
590
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
591
      <desc>Process elements  text()</desc>
592
   </doc>
593
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
594
      <desc>[fo] </desc>
595
   </doc>
596
  <xsl:template name="Header">
597
      <block font-size="12pt" padding-before="6pt">
598
         <inline>
599
	           <xsl:value-of select="$institution"/>
600
         </inline>
601
      </block>
602
    
603
      <block font-size="12pt" font-weight="bold">
604
         <xsl:call-template name="generateTitle"/>
605
      </block>
606
    
607
      <block>
608
         <xsl:call-template name="generateAuthor"/>
609
      </block>
610
    
611
      <block padding-after="6pt">
612
         <xsl:call-template name="generateDate"/>
613
      </block>
614
  </xsl:template>
615
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
616
      <desc>[fo] <param name="level">level</param>
617
      </desc>
618
   </doc>
619
  <xsl:template name="NumberedHeading">
620
      <xsl:param name="level"/>
621
      <block keep-with-next.within-page="always">
622
         <xsl:variable name="divid">
623
            <xsl:choose>
624
               <xsl:when test="@xml:id">
625
                  <xsl:value-of select="@xml:id"/>
626
               </xsl:when>
627
               <xsl:otherwise>
628
                  <xsl:value-of select="generate-id()"/>
629
               </xsl:otherwise>
630
            </xsl:choose>
631
         </xsl:variable>
632
         <xsl:attribute name="id">
633
            <xsl:value-of select="$divid"/>
634
         </xsl:attribute>
635
         <xsl:attribute name="text-align">start</xsl:attribute>
636
         <xsl:attribute name="font-family">
637
            <xsl:value-of select="$divFont"/>
638
         </xsl:attribute>
639
         <xsl:choose>
640
            <xsl:when test="$level=0">
641
               <xsl:call-template name="setupDiv0"/>
642
            </xsl:when>
643
            <xsl:when test="$level=1">
644
               <xsl:call-template name="setupDiv1"/>
645
            </xsl:when>
646
            <xsl:when test="$level=2">
647
               <xsl:call-template name="setupDiv2"/>
648
            </xsl:when>
649
            <xsl:when test="$level=3">
650
               <xsl:call-template name="setupDiv3"/>
651
            </xsl:when>
652
            <xsl:when test="$level=4">
653
               <xsl:call-template name="setupDiv4"/>
654
            </xsl:when>
655
            <xsl:when test="$level=5">
656
               <xsl:call-template name="setupDiv5"/>
657
            </xsl:when>
658
            <xsl:when test="$level=6">
659
               <xsl:call-template name="setupDiv6"/>
660
            </xsl:when>
661
         </xsl:choose>
662
         <xsl:call-template name="blockStartHook"/>
663
         <xsl:variable name="Number">
664
            <xsl:if test="$numberHeadings='true' and $numberHeadingsDepth &gt; $level">
665
               <xsl:call-template name="calculateNumber">
666
                  <xsl:with-param name="numbersuffix">
667
	                    <xsl:call-template name="headingNumberSuffix"/>
668
	                 </xsl:with-param>
669
               </xsl:call-template>
670
            </xsl:if>
671
         </xsl:variable>
672
         <!--
673
<xsl:message>**  Calculated   [<xsl:value-of select="$Number"/>] [<xsl:value-of select="$headingNumberSuffix"/>] for <xsl:value-of select="@xml:id"/></xsl:message>
674
-->
675
      <xsl:value-of select="$Number"/>
676
         <xsl:apply-templates mode="section" select="tei:head"/>
677
         <xsl:if test="$divRunningheads='true'">
678
<!-- markers for use in running heads -->
679
        <xsl:choose>
680
               <xsl:when test="$level=0">
681
                  <marker marker-class-name="section1"/>
682
                  <marker marker-class-name="section2"/>
683
                  <marker marker-class-name="section3"/>
684
                  <marker marker-class-name="section4"/>
685
                  <marker marker-class-name="section5"/>
686
               </xsl:when>
687
               <xsl:when test="$level=1">
688
                  <marker marker-class-name="section2"/>
689
                  <marker marker-class-name="section3"/>
690
                  <marker marker-class-name="section4"/>
691
                  <marker marker-class-name="section5"/>
692
               </xsl:when>
693
               <xsl:when test="$level=2">
694
                  <marker marker-class-name="section3"/>
695
                  <marker marker-class-name="section4"/>
696
                  <marker marker-class-name="section5"/>
697
               </xsl:when>
698
               <xsl:when test="$level=3">
699
                  <marker marker-class-name="section4"/>
700
                  <marker marker-class-name="section5"/>
701
               </xsl:when>
702
               <xsl:when test="$level=4">
703
                  <marker marker-class-name="section5"/>
704
               </xsl:when>
705
               <xsl:when test="$level=5"/>                     
706
            </xsl:choose>
707
            <marker marker-class-name="section{$level}">
708
               <xsl:if test="$numberHeadings='true'">
709
                  <xsl:value-of select="$Number"/>
710
                  <xsl:call-template name="headingNumberSuffix"/>
711
               </xsl:if>
712
               <xsl:value-of select="tei:head"/>
713
            </marker>
714
         </xsl:if>
715
         <xsl:choose>
716
            <xsl:when test="$foEngine='passivetex'">
717
<!-- Passive TeX extension, to get PDF bookmarks -->
718
          <fotex:bookmark fotex-bookmark-level="{$level}" fotex-bookmark-label="{$divid}">
719
                  <xsl:if test="$numberHeadings='true'">
720
                     <xsl:value-of select="$Number"/>
721
                  </xsl:if>
722
                  <xsl:value-of select="tei:head"/>
723
               </fotex:bookmark>
724
            </xsl:when>
725
         </xsl:choose>
726
      </block>
727
  </xsl:template>
728
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
729
      <desc>[fo] </desc>
730
   </doc>
731
  <xsl:template name="bookTOC">
732
      <page-sequence format="1" initial-page-number="{$tocStartPage}" master-reference="twoside1">
733
         <xsl:call-template name="headers-footers-twoside">
734
            <xsl:with-param name="runeven">even page running head</xsl:with-param>
735
            <xsl:with-param name="runodd">&#160;odd page running head</xsl:with-param>
736
         </xsl:call-template>
737
         <flow flow-name="xsl-region-body" font-family="{$bodyFont}">
738
            <block text-align="center">
739
               <xsl:attribute name="font-size">
740
                  <xsl:value-of select="$tocSize"/>
741
               </xsl:attribute>
742
               <xsl:attribute name="text-indent">
743
                  <xsl:value-of select="$headingOutdent"/>
744
               </xsl:attribute>
745
               <xsl:attribute name="font-weight">bold</xsl:attribute>
746
               <xsl:attribute name="space-after">24pt</xsl:attribute>
747
               <xsl:attribute name="space-before.optimum">24pt</xsl:attribute>
748
               <xsl:text>Contents</xsl:text>
749
            </block>
750
            <xsl:for-each select="ancestor::tei:text/tei:group/tei:text">
751
               <xsl:apply-templates select="." mode="toc"/>
752
            </xsl:for-each>
753
         </flow>
754
      </page-sequence>
755
  </xsl:template>
756
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
757
      <desc>[fo] <param name="where">where</param>
758
         <param name="force">force</param>
759
      </desc>
760
   </doc>
761
  <xsl:template name="choosePageMaster">
762
      <xsl:param name="where"/>
763
      <xsl:param name="force"/>
764
      <xsl:variable name="mn">
765
         <xsl:choose>
766
            <xsl:when test="$forcePageMaster">
767
               <xsl:value-of select="$forcePageMaster"/>
768
            </xsl:when>
769
            <xsl:when test="not($where='')">
770
               <xsl:choose>
771
                  <xsl:when test="$twoSided='true'">twoside2</xsl:when>
772
                  <xsl:otherwise>oneside2</xsl:otherwise>
773
               </xsl:choose>
774
            </xsl:when>
775
            <xsl:otherwise>
776
               <xsl:choose>
777
                  <xsl:when test="$twoSided='true'">twoside1</xsl:when>
778
                  <xsl:otherwise>oneside1</xsl:otherwise>
779
               </xsl:choose>
780
            </xsl:otherwise>
781
         </xsl:choose>
782
      </xsl:variable>
783
      <xsl:attribute name="master-reference">
784
         <xsl:value-of select="$mn"/>
785
      </xsl:attribute>
786
  </xsl:template>
787
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
788
      <desc>[fo] </desc>
789
   </doc>
790
  <xsl:template name="grouptextStatic">
791
      <static-content flow-name="xsl-region-after-right">
792
         <block text-align="end" font-size="{$bodySize}">
793
            <page-number/>
794
         </block>
795
      </static-content>
796
      <static-content flow-name="xsl-region-after-left">
797
         <block text-align="start" font-size="{$bodySize}">
798
            <page-number/>
799
         </block>
800
      </static-content>
801
      <static-content flow-name="xsl-region-before-left">
802
         <block text-indent="0em" background-color="blue" font-weight="bold" padding="3pt"
803
                color="white"
804
                font-family="{$runFont}"
805
                text-align="justify"
806
                font-size="{$runSize}">
807
            <inline>
808
               <xsl:number/>
809
            </inline>
810
            <leader rule-thickness="0pt"/>
811
            <inline>
812
               <xsl:choose>
813
                  <xsl:when test="front/tei:docTitle[@n]">
814
                     <xsl:value-of select="tei:front/tei:docTitle[@n]"/>
815
                  </xsl:when>
816
                  <xsl:otherwise>
817
                     <xsl:value-of select="tei:front/tei:docTitle"/>
818
                  </xsl:otherwise>
819
               </xsl:choose>
820
            </inline>
821
         </block>
822
      </static-content>
823
      <static-content flow-name="xsl-region-before-right">
824
         <block background-color="blue" text-indent="0em" font-weight="bold" padding="3pt"
825
                color="white"
826
                text-align="left"
827
                font-family="{$runFont}"
828
                font-size="{$runSize}">
829
            <xsl:value-of select="tei:front//tei:docAuthor"/>
830
         </block>
831
      </static-content>
832
  </xsl:template>
833
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
834
      <desc>[fo] <param name="runhead">runhead</param>
835
      </desc>
836
   </doc>
837
  <xsl:template name="headers-footers-oneside">
838
      <xsl:param name="runhead"/>
839
      <static-content flow-name="xsl-region-before">
840
         <block font-size="{$bodySize}">
841
            <xsl:choose>
842
               <xsl:when test="$runhead='true'">
843
                  <xsl:value-of select="$runhead"/>
844
               </xsl:when>
845
               <xsl:otherwise>
846
                  <xsl:call-template name="runninghead-author"/>
847
               </xsl:otherwise>
848
            </xsl:choose>
849
         </block>
850
      </static-content>
851
      <static-content flow-name="xsl-region-after">
852
         <block text-align="center" font-size="{$bodySize}">
853
            <page-number/>
854
         </block>
855
      </static-content>
856
      <static-content flow-name="xsl-region-before-first">
857
        </static-content>
858
      <static-content flow-name="xsl-region-after-first">
859
         <block text-align="center" font-size="{$bodySize}">
860
            <page-number/>
861
         </block>
862
      </static-content>
863
  </xsl:template>
864
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
865
      <desc>[fo] <param name="runhead">runhead</param>
866
      </desc>
867
   </doc>
868
  <xsl:template name="headers-footers-oneside-back">
869
      <xsl:param name="runhead"/>
870
      <xsl:call-template name="headers-footers-oneside">
871
         <xsl:with-param name="runhead">
872
            <xsl:value-of select="$runhead"/>
873
         </xsl:with-param>
874
      </xsl:call-template>
875
  </xsl:template>
876
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
877
      <desc>[fo] <param name="runodd">odd page running head</param>
878
         <param name="runeven">even page running head</param>
879
      </desc>
880
   </doc>
881
  <xsl:template name="headers-footers-twoside">
882
      <xsl:param name="runodd"/>
883
      <xsl:param name="runeven"/>
884
      <static-content flow-name="xsl-region-before-right">
885
         <block text-align="justify" text-align-last="justify" font-size="{$bodySize}">
886
            <xsl:choose>
887
               <xsl:when test="$runodd">
888
                  <xsl:value-of select="$runodd"/>
889
               </xsl:when>
890
               <xsl:when test="$sectionHeaders='true'">
891
                  <block>
892
                     <xsl:if test="$divRunningheads='true'">
893
                        <inline>
894
                           <retrieve-marker retrieve-class-name="section2"/>
895
                        </inline>
896
                     </xsl:if>
897
                     <leader rule-thickness="0pt"/>
898
                     <inline>
899
                        <page-number/>
900
                     </inline>
901
                  </block>
902
               </xsl:when>
903
               <xsl:otherwise>
904
                  <xsl:call-template name="runninghead-title"/>
905
               </xsl:otherwise>
906
            </xsl:choose>
907
         </block>
908
      </static-content>
909
      <static-content flow-name="xsl-region-before-left">
910
         <block text-align="justify" font-size="{$bodySize}">
911
            <xsl:choose>
912
               <xsl:when test="$runeven">
913
                  <xsl:value-of select="$runeven"/>
914
               </xsl:when>
915
               <xsl:when test="$sectionHeaders='true'">
916
                  <block>
917
                     <inline>
918
                        <page-number/>
919
                     </inline>
920
                     <leader rule-thickness="0pt"/>
921
                     <xsl:if test="$divRunningheads='true'">
922
                        <inline>
923
                           <retrieve-marker retrieve-class-name="section1"/>
924
                        </inline>
925
                     </xsl:if>
926
                  </block>
927
               </xsl:when>
928
               <xsl:otherwise>
929
                  <xsl:call-template name="runninghead-author"/>
930
               </xsl:otherwise>
931
            </xsl:choose>
932
         </block>
933
      </static-content>
934
      <static-content flow-name="xsl-region-before-first">
935
         <block/>
936
      </static-content>
937
      <static-content flow-name="xsl-region-after-right">
938
         <block text-align="end" font-size="{$bodySize}">
939
            <page-number/>
940
         </block>
941
      </static-content>
942
      <static-content flow-name="xsl-region-after-left">
943
         <block text-align="start" font-size="{$bodySize}">
944
            <page-number/>
945
         </block>
946
      </static-content>
947
      <static-content flow-name="xsl-region-after-first">
948
         <block font-size="{$bodySize}" text-align="end">
949
            <page-number/>
950
         </block>
951
      </static-content>
952
  </xsl:template>
953
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
954
      <desc>[fo] <param name="runodd">odd page running head</param>
955
         <param name="runeven">even page running head</param>
956
      </desc>
957
   </doc>
958
  <xsl:template name="headers-footers-twoside-back">
959
      <xsl:param name="runodd"/>
960
      <xsl:param name="runeven"/>
961
      <xsl:call-template name="headers-footers-twoside">
962
         <xsl:with-param name="runeven">
963
            <xsl:value-of select="$runeven"/>
964
         </xsl:with-param>
965
         <xsl:with-param name="runodd">
966
            <xsl:value-of select="$runodd"/>
967
         </xsl:with-param>
968
      </xsl:call-template>
969
  </xsl:template>
970
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
971
      <desc>[fo] </desc>
972
   </doc>
973
  <xsl:template name="mainAction">
974
      <xsl:choose>
975
         <xsl:when test="tei:text/tei:group">
976
            <xsl:apply-templates select="tei:text/tei:front"/>
977
            <xsl:apply-templates select="tei:text/tei:group"/>
978
         </xsl:when>
979
         <xsl:otherwise>
980
            <xsl:apply-templates select="tei:text/tei:front"/>
981
            <xsl:apply-templates select="tei:text/tei:body"/>
982
         </xsl:otherwise>
983
      </xsl:choose>
984
      <xsl:apply-templates select="tei:text/tei:back"/>
985
  </xsl:template>
986
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
987
      <desc>[fo] </desc>
988
   </doc>
989
  <xsl:template name="mainTOC">
990
      <block>
991
         <xsl:call-template name="setupDiv1"/>
992
         <xsl:call-template name="i18n">
993
            <xsl:with-param name="word">contentsWord</xsl:with-param>
994
         </xsl:call-template>
995
      </block>
996
      <xsl:choose>
997
         <xsl:when test="ancestor::tei:text/tei:group">
998
            <xsl:for-each select="ancestor::tei:text/tei:group">
999
               <xsl:apply-templates select="tei:text" mode="toc"/>
1000
            </xsl:for-each>
1001
         </xsl:when>
1002
         <xsl:when test="ancestor::tei:text/tei:body/tei:div1">
1003
            <xsl:if test="$tocFront='true'">
1004
               <xsl:for-each select="ancestor::tei:text/tei:front/tei:div1|ancestor::tei:text/tei:front//tei:div2|ancestor::tei:text/tei:front//tei:div3">
1005
                  <xsl:apply-templates mode="toc" select="(.)"/>
1006
               </xsl:for-each>
1007
            </xsl:if>
1008
            <xsl:for-each select="ancestor::tei:text/tei:body/tei:div1|ancestor::tei:text/tei:body//tei:div2|ancestor::tei:text/tei:body//tei:div3">
1009
               <xsl:apply-templates mode="toc" select="(.)"/>
1010
            </xsl:for-each>
1011
            <xsl:if test="$tocBack='true'">
1012
               <xsl:for-each select="ancestor::tei:text/tei:back/tei:div1|ancestor::tei:text/tei:back//tei:div2|ancestor::tei:text/tei:back//tei:div3">
1013
                  <xsl:apply-templates mode="toc" select="(.)"/>
1014
               </xsl:for-each>
1015
            </xsl:if>
1016
         </xsl:when>
1017
         <xsl:otherwise>
1018
            <xsl:call-template name="tocBits"/>
1019
         </xsl:otherwise>
1020
      </xsl:choose>
1021
  </xsl:template>
1022
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
1023
      <desc>[fo] </desc>
1024
   </doc>
1025
  <xsl:template name="runninghead-author">
1026
      <xsl:choose>
1027
         <xsl:when test="ancestor::tei:text[1]/tei:front//tei:docAuthor[@type='running']">
1028
            <xsl:apply-templates select="ancestor-or-self::tei:text[1]/tei:front//tei:docAuthor[@type='running']"
1029
                                 mode="heading"/>
1030
         </xsl:when>
1031
         <xsl:otherwise>
1032
            <xsl:apply-templates select="ancestor-or-self::tei:text[1]/tei:front//tei:docAuthor" mode="heading"/>
1033
         </xsl:otherwise>
1034
      </xsl:choose>
1035
  </xsl:template>
1036
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
1037
      <desc>[fo] </desc>
1038
   </doc>
1039
  <xsl:template name="runninghead-title">
1040
      <xsl:comment>Running Head: title</xsl:comment>
1041
      <xsl:choose>
1042
         <xsl:when test="ancestor-or-self::tei:text[1]/tei:front//tei:docTitle[1]/tei:titlePart[@type='running']">
1043
            <xsl:apply-templates select="ancestor-or-self::tei:text[1]/tei:front//tei:docTitle[1]/tei:titlePart[@type='running']"
1044
                                 mode="heading"/>
1045
         </xsl:when>
1046
         <xsl:otherwise>
1047
            <xsl:apply-templates select="ancestor-or-self::tei:text[1]/tei:front//tei:docTitle[1]/tei:titlePart"
1048
                                 mode="heading"/>
1049
         </xsl:otherwise>
1050
      </xsl:choose>
1051
  </xsl:template>
1052
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
1053
      <desc>[fo] </desc>
1054
   </doc>
1055
  <xsl:template name="setupPagemasters">
1056
      <layout-master-set>
1057
<!-- one sided, single column -->
1058
      <simple-page-master master-name="simple1" page-width="{$pageWidth}" page-height="{$pageHeight}"
1059
                             margin-top="{$pageMarginTop}"
1060
                             margin-bottom="{$pageMarginBottom}"
1061
                             margin-left="{$pageMarginLeft}"
1062
                             margin-right="{$pageMarginRight}">
1063
            <region-body margin-bottom="{$bodyMarginBottom}" margin-top="{$bodyMarginTop}"/>
1064
            <region-before extent="{$regionBeforeExtent}"/>
1065
            <region-after extent="{$regionAfterExtent}"/>
1066
         </simple-page-master>
1067
         <!-- for left-hand/tei:even pages in twosided mode, single column -->
1068
      <simple-page-master master-name="left1" page-width="{$pageWidth}" page-height="{$pageHeight}"
1069
                             margin-top="{$pageMarginTop}"
1070
                             margin-bottom="{$pageMarginBottom}"
1071
                             margin-left="{$pageMarginLeft}"
1072
                             margin-right="{$pageMarginRight}">
1073
            <region-body margin-bottom="{$bodyMarginBottom}" margin-top="{$bodyMarginTop}"/>
1074
            <region-before region-name="xsl-region-before-left" extent="{$regionBeforeExtent}"/>
1075
            <region-after region-name="xsl-region-after-left" extent="{$regionAfterExtent}"/>
1076
         </simple-page-master>
1077
         <!-- for right-hand/tei:odd pages in twosided mode, single column -->
1078
      <simple-page-master master-name="right1" page-width="{$pageWidth}" page-height="{$pageHeight}"
1079
                             margin-top="{$pageMarginTop}"
1080
                             margin-bottom="{$pageMarginBottom}"
1081
                             margin-left="{$pageMarginLeft}"
1082
                             margin-right="{$pageMarginRight}">
1083
            <region-body margin-bottom="{$bodyMarginBottom}" margin-top="{$bodyMarginTop}"/>
1084
            <region-before region-name="xsl-region-before-right" extent="{$regionBeforeExtent}"/>
1085
            <region-after region-name="xsl-region-after-right" extent="{$regionAfterExtent}"/>
1086
         </simple-page-master>
1087
         <!-- special case of first page in either mode, single column -->
1088
      <simple-page-master master-name="first1" page-width="{$pageWidth}" page-height="{$pageHeight}"
1089
                             margin-top="{$pageMarginTop}"
1090
                             margin-bottom="{$pageMarginBottom}"
1091
                             margin-left="{$pageMarginLeft}"
1092
                             margin-right="{$pageMarginRight}">
1093
            <region-body margin-bottom="{$bodyMarginBottom}" margin-top="{$bodyMarginTop}"/>
1094
            <region-before region-name="xsl-region-before-first" extent="{$regionBeforeExtent}"/>
1095
            <region-after region-name="xsl-region-after-first" extent="{$regionAfterExtent}"/>
1096
         </simple-page-master>
1097
         <!-- for pages in one-side mode, 2 column -->
1098
      <simple-page-master master-name="simple2" page-width="{$pageWidth}" page-height="{$pageHeight}"
1099
                             margin-top="{$pageMarginTop}"
1100
                             margin-bottom="{$pageMarginBottom}"
1101
                             margin-left="{$pageMarginLeft}"
1102
                             margin-right="{$pageMarginRight}">
1103
            <region-body column-count="{$columnCount}" margin-bottom="{$bodyMarginBottom}"
1104
                         margin-top="{$bodyMarginTop}"/>
1105
            <region-before extent="{$regionBeforeExtent}"/>
1106
            <region-after extent="{$regionAfterExtent}"/>
1107
         </simple-page-master>
1108
         <!-- for left-hand/tei:even pages in twosided mode, 2 column -->
1109
      <simple-page-master master-name="left2" page-width="{$pageWidth}" page-height="{$pageHeight}"
1110
                             margin-top="{$pageMarginTop}"
1111
                             margin-bottom="{$pageMarginBottom}"
1112
                             margin-left="{$pageMarginLeft}"
1113
                             margin-right="{$pageMarginRight}">
1114
            <region-body column-count="{$columnCount}" margin-bottom="{$bodyMarginBottom}"
1115
                         margin-top="{$bodyMarginTop}"/>
1116
            <region-before region-name="xsl-region-before-left" extent="{$regionBeforeExtent}"/>
1117
            <region-after region-name="xsl-region-after-left" extent="{$regionAfterExtent}"/>
1118
         </simple-page-master>
1119
         <!-- for right-hand/tei:odd pages in twosided mode, 2 column -->
1120
      <simple-page-master master-name="right2" page-width="{$pageWidth}" page-height="{$pageHeight}"
1121
                             margin-top="{$pageMarginTop}"
1122
                             margin-bottom="{$pageMarginBottom}"
1123
                             margin-left="{$pageMarginLeft}"
1124
                             margin-right="{$pageMarginRight}">
1125
            <region-body column-count="{$columnCount}" margin-bottom="{$bodyMarginBottom}"
1126
                         margin-top="{$bodyMarginTop}"/>
1127
            <region-before region-name="xsl-region-before-right" extent="{$regionBeforeExtent}"/>
1128
            <region-after region-name="xsl-region-after-right" extent="{$regionAfterExtent}"/>
1129
         </simple-page-master>
1130
         <!-- special case of first page in either mode -->
1131
      <simple-page-master master-name="first2" page-width="{$pageWidth}" page-height="{$pageHeight}"
1132
                             margin-top="{$pageMarginTop}"
1133
                             margin-bottom="{$pageMarginBottom}"
1134
                             margin-left="{$pageMarginLeft}"
1135
                             margin-right="{$pageMarginRight}">
1136
            <region-body column-count="{$columnCount}" margin-bottom="{$bodyMarginBottom}"
1137
                         margin-top="{$bodyMarginTop}"/>
1138
            <region-before region-name="xsl-region-before-first" extent="{$regionBeforeExtent}"/>
1139
            <region-after region-name="xsl-region-after-first" extent="{$regionAfterExtent}"/>
1140
         </simple-page-master>
1141
         <!-- setup for double-sided, 1 column, no first page -->
1142
      <page-sequence-master master-name="twoside1nofirst">
1143
            <repeatable-page-master-alternatives>
1144
               <conditional-page-master-reference master-reference="right1" odd-or-even="odd"/>
1145
               <conditional-page-master-reference master-reference="left1" odd-or-even="even"/>
1146
            </repeatable-page-master-alternatives>
1147
         </page-sequence-master>
1148
         <!-- setup for double-sided, 1 column -->
1149
      <page-sequence-master master-name="twoside1">
1150
            <repeatable-page-master-alternatives>
1151
               <conditional-page-master-reference master-reference="first1" page-position="first"/>
1152
               <conditional-page-master-reference master-reference="right1" odd-or-even="odd"/>
1153
               <conditional-page-master-reference master-reference="left1" odd-or-even="even"/>
1154
            </repeatable-page-master-alternatives>
1155
         </page-sequence-master>
1156
         <!-- setup for single-sided, 1 column -->
1157
      <page-sequence-master master-name="oneside1">
1158
            <repeatable-page-master-alternatives>
1159
               <conditional-page-master-reference master-reference="first1" page-position="first"/>
1160
               <conditional-page-master-reference master-reference="simple1"/>
1161
            </repeatable-page-master-alternatives>
1162
         </page-sequence-master>
1163
         <!-- setup for double-sided, 2 column -->
1164
      <page-sequence-master master-name="twoside2">
1165
            <repeatable-page-master-alternatives>
1166
               <conditional-page-master-reference master-reference="first2" page-position="first"/>
1167
               <conditional-page-master-reference master-reference="right2" odd-or-even="odd"/>
1168
               <conditional-page-master-reference master-reference="left2" odd-or-even="even"/>
1169
            </repeatable-page-master-alternatives>
1170
         </page-sequence-master>
1171
         <!-- setup for single-sided, 2 column -->
1172
      <page-sequence-master master-name="oneside2">
1173
            <repeatable-page-master-alternatives>
1174
               <conditional-page-master-reference master-reference="first2" page-position="first"/>
1175
               <conditional-page-master-reference master-reference="simple2"/>
1176
            </repeatable-page-master-alternatives>
1177
         </page-sequence-master>
1178
         <xsl:call-template name="pageMasterHook"/>
1179
      </layout-master-set>
1180
      <xsl:if test="$foEngine='xep'">
1181
<!-- PDF bookmarks using XEP -->
1182
      <outline xmlns="http://www.renderx.com/XSL/Extensions">
1183
            <xsl:for-each select="/tei:TEI/tei:text/tei:front/tei:div">
1184
               <xsl:call-template name="makeBookMark"/>
1185
            </xsl:for-each>
1186
            <xsl:for-each select="/tei:TEI/tei:text/tei:body/tei:div">
1187
               <xsl:call-template name="makeBookMark"/>
1188
            </xsl:for-each>
1189
            <xsl:for-each select="/tei:TEI/tei:text/tei:back/tei:div">
1190
               <xsl:call-template name="makeBookMark"/>
1191
            </xsl:for-each>
1192
            <!-- now try numbered divs -->
1193
        <xsl:for-each select="/tei:TEI/tei:text/tei:front/tei:div1">
1194
               <xsl:call-template name="makeBookMarkN"/>
1195
            </xsl:for-each>
1196
            <xsl:for-each select="/tei:TEI/tei:text/tei:body/tei:div1">
1197
               <xsl:call-template name="makeBookMarkN"/>
1198
            </xsl:for-each>
1199
            <xsl:for-each select="/tei:TEI/tei:text/tei:back/tei:div1">
1200
               <xsl:call-template name="makeBookMarkN"/>
1201
            </xsl:for-each>
1202
         </outline>
1203
      </xsl:if>
1204
  </xsl:template>
1205
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
1206
      <desc>[fo] Make an XEP bookmark</desc>
1207
   </doc>
1208
  <xsl:template name="makeBookMark">
1209
      <xsl:if test="tei:head">
1210
         <bookmark xmlns="http://www.renderx.com/XSL/Extensions">
1211
            <xsl:variable name="depth" select="count(ancestor::tei:div)"/>
1212
            <xsl:attribute name="internal-destination">
1213
               <xsl:choose>
1214
                  <xsl:when test="@xml:id">
1215
                     <xsl:value-of select="@xml:id"/>
1216
                  </xsl:when>
1217
                  <xsl:otherwise>
1218
                     <xsl:value-of select="generate-id()"/>
1219
                  </xsl:otherwise>
1220
               </xsl:choose>
1221
            </xsl:attribute>
1222
            <bookmark-label>
1223
               <xsl:if test="$numberHeadings='true' and $numberHeadingsDepth &gt; $depth">
1224
                  <xsl:call-template name="calculateNumber">
1225
                     <xsl:with-param name="numbersuffix">
1226
		                      <xsl:call-template name="headingNumberSuffix"/>
1227
	                    </xsl:with-param>
1228
                  </xsl:call-template>
1229
                  <xsl:text> </xsl:text>
1230
               </xsl:if>
1231
               <xsl:value-of select="tei:head"/>
1232
            </bookmark-label>
1233
            <xsl:for-each select="tei:div">
1234
               <xsl:call-template name="makeBookMark"/>
1235
            </xsl:for-each>
1236
         </bookmark>
1237
      </xsl:if>
1238
  </xsl:template>
1239
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
1240
      <desc>[fo] Make an XEP bookmark for numbered divs</desc>
1241
   </doc>
1242
  <xsl:template name="makeBookMarkN">
1243
      <xsl:if test="tei:head">
1244
         <xsl:variable name="depth" select="substring-after(local-name(.),'div')"/>
1245
         <bookmark xmlns="http://www.renderx.com/XSL/Extensions">
1246
            <xsl:attribute name="internal-destination">
1247
               <xsl:choose>
1248
                  <xsl:when test="@xml:id">
1249
                     <xsl:value-of select="@xml:id"/>
1250
                  </xsl:when>
1251
                  <xsl:otherwise>
1252
                     <xsl:value-of select="generate-id()"/>
1253
                  </xsl:otherwise>
1254
               </xsl:choose>
1255
            </xsl:attribute>
1256
            <bookmark-label>
1257
               <xsl:if test="$numberHeadings='true' and $numberHeadingsDepth &gt; $depth">
1258
                  <xsl:call-template name="calculateNumber">
1259
                     <xsl:with-param name="numbersuffix">
1260
		                      <xsl:call-template name="headingNumberSuffix"/>
1261
	                    </xsl:with-param>
1262
                  </xsl:call-template>
1263
                  <xsl:text> </xsl:text>
1264
               </xsl:if>
1265
               <xsl:value-of select="tei:head"/>
1266
            </bookmark-label>
1267
            <xsl:choose>
1268
               <xsl:when test="$depth='0'">
1269
                  <xsl:for-each select="tei:div1">
1270
                     <xsl:call-template name="makeBookMarkN"/>
1271
                  </xsl:for-each>
1272
               </xsl:when>
1273
               <xsl:when test="$depth='1'">
1274
                  <xsl:for-each select="tei:div2">
1275
                     <xsl:call-template name="makeBookMarkN"/>
1276
                  </xsl:for-each>
1277
               </xsl:when>
1278
               <xsl:when test="$depth='2'">
1279
                  <xsl:for-each select="tei:div3">
1280
                     <xsl:call-template name="makeBookMarkN"/>
1281
                  </xsl:for-each>
1282
               </xsl:when>
1283
               <xsl:when test="$depth='3'">
1284
                  <xsl:for-each select="tei:div4">
1285
                     <xsl:call-template name="makeBookMarkN"/>
1286
                  </xsl:for-each>
1287
               </xsl:when>
1288
               <xsl:when test="$depth='4'">
1289
                  <xsl:for-each select="tei:div5">
1290
                     <xsl:call-template name="makeBookMarkN"/>
1291
                  </xsl:for-each>
1292
               </xsl:when>
1293
               <xsl:when test="$depth='5'">
1294
                  <xsl:for-each select="tei:div6">
1295
                     <xsl:call-template name="makeBookMarkN"/>
1296
                  </xsl:for-each>
1297
               </xsl:when>
1298
            </xsl:choose>
1299
         </bookmark>
1300
      </xsl:if>
1301
  </xsl:template>
1302
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
1303
      <desc>[fo] </desc>
1304
   </doc>
1305
  <xsl:template name="tocBits">
1306
      <xsl:if test="$tocFront='true'">
1307
         <xsl:for-each select="ancestor::tei:text/tei:front//tei:div">
1308
            <xsl:apply-templates mode="toc" select="(.)"/>
1309
         </xsl:for-each>
1310
      </xsl:if>
1311
      <xsl:for-each select="ancestor::tei:text/tei:body//tei:div">
1312
         <xsl:apply-templates mode="toc" select="(.)"/>
1313
      </xsl:for-each>
1314
      <xsl:if test="$tocBack='true'">
1315
         <xsl:for-each select="ancestor::tei:text/tei:back//tei:div">
1316
            <xsl:apply-templates mode="toc" select="(.)"/>
1317
         </xsl:for-each>
1318
      </xsl:if>
1319
  </xsl:template>
1320
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
1321
      <desc>[fo] <param name="level">level</param>
1322
      </desc>
1323
   </doc>
1324
  <xsl:template name="tocheading">
1325
      <xsl:param name="level"/>
1326
      <xsl:variable name="tocindent">
1327
         <xsl:choose>
1328
            <xsl:when test="$level='0'">
1329
               <xsl:value-of select="$div0Tocindent"/>
1330
            </xsl:when>
1331
            <xsl:when test="$level='1'">
1332
               <xsl:value-of select="$div1Tocindent"/>
1333
            </xsl:when>
1334
            <xsl:when test="$level='2'">
1335
               <xsl:value-of select="$div2Tocindent"/>
1336
            </xsl:when>
1337
            <xsl:when test="$level='3'">
1338
               <xsl:value-of select="$div3Tocindent"/>
1339
            </xsl:when>
1340
            <xsl:when test="$level='4'">
1341
               <xsl:value-of select="$div4Tocindent"/>
1342
            </xsl:when>
1343
            <xsl:when test="$level='5'">
1344
               <xsl:value-of select="$div5Tocindent"/>
1345
            </xsl:when>
1346
            <xsl:otherwise>
1347
               <xsl:value-of select="$div1Tocindent"/>
1348
            </xsl:otherwise>
1349
         </xsl:choose>
1350
      </xsl:variable>
1351
      <block>
1352
         <xsl:if test="$level='0'">
1353
            <xsl:attribute name="font-weight">bold</xsl:attribute>
1354
         </xsl:if>
1355
         <xsl:attribute name="text-indent">
1356
            <xsl:value-of select="$tocindent"/>
1357
         </xsl:attribute>
1358
         <xsl:variable name="Number">
1359
            <xsl:if test="$numberHeadings='true' and $numberHeadingsDepth &gt; $level">
1360
               <xsl:call-template name="calculateNumber">
1361
                  <xsl:with-param name="numbersuffix" select="$tocNumberSuffix"/>
1362
               </xsl:call-template>
1363
            </xsl:if>
1364
         </xsl:variable>
1365
         <xsl:value-of select="$Number"/>
1366
         <xsl:text> </xsl:text>
1367
         <inline>
1368
            <xsl:apply-templates mode="section" select="tei:head"/>
1369
         </inline>
1370
         <leader rule-thickness="0pt"/>
1371
         <inline>
1372
            <xsl:call-template name="linkStyle"/>
1373
            <xsl:variable name="pagref">
1374
               <xsl:choose>
1375
                  <xsl:when test="@xml:id">
1376
                     <xsl:value-of select="@xml:id"/>
1377
                  </xsl:when>
1378
                  <xsl:otherwise>
1379
                     <xsl:value-of select="generate-id()"/>
1380
                  </xsl:otherwise>
1381
               </xsl:choose>
1382
            </xsl:variable>
1383
            <basic-link internal-destination="{$pagref}">
1384
               <page-number-citation ref-id="{$pagref}"/>
1385
            </basic-link>
1386
         </inline>
1387
      </block>
1388
  </xsl:template>
1389
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
1390
      <desc>[fo] <param name="level">level</param>
1391
      </desc>
1392
   </doc>
1393
  <xsl:template name="xheading">
1394
      <xsl:param name="level"/>
1395
      <xsl:if test="$numberHeadings='true'">
1396
         <xsl:call-template name="calculateNumber"/>
1397
      </xsl:if>
1398
      <xsl:call-template name="divXRefHeading"/>
1399
  </xsl:template>
1400

    
1401
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
1402
      <desc>[fo] Work out the number of a section <param name="numbersuffix">suffix to add after number (typically ". ")</param>
1403
      </desc>
1404
   </doc>
1405
  <xsl:template name="calculateNumber">
1406
      <xsl:param name="numbersuffix"/>
1407
      <xsl:choose>
1408
         <xsl:when test="$prenumberedHeadings='true' and @n">
1409
            <xsl:value-of select="@n"/>
1410
            <xsl:value-of select="$numbersuffix"/>
1411
         </xsl:when>
1412
         <xsl:when test="ancestor::tei:front">
1413
            <xsl:if test="not($numberFrontHeadings='')">
1414
               <xsl:number count="tei:div|tei:div1|tei:div2|tei:div3|tei:div4"
1415
                           format="{$numberFrontHeadings}"
1416
                           from="tei:front"
1417
                           level="multiple"/>
1418
               <xsl:value-of select="$numbersuffix"/>
1419
            </xsl:if>
1420
         </xsl:when>
1421
         <xsl:when test="ancestor::tei:back">
1422
            <xsl:if test="not($numberBackHeadings='')">
1423
               <xsl:call-template name="i18n">
1424
                  <xsl:with-param name="word">appendixWords</xsl:with-param>
1425
               </xsl:call-template>
1426
               <xsl:text> </xsl:text>
1427
               <xsl:number count="tei:div|tei:div1|tei:div2|tei:div3|tei:div4"
1428
                           format="{$numberBackHeadings}"
1429
                           from="tei:back"
1430
                           level="multiple"/>
1431
               <xsl:value-of select="$numbersuffix"/>
1432
            </xsl:if>
1433
         </xsl:when>
1434
         <xsl:otherwise>
1435
            <xsl:number count="tei:div|tei:div1|tei:div2|tei:div3|tei:div4" from="tei:body"
1436
                        level="multiple"/>
1437
	           <xsl:value-of select="$numbersuffix"/>
1438
         </xsl:otherwise>
1439
      </xsl:choose>
1440
  </xsl:template>
1441

    
1442
</xsl:stylesheet>