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                xmlns:axf="http://www.antennahouse.com/names/XSL/Extensions"
5                version='1.0'>
6
7<!-- ********************************************************************
8     $Id: sections.xsl,v 1.43 2005/12/29 19:14:15 bobstayton Exp $
9     ********************************************************************
10
11     This file is part of the XSL DocBook Stylesheet distribution.
12     See ../README or http://nwalsh.com/docbook/xsl/ for copyright
13     and other information.
14
15     ******************************************************************** -->
16
17<!-- ==================================================================== -->
18
19<xsl:template match="section">
20  <xsl:choose>
21    <xsl:when test="$rootid = @id">
22      <xsl:call-template name="section.page.sequence"/>
23    </xsl:when>
24    <xsl:otherwise>
25      <xsl:variable name="id">
26        <xsl:call-template name="object.id"/>
27      </xsl:variable>
28
29      <xsl:variable name="renderas">
30        <xsl:choose>
31          <xsl:when test="@renderas = 'sect1'">1</xsl:when>
32          <xsl:when test="@renderas = 'sect2'">2</xsl:when>
33          <xsl:when test="@renderas = 'sect3'">3</xsl:when>
34          <xsl:when test="@renderas = 'sect4'">4</xsl:when>
35          <xsl:when test="@renderas = 'sect5'">5</xsl:when>
36          <xsl:otherwise><xsl:value-of select="''"/></xsl:otherwise>
37        </xsl:choose>
38      </xsl:variable>
39
40      <xsl:variable name="level">
41        <xsl:choose>
42          <xsl:when test="$renderas != ''">
43            <xsl:value-of select="$renderas"/>
44          </xsl:when>
45          <xsl:otherwise>
46            <xsl:call-template name="section.level"/>
47          </xsl:otherwise>
48        </xsl:choose>
49      </xsl:variable>
50
51      <!-- xsl:use-attribute-sets takes only a Qname, not a variable -->
52      <xsl:choose>
53        <xsl:when test="$level = 1">
54          <fo:block id="{$id}"
55                    xsl:use-attribute-sets="section.level1.properties">
56            <xsl:call-template name="section.content"/>
57          </fo:block>
58        </xsl:when>
59        <xsl:when test="$level = 2">
60          <fo:block id="{$id}"
61                    xsl:use-attribute-sets="section.level2.properties">
62            <xsl:call-template name="section.content"/>
63          </fo:block>
64        </xsl:when>
65        <xsl:when test="$level = 3">
66          <fo:block id="{$id}"
67                    xsl:use-attribute-sets="section.level3.properties">
68            <xsl:call-template name="section.content"/>
69          </fo:block>
70        </xsl:when>
71        <xsl:when test="$level = 4">
72          <fo:block id="{$id}"
73                    xsl:use-attribute-sets="section.level4.properties">
74            <xsl:call-template name="section.content"/>
75          </fo:block>
76        </xsl:when>
77        <xsl:when test="$level = 5">
78          <fo:block id="{$id}"
79                    xsl:use-attribute-sets="section.level5.properties">
80            <xsl:call-template name="section.content"/>
81          </fo:block>
82        </xsl:when>
83        <xsl:otherwise>
84          <fo:block id="{$id}"
85                    xsl:use-attribute-sets="section.level6.properties">
86            <xsl:call-template name="section.content"/>
87          </fo:block>
88        </xsl:otherwise>
89      </xsl:choose>
90    </xsl:otherwise>
91  </xsl:choose>
92</xsl:template>
93
94<xsl:template name="section.content">
95  <xsl:call-template name="section.titlepage"/>
96
97  <xsl:variable name="toc.params">
98    <xsl:call-template name="find.path.params">
99      <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
100    </xsl:call-template>
101  </xsl:variable>
102
103  <xsl:if test="contains($toc.params, 'toc')
104                and (count(ancestor::section)+1) &lt;= 
105		$generate.section.toc.level">
106    <xsl:call-template name="section.toc">
107      <xsl:with-param name="toc.title.p" 
108                      select="contains($toc.params, 'title')"/>
109    </xsl:call-template>
110   <xsl:call-template name="section.toc.separator"/>
111  </xsl:if>
112
113  <xsl:apply-templates/>
114</xsl:template>
115
116<xsl:template match="section[not(parent::*)]" name="section.page.sequence">
117  <xsl:variable name="id">
118    <xsl:call-template name="object.id">
119      <xsl:with-param name="object" select="ancestor::reference"/>
120    </xsl:call-template>
121  </xsl:variable>
122  <xsl:variable name="master-reference">
123    <xsl:call-template name="select.pagemaster"/>
124  </xsl:variable>
125
126  <fo:page-sequence hyphenate="{$hyphenate}"
127                    master-reference="{$master-reference}">
128    <xsl:attribute name="language">
129      <xsl:call-template name="l10n.language"/>
130    </xsl:attribute>
131    <xsl:attribute name="format">
132      <xsl:call-template name="page.number.format">
133        <xsl:with-param name="master-reference" select="$master-reference"/>
134      </xsl:call-template>
135    </xsl:attribute>
136
137    <xsl:attribute name="initial-page-number">
138      <xsl:call-template name="initial.page.number">
139        <xsl:with-param name="master-reference" select="$master-reference"/>
140      </xsl:call-template>
141    </xsl:attribute>
142
143    <xsl:attribute name="force-page-count">
144      <xsl:call-template name="force.page.count">
145        <xsl:with-param name="master-reference" select="$master-reference"/>
146      </xsl:call-template>
147    </xsl:attribute>
148
149    <xsl:attribute name="hyphenation-character">
150      <xsl:call-template name="gentext">
151        <xsl:with-param name="key" select="'hyphenation-character'"/>
152      </xsl:call-template>
153    </xsl:attribute>
154    <xsl:attribute name="hyphenation-push-character-count">
155      <xsl:call-template name="gentext">
156        <xsl:with-param name="key" select="'hyphenation-push-character-count'"/>
157      </xsl:call-template>
158    </xsl:attribute>
159    <xsl:attribute name="hyphenation-remain-character-count">
160      <xsl:call-template name="gentext">
161        <xsl:with-param name="key" select="'hyphenation-remain-character-count'"/>
162      </xsl:call-template>
163    </xsl:attribute>
164
165    <xsl:apply-templates select="." mode="running.head.mode">
166      <xsl:with-param name="master-reference" select="$master-reference"/>
167    </xsl:apply-templates>
168    <xsl:apply-templates select="." mode="running.foot.mode">
169      <xsl:with-param name="master-reference" select="$master-reference"/>
170    </xsl:apply-templates>
171
172    <fo:flow flow-name="xsl-region-body">
173      <xsl:call-template name="set.flow.properties">
174        <xsl:with-param name="element" select="local-name(.)"/>
175        <xsl:with-param name="master-reference" select="$master-reference"/>
176      </xsl:call-template>
177
178      <fo:block id="{$id}" 
179            xsl:use-attribute-sets="section.level1.properties">
180        <xsl:call-template name="section.titlepage"/>
181      </fo:block>
182
183      <xsl:variable name="toc.params">
184        <xsl:call-template name="find.path.params">
185          <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
186        </xsl:call-template>
187      </xsl:variable>
188
189      <xsl:if test="contains($toc.params, 'toc')
190                    and (count(ancestor::section)+1) &lt;= 
191		    $generate.section.toc.level">
192        <xsl:call-template name="section.toc">
193          <xsl:with-param name="toc.title.p" 
194                          select="contains($toc.params, 'title')"/>
195        </xsl:call-template>
196        <xsl:call-template name="section.toc.separator"/>
197      </xsl:if>
198
199      <xsl:apply-templates/>
200   </fo:flow>
201  </fo:page-sequence>
202</xsl:template>
203
204<xsl:template match="section/title
205                     |simplesect/title
206                     |sect1/title
207                     |sect2/title
208                     |sect3/title
209                     |sect4/title
210                     |sect5/title"
211              mode="titlepage.mode"
212              priority="2">
213  <xsl:variable name="section" select="parent::*"/>
214  <fo:block keep-with-next.within-column="always">
215    <xsl:variable name="id">
216      <xsl:call-template name="object.id">
217        <xsl:with-param name="object" select="$section"/>
218      </xsl:call-template>
219    </xsl:variable>
220
221    <xsl:variable name="renderas">
222      <xsl:choose>
223        <xsl:when test="$section/@renderas = 'sect1'">1</xsl:when>
224        <xsl:when test="$section/@renderas = 'sect2'">2</xsl:when>
225        <xsl:when test="$section/@renderas = 'sect3'">3</xsl:when>
226        <xsl:when test="$section/@renderas = 'sect4'">4</xsl:when>
227        <xsl:when test="$section/@renderas = 'sect5'">5</xsl:when>
228        <xsl:otherwise><xsl:value-of select="''"/></xsl:otherwise>
229      </xsl:choose>
230    </xsl:variable>
231  
232    <xsl:variable name="level">
233      <xsl:choose>
234        <xsl:when test="$renderas != ''">
235          <xsl:value-of select="$renderas"/>
236        </xsl:when>
237        <xsl:otherwise>
238          <xsl:call-template name="section.level">
239            <xsl:with-param name="node" select="$section"/>
240          </xsl:call-template>
241        </xsl:otherwise>
242      </xsl:choose>
243    </xsl:variable>
244
245    <xsl:variable name="marker">
246      <xsl:choose>
247        <xsl:when test="$level &lt;= $marker.section.level">1</xsl:when>
248        <xsl:otherwise>0</xsl:otherwise>
249      </xsl:choose>
250    </xsl:variable>
251
252    <xsl:variable name="title">
253      <xsl:apply-templates select="$section" mode="object.title.markup">
254        <xsl:with-param name="allow-anchors" select="1"/>
255      </xsl:apply-templates>
256    </xsl:variable>
257
258    <xsl:variable name="marker.title">
259      <xsl:apply-templates select="$section" mode="titleabbrev.markup">
260        <xsl:with-param name="allow-anchors" select="0"/>
261      </xsl:apply-templates>
262    </xsl:variable>
263
264    <xsl:if test="$passivetex.extensions != 0">
265      <fotex:bookmark xmlns:fotex="http://www.tug.org/fotex" 
266                      fotex-bookmark-level="{$level + 2}" 
267                      fotex-bookmark-label="{$id}">
268        <xsl:value-of select="$marker.title"/>
269      </fotex:bookmark>
270    </xsl:if>
271
272    <xsl:if test="$axf.extensions != 0">
273      <xsl:attribute name="axf:outline-level">
274        <xsl:value-of select="count(ancestor::*)-1"/>
275      </xsl:attribute>
276      <xsl:attribute name="axf:outline-expand">false</xsl:attribute>
277      <xsl:attribute name="axf:outline-title">
278        <xsl:value-of select="normalize-space($title)"/>
279      </xsl:attribute>
280    </xsl:if>
281
282    <xsl:call-template name="section.heading">
283      <xsl:with-param name="level" select="$level"/>
284      <xsl:with-param name="title" select="$title"/>
285      <xsl:with-param name="marker" select="$marker"/>
286      <xsl:with-param name="marker.title" select="$marker.title"/>
287    </xsl:call-template>
288  </fo:block>
289</xsl:template>
290
291<xsl:template match="sect1">
292  <xsl:variable name="id">
293    <xsl:call-template name="object.id"/>
294  </xsl:variable>
295
296  <fo:block id="{$id}" 
297            xsl:use-attribute-sets="section.level1.properties">
298    <xsl:call-template name="sect1.titlepage"/>
299
300    <xsl:variable name="toc.params">
301      <xsl:call-template name="find.path.params">
302        <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
303      </xsl:call-template>
304    </xsl:variable>
305
306    <xsl:if test="contains($toc.params, 'toc')
307                  and $generate.section.toc.level &gt;= 1">
308      <xsl:call-template name="section.toc">
309        <xsl:with-param name="toc.title.p" 
310                        select="contains($toc.params, 'title')"/>
311      </xsl:call-template>
312      <xsl:call-template name="section.toc.separator"/>
313    </xsl:if>
314
315    <xsl:apply-templates/>
316  </fo:block>
317</xsl:template>
318
319<xsl:template match="/sect1">
320  <xsl:variable name="id">
321    <xsl:call-template name="object.id">
322      <xsl:with-param name="object" select="ancestor::reference"/>
323    </xsl:call-template>
324  </xsl:variable>
325  <xsl:variable name="master-reference">
326    <xsl:call-template name="select.pagemaster"/>
327  </xsl:variable>
328
329  <fo:page-sequence hyphenate="{$hyphenate}"
330                    master-reference="{$master-reference}">
331    <xsl:attribute name="language">
332      <xsl:call-template name="l10n.language"/>
333    </xsl:attribute>
334    <xsl:attribute name="format">
335      <xsl:call-template name="page.number.format">
336        <xsl:with-param name="master-reference" select="$master-reference"/>
337      </xsl:call-template>
338    </xsl:attribute>
339
340    <xsl:attribute name="initial-page-number">
341      <xsl:call-template name="initial.page.number">
342        <xsl:with-param name="master-reference" select="$master-reference"/>
343      </xsl:call-template>
344    </xsl:attribute>
345
346    <xsl:attribute name="force-page-count">
347      <xsl:call-template name="force.page.count">
348        <xsl:with-param name="master-reference" select="$master-reference"/>
349      </xsl:call-template>
350    </xsl:attribute>
351
352    <xsl:attribute name="hyphenation-character">
353      <xsl:call-template name="gentext">
354        <xsl:with-param name="key" select="'hyphenation-character'"/>
355      </xsl:call-template>
356    </xsl:attribute>
357    <xsl:attribute name="hyphenation-push-character-count">
358      <xsl:call-template name="gentext">
359        <xsl:with-param name="key" select="'hyphenation-push-character-count'"/>
360      </xsl:call-template>
361    </xsl:attribute>
362    <xsl:attribute name="hyphenation-remain-character-count">
363      <xsl:call-template name="gentext">
364        <xsl:with-param name="key" select="'hyphenation-remain-character-count'"/>
365      </xsl:call-template>
366    </xsl:attribute>
367
368    <xsl:apply-templates select="." mode="running.head.mode">
369      <xsl:with-param name="master-reference" select="$master-reference"/>
370    </xsl:apply-templates>
371    <xsl:apply-templates select="." mode="running.foot.mode">
372      <xsl:with-param name="master-reference" select="$master-reference"/>
373    </xsl:apply-templates>
374
375    <fo:flow flow-name="xsl-region-body">
376      <xsl:call-template name="set.flow.properties">
377        <xsl:with-param name="element" select="local-name(.)"/>
378        <xsl:with-param name="master-reference" select="$master-reference"/>
379      </xsl:call-template>
380
381      <fo:block id="{$id}" 
382                xsl:use-attribute-sets="section.level1.properties">
383        <xsl:call-template name="sect1.titlepage"/>
384      </fo:block>
385
386      <xsl:variable name="toc.params">
387        <xsl:call-template name="find.path.params">
388          <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
389        </xsl:call-template>
390      </xsl:variable>
391
392      <xsl:if test="contains($toc.params, 'toc')
393                    and $generate.section.toc.level &gt;= 1">
394        <xsl:call-template name="section.toc">
395          <xsl:with-param name="toc.title.p" 
396                          select="contains($toc.params, 'title')"/>
397        </xsl:call-template>
398        <xsl:call-template name="section.toc.separator"/>
399      </xsl:if>
400
401      <xsl:apply-templates/>
402   </fo:flow>
403  </fo:page-sequence>
404</xsl:template>
405
406<xsl:template match="sect2">
407  <xsl:variable name="id">
408    <xsl:call-template name="object.id"/>
409  </xsl:variable>
410
411  <fo:block id="{$id}" 
412            xsl:use-attribute-sets="section.level2.properties">
413    <xsl:call-template name="sect2.titlepage"/>
414
415    <xsl:variable name="toc.params">
416      <xsl:call-template name="find.path.params">
417        <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
418      </xsl:call-template>
419    </xsl:variable>
420
421    <xsl:if test="contains($toc.params, 'toc')
422                   and $generate.section.toc.level &gt;= 2">
423      <xsl:call-template name="section.toc">
424        <xsl:with-param name="toc.title.p" 
425                        select="contains($toc.params, 'title')"/>
426      </xsl:call-template>
427      <xsl:call-template name="section.toc.separator"/>
428    </xsl:if>
429
430    <xsl:apply-templates/>
431  </fo:block>
432</xsl:template>
433
434<xsl:template match="sect3">
435  <xsl:variable name="id">
436    <xsl:call-template name="object.id"/>
437  </xsl:variable>
438
439  <fo:block id="{$id}" 
440            xsl:use-attribute-sets="section.level3.properties">
441    <xsl:call-template name="sect3.titlepage"/>
442
443    <xsl:variable name="toc.params">
444      <xsl:call-template name="find.path.params">
445        <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
446      </xsl:call-template>
447    </xsl:variable>
448
449    <xsl:if test="contains($toc.params, 'toc')
450                  and $generate.section.toc.level &gt;= 3">
451      <xsl:call-template name="section.toc">
452        <xsl:with-param name="toc.title.p" 
453                        select="contains($toc.params, 'title')"/>
454      </xsl:call-template>
455      <xsl:call-template name="section.toc.separator"/>
456    </xsl:if>
457
458    <xsl:apply-templates/>
459  </fo:block>
460</xsl:template>
461
462<xsl:template match="sect4">
463  <xsl:variable name="id">
464    <xsl:call-template name="object.id"/>
465  </xsl:variable>
466
467  <fo:block id="{$id}" 
468            xsl:use-attribute-sets="section.level4.properties">
469    <xsl:call-template name="sect4.titlepage"/>
470
471    <xsl:variable name="toc.params">
472      <xsl:call-template name="find.path.params">
473        <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
474      </xsl:call-template>
475    </xsl:variable>
476
477    <xsl:if test="contains($toc.params, 'toc')
478                  and $generate.section.toc.level &gt;= 4">
479      <xsl:call-template name="section.toc">
480        <xsl:with-param name="toc.title.p" 
481                        select="contains($toc.params, 'title')"/>
482      </xsl:call-template>
483      <xsl:call-template name="section.toc.separator"/>
484    </xsl:if>
485
486    <xsl:apply-templates/>
487  </fo:block>
488</xsl:template>
489
490<xsl:template match="sect5">
491  <xsl:variable name="id">
492    <xsl:call-template name="object.id"/>
493  </xsl:variable>
494
495  <fo:block id="{$id}" 
496            xsl:use-attribute-sets="section.level5.properties">
497    <xsl:call-template name="sect5.titlepage"/>
498
499    <xsl:variable name="toc.params">
500      <xsl:call-template name="find.path.params">
501        <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
502      </xsl:call-template>
503    </xsl:variable>
504
505    <xsl:if test="contains($toc.params, 'toc')
506                  and $generate.section.toc.level &gt;= 5">
507      <xsl:call-template name="section.toc">
508        <xsl:with-param name="toc.title.p" 
509                        select="contains($toc.params, 'title')"/>
510      </xsl:call-template>
511      <xsl:call-template name="section.toc.separator"/>
512    </xsl:if>
513
514    <xsl:apply-templates/>
515  </fo:block>
516</xsl:template>
517
518<xsl:template match="simplesect">
519  <xsl:variable name="id">
520    <xsl:call-template name="object.id"/>
521  </xsl:variable>
522
523  <fo:block id="{$id}">
524    <xsl:call-template name="simplesect.titlepage"/>
525    <xsl:apply-templates/>
526  </fo:block>
527</xsl:template>
528
529<xsl:template match="sectioninfo"></xsl:template>
530<xsl:template match="section/title"></xsl:template>
531<xsl:template match="section/titleabbrev"></xsl:template>
532<xsl:template match="section/subtitle"></xsl:template>
533
534<xsl:template match="sect1info"></xsl:template>
535<xsl:template match="sect1/title"></xsl:template>
536<xsl:template match="sect1/titleabbrev"></xsl:template>
537<xsl:template match="sect1/subtitle"></xsl:template>
538
539<xsl:template match="sect2info"></xsl:template>
540<xsl:template match="sect2/title"></xsl:template>
541<xsl:template match="sect2/titleabbrev"></xsl:template>
542<xsl:template match="sect2/subtitle"></xsl:template>
543
544<xsl:template match="sect3info"></xsl:template>
545<xsl:template match="sect3/title"></xsl:template>
546<xsl:template match="sect3/titleabbrev"></xsl:template>
547<xsl:template match="sect3/subtitle"></xsl:template>
548
549<xsl:template match="sect4info"></xsl:template>
550<xsl:template match="sect4/title"></xsl:template>
551<xsl:template match="sect4/titleabbrev"></xsl:template>
552<xsl:template match="sect4/subtitle"></xsl:template>
553
554<xsl:template match="sect5info"></xsl:template>
555<xsl:template match="sect5/title"></xsl:template>
556<xsl:template match="sect5/titleabbrev"></xsl:template>
557<xsl:template match="sect5/subtitle"></xsl:template>
558
559<xsl:template match="simplesect/title"></xsl:template>
560<xsl:template match="simplesect/titleabbrev"></xsl:template>
561<xsl:template match="simplesect/subtitle"></xsl:template>
562
563<!-- ==================================================================== -->
564
565<xsl:template name="section.heading">
566  <xsl:param name="level" select="1"/>
567  <xsl:param name="marker" select="1"/>
568  <xsl:param name="title"/>
569  <xsl:param name="marker.title"/>
570
571  <fo:block xsl:use-attribute-sets="section.title.properties">
572    <xsl:if test="$marker != 0">
573      <fo:marker marker-class-name="section.head.marker">
574        <xsl:copy-of select="$marker.title"/>
575      </fo:marker>
576    </xsl:if>
577
578    <xsl:choose>
579      <xsl:when test="$level=1">
580        <fo:block xsl:use-attribute-sets="section.title.level1.properties">
581          <xsl:copy-of select="$title"/>
582        </fo:block>
583      </xsl:when>
584      <xsl:when test="$level=2">
585        <fo:block xsl:use-attribute-sets="section.title.level2.properties">
586          <xsl:copy-of select="$title"/>
587        </fo:block>
588      </xsl:when>
589      <xsl:when test="$level=3">
590        <fo:block xsl:use-attribute-sets="section.title.level3.properties">
591          <xsl:copy-of select="$title"/>
592        </fo:block>
593      </xsl:when>
594      <xsl:when test="$level=4">
595        <fo:block xsl:use-attribute-sets="section.title.level4.properties">
596          <xsl:copy-of select="$title"/>
597        </fo:block>
598      </xsl:when>
599      <xsl:when test="$level=5">
600        <fo:block xsl:use-attribute-sets="section.title.level5.properties">
601          <xsl:copy-of select="$title"/>
602        </fo:block>
603      </xsl:when>
604      <xsl:otherwise>
605        <fo:block xsl:use-attribute-sets="section.title.level6.properties">
606          <xsl:copy-of select="$title"/>
607        </fo:block>
608      </xsl:otherwise>
609    </xsl:choose>
610  </fo:block>
611</xsl:template>
612
613<!-- ==================================================================== -->
614
615<xsl:template match="bridgehead">
616  <xsl:variable name="container"
617                select="(ancestor::appendix
618                        |ancestor::article
619                        |ancestor::bibliography
620                        |ancestor::chapter
621                        |ancestor::glossary
622                        |ancestor::glossdiv
623                        |ancestor::index
624                        |ancestor::partintro
625                        |ancestor::preface
626                        |ancestor::refsect1
627                        |ancestor::refsect2
628                        |ancestor::refsect3
629                        |ancestor::sect1
630                        |ancestor::sect2
631                        |ancestor::sect3
632                        |ancestor::sect4
633                        |ancestor::sect5
634                        |ancestor::section
635                        |ancestor::setindex
636                        |ancestor::simplesect)[last()]"/>
637
638  <xsl:variable name="clevel">
639    <xsl:choose>
640      <xsl:when test="local-name($container) = 'appendix'
641                      or local-name($container) = 'chapter'
642                      or local-name($container) = 'article'
643                      or local-name($container) = 'bibliography'
644                      or local-name($container) = 'glossary'
645                      or local-name($container) = 'index'
646                      or local-name($container) = 'partintro'
647                      or local-name($container) = 'preface'
648                      or local-name($container) = 'setindex'">2</xsl:when>
649      <xsl:when test="local-name($container) = 'glossdiv'">
650        <xsl:value-of select="count(ancestor::glossdiv)+2"/>
651      </xsl:when>
652      <xsl:when test="local-name($container) = 'sect1'
653                      or local-name($container) = 'sect2'
654                      or local-name($container) = 'sect3'
655                      or local-name($container) = 'sect4'
656                      or local-name($container) = 'sect5'
657                      or local-name($container) = 'refsect1'
658                      or local-name($container) = 'refsect2'
659                      or local-name($container) = 'refsect3'
660                      or local-name($container) = 'section'
661                      or local-name($container) = 'simplesect'">
662        <xsl:variable name="slevel">
663          <xsl:call-template name="section.level">
664            <xsl:with-param name="node" select="$container"/>
665          </xsl:call-template>
666        </xsl:variable>
667        <xsl:value-of select="$slevel + 1"/>
668      </xsl:when>
669      <xsl:otherwise>2</xsl:otherwise>
670    </xsl:choose>
671  </xsl:variable>
672
673  <xsl:variable name="level">
674    <xsl:choose>
675      <xsl:when test="@renderas = 'sect1'">1</xsl:when>
676      <xsl:when test="@renderas = 'sect2'">2</xsl:when>
677      <xsl:when test="@renderas = 'sect3'">3</xsl:when>
678      <xsl:when test="@renderas = 'sect4'">4</xsl:when>
679      <xsl:when test="@renderas = 'sect5'">5</xsl:when>
680      <xsl:otherwise>
681        <xsl:value-of select="$clevel"/>
682      </xsl:otherwise>
683    </xsl:choose>
684  </xsl:variable>
685
686  <xsl:variable name="marker">
687    <xsl:choose>
688      <xsl:when test="$level &lt;= $marker.section.level">1</xsl:when>
689      <xsl:otherwise>0</xsl:otherwise>
690    </xsl:choose>
691  </xsl:variable>
692
693  <xsl:variable name="marker.title">
694    <xsl:apply-templates/>
695  </xsl:variable>
696
697  <xsl:variable name="id">
698    <xsl:call-template name="object.id"/>
699  </xsl:variable>
700
701  <fo:block id="{$id}">
702    <xsl:call-template name="section.heading">
703      <xsl:with-param name="level" select="$level"/>
704      <xsl:with-param name="title">
705        <xsl:apply-templates/>
706      </xsl:with-param>
707      <xsl:with-param name="marker" select="$marker"/>
708      <xsl:with-param name="marker.title" select="$marker.title"/>
709    </xsl:call-template>
710  </fo:block>
711</xsl:template>
712
713</xsl:stylesheet>
714
715