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"
7 <!-- ********************************************************************
8 $Id: sections.xsl 9647 2012-10-26 17:42:03Z bobstayton $
9 ********************************************************************
11 This file is part of the XSL DocBook Stylesheet distribution.
12 See ../README or http://docbook.sf.net/release/xsl/current/ for
13 copyright and other information.
15 ******************************************************************** -->
17 <!-- ==================================================================== -->
19 <xsl:template match="section">
21 <xsl:when test="$rootid = @id or $rootid = @xml:id">
22 <xsl:call-template name="section.page.sequence"/>
25 <xsl:variable name="id">
26 <xsl:call-template name="object.id"/>
29 <xsl:variable name="renderas">
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>
40 <xsl:variable name="level">
42 <xsl:when test="$renderas != ''">
43 <xsl:value-of select="$renderas"/>
46 <xsl:call-template name="section.level"/>
51 <!-- xsl:use-attribute-sets takes only a Qname, not a variable -->
53 <xsl:when test="$level = 1">
54 <xsl:element name="fo:{$section.container.element}"
55 use-attribute-sets="section.level1.properties">
56 <xsl:attribute name="id"><xsl:value-of
57 select="$id"/></xsl:attribute>
58 <xsl:call-template name="section.content"/>
61 <xsl:when test="$level = 2">
62 <xsl:element name="fo:{$section.container.element}"
63 use-attribute-sets="section.level2.properties">
64 <xsl:attribute name="id"><xsl:value-of
65 select="$id"/></xsl:attribute>
66 <xsl:call-template name="section.content"/>
69 <xsl:when test="$level = 3">
70 <xsl:element name="fo:{$section.container.element}"
71 use-attribute-sets="section.level3.properties">
72 <xsl:attribute name="id"><xsl:value-of
73 select="$id"/></xsl:attribute>
74 <xsl:call-template name="section.content"/>
77 <xsl:when test="$level = 4">
78 <xsl:element name="fo:{$section.container.element}"
79 use-attribute-sets="section.level4.properties">
80 <xsl:attribute name="id"><xsl:value-of
81 select="$id"/></xsl:attribute>
82 <xsl:call-template name="section.content"/>
85 <xsl:when test="$level = 5">
86 <xsl:element name="fo:{$section.container.element}"
87 use-attribute-sets="section.level5.properties">
88 <xsl:attribute name="id"><xsl:value-of
89 select="$id"/></xsl:attribute>
90 <xsl:call-template name="section.content"/>
94 <xsl:element name="fo:{$section.container.element}"
95 use-attribute-sets="section.level6.properties">
96 <xsl:attribute name="id"><xsl:value-of
97 select="$id"/></xsl:attribute>
98 <xsl:call-template name="section.content"/>
106 <xsl:template name="section.content">
107 <xsl:call-template name="section.titlepage"/>
109 <xsl:variable name="toc.params">
110 <xsl:call-template name="find.path.params">
111 <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
115 <xsl:if test="contains($toc.params, 'toc')
116 and (count(ancestor::section)+1) <=
117 $generate.section.toc.level">
118 <xsl:call-template name="section.toc">
119 <xsl:with-param name="toc.title.p"
120 select="contains($toc.params, 'title')"/>
122 <xsl:call-template name="section.toc.separator"/>
125 <xsl:apply-templates/>
128 <xsl:template match="/section" name="section.page.sequence">
129 <xsl:variable name="id">
130 <xsl:call-template name="object.id"/>
133 <xsl:variable name="master-reference">
134 <xsl:call-template name="select.pagemaster"/>
137 <fo:page-sequence hyphenate="{$hyphenate}"
138 master-reference="{$master-reference}">
139 <xsl:attribute name="language">
140 <xsl:call-template name="l10n.language"/>
142 <xsl:attribute name="format">
143 <xsl:call-template name="page.number.format">
144 <xsl:with-param name="master-reference" select="$master-reference"/>
148 <xsl:attribute name="initial-page-number">
149 <xsl:call-template name="initial.page.number">
150 <xsl:with-param name="master-reference" select="$master-reference"/>
154 <xsl:attribute name="force-page-count">
155 <xsl:call-template name="force.page.count">
156 <xsl:with-param name="master-reference" select="$master-reference"/>
160 <xsl:attribute name="hyphenation-character">
161 <xsl:call-template name="gentext">
162 <xsl:with-param name="key" select="'hyphenation-character'"/>
165 <xsl:attribute name="hyphenation-push-character-count">
166 <xsl:call-template name="gentext">
167 <xsl:with-param name="key" select="'hyphenation-push-character-count'"/>
170 <xsl:attribute name="hyphenation-remain-character-count">
171 <xsl:call-template name="gentext">
172 <xsl:with-param name="key" select="'hyphenation-remain-character-count'"/>
176 <xsl:apply-templates select="." mode="running.head.mode">
177 <xsl:with-param name="master-reference" select="$master-reference"/>
178 </xsl:apply-templates>
179 <xsl:apply-templates select="." mode="running.foot.mode">
180 <xsl:with-param name="master-reference" select="$master-reference"/>
181 </xsl:apply-templates>
183 <fo:flow flow-name="xsl-region-body">
184 <xsl:call-template name="set.flow.properties">
185 <xsl:with-param name="element" select="local-name(.)"/>
186 <xsl:with-param name="master-reference" select="$master-reference"/>
190 xsl:use-attribute-sets="section.level1.properties">
191 <xsl:call-template name="section.titlepage"/>
194 <xsl:variable name="toc.params">
195 <xsl:call-template name="find.path.params">
196 <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
200 <xsl:if test="contains($toc.params, 'toc')
201 and (count(ancestor::section)+1) <=
202 $generate.section.toc.level">
203 <xsl:call-template name="section.toc">
204 <xsl:with-param name="toc.title.p"
205 select="contains($toc.params, 'title')"/>
207 <xsl:call-template name="section.toc.separator"/>
210 <xsl:apply-templates/>
215 <xsl:template match="section/title
223 |simplesect/info/title
229 |section/sectioninfo/title
230 |sect1/sect1info/title
231 |sect2/sect2info/title
232 |sect3/sect3info/title
233 |sect4/sect4info/title
234 |sect5/sect5info/title"
235 mode="titlepage.mode"
238 <xsl:variable name="section"
239 select="(ancestor::section |
240 ancestor::simplesect |
245 ancestor::sect5)[position() = last()]"/>
247 <fo:block keep-with-next.within-column="always">
248 <xsl:variable name="id">
249 <xsl:call-template name="object.id">
250 <xsl:with-param name="object" select="$section"/>
254 <xsl:variable name="renderas">
256 <xsl:when test="$section/@renderas = 'sect1'">1</xsl:when>
257 <xsl:when test="$section/@renderas = 'sect2'">2</xsl:when>
258 <xsl:when test="$section/@renderas = 'sect3'">3</xsl:when>
259 <xsl:when test="$section/@renderas = 'sect4'">4</xsl:when>
260 <xsl:when test="$section/@renderas = 'sect5'">5</xsl:when>
261 <xsl:otherwise><xsl:value-of select="''"/></xsl:otherwise>
265 <xsl:variable name="level">
267 <xsl:when test="$renderas != ''">
268 <xsl:value-of select="$renderas"/>
271 <xsl:call-template name="section.level">
272 <xsl:with-param name="node" select="$section"/>
278 <xsl:variable name="marker">
280 <xsl:when test="$level <= $marker.section.level">1</xsl:when>
281 <xsl:otherwise>0</xsl:otherwise>
285 <xsl:variable name="title">
286 <xsl:apply-templates select="$section" mode="object.title.markup">
287 <xsl:with-param name="allow-anchors" select="1"/>
288 </xsl:apply-templates>
291 <xsl:variable name="marker.title">
292 <xsl:apply-templates select="$section" mode="titleabbrev.markup">
293 <xsl:with-param name="allow-anchors" select="0"/>
294 </xsl:apply-templates>
297 <xsl:if test="$axf.extensions != 0">
298 <xsl:attribute name="axf:outline-level">
299 <xsl:value-of select="count(ancestor::*)-1"/>
301 <xsl:attribute name="axf:outline-expand">false</xsl:attribute>
302 <xsl:attribute name="axf:outline-title">
303 <xsl:value-of select="normalize-space($title)"/>
307 <xsl:call-template name="section.heading">
308 <xsl:with-param name="level" select="$level"/>
309 <xsl:with-param name="title" select="$title"/>
310 <xsl:with-param name="marker" select="$marker"/>
311 <xsl:with-param name="marker.title" select="$marker.title"/>
316 <xsl:template match="sect1">
317 <xsl:variable name="id">
318 <xsl:call-template name="object.id"/>
321 <xsl:element name="fo:{$section.container.element}"
322 use-attribute-sets="section.level1.properties">
323 <xsl:attribute name="id"><xsl:value-of
324 select="$id"/></xsl:attribute>
325 <xsl:call-template name="sect1.titlepage"/>
327 <xsl:variable name="toc.params">
328 <xsl:call-template name="find.path.params">
329 <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
333 <xsl:if test="contains($toc.params, 'toc')
334 and $generate.section.toc.level >= 1">
335 <xsl:call-template name="section.toc">
336 <xsl:with-param name="toc.title.p"
337 select="contains($toc.params, 'title')"/>
339 <xsl:call-template name="section.toc.separator"/>
342 <xsl:apply-templates/>
346 <xsl:template match="/sect1">
347 <xsl:variable name="id">
348 <xsl:call-template name="object.id"/>
350 <xsl:variable name="master-reference">
351 <xsl:call-template name="select.pagemaster"/>
354 <fo:page-sequence hyphenate="{$hyphenate}"
355 master-reference="{$master-reference}">
356 <xsl:attribute name="language">
357 <xsl:call-template name="l10n.language"/>
359 <xsl:attribute name="format">
360 <xsl:call-template name="page.number.format">
361 <xsl:with-param name="master-reference" select="$master-reference"/>
365 <xsl:attribute name="initial-page-number">
366 <xsl:call-template name="initial.page.number">
367 <xsl:with-param name="master-reference" select="$master-reference"/>
371 <xsl:attribute name="force-page-count">
372 <xsl:call-template name="force.page.count">
373 <xsl:with-param name="master-reference" select="$master-reference"/>
377 <xsl:attribute name="hyphenation-character">
378 <xsl:call-template name="gentext">
379 <xsl:with-param name="key" select="'hyphenation-character'"/>
382 <xsl:attribute name="hyphenation-push-character-count">
383 <xsl:call-template name="gentext">
384 <xsl:with-param name="key" select="'hyphenation-push-character-count'"/>
387 <xsl:attribute name="hyphenation-remain-character-count">
388 <xsl:call-template name="gentext">
389 <xsl:with-param name="key" select="'hyphenation-remain-character-count'"/>
393 <xsl:apply-templates select="." mode="running.head.mode">
394 <xsl:with-param name="master-reference" select="$master-reference"/>
395 </xsl:apply-templates>
396 <xsl:apply-templates select="." mode="running.foot.mode">
397 <xsl:with-param name="master-reference" select="$master-reference"/>
398 </xsl:apply-templates>
400 <fo:flow flow-name="xsl-region-body">
401 <xsl:call-template name="set.flow.properties">
402 <xsl:with-param name="element" select="local-name(.)"/>
403 <xsl:with-param name="master-reference" select="$master-reference"/>
407 xsl:use-attribute-sets="section.level1.properties">
408 <xsl:call-template name="sect1.titlepage"/>
411 <xsl:variable name="toc.params">
412 <xsl:call-template name="find.path.params">
413 <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
417 <xsl:if test="contains($toc.params, 'toc')
418 and $generate.section.toc.level >= 1">
419 <xsl:call-template name="section.toc">
420 <xsl:with-param name="toc.title.p"
421 select="contains($toc.params, 'title')"/>
423 <xsl:call-template name="section.toc.separator"/>
426 <xsl:apply-templates/>
431 <xsl:template match="sect2">
432 <xsl:variable name="id">
433 <xsl:call-template name="object.id"/>
436 <xsl:element name="fo:{$section.container.element}"
437 use-attribute-sets="section.level2.properties">
438 <xsl:attribute name="id"><xsl:value-of
439 select="$id"/></xsl:attribute>
440 <xsl:call-template name="sect2.titlepage"/>
442 <xsl:variable name="toc.params">
443 <xsl:call-template name="find.path.params">
444 <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
448 <xsl:if test="contains($toc.params, 'toc')
449 and $generate.section.toc.level >= 2">
450 <xsl:call-template name="section.toc">
451 <xsl:with-param name="toc.title.p"
452 select="contains($toc.params, 'title')"/>
454 <xsl:call-template name="section.toc.separator"/>
457 <xsl:apply-templates/>
461 <xsl:template match="sect3">
462 <xsl:variable name="id">
463 <xsl:call-template name="object.id"/>
466 <xsl:element name="fo:{$section.container.element}"
467 use-attribute-sets="section.level3.properties">
468 <xsl:attribute name="id"><xsl:value-of
469 select="$id"/></xsl:attribute>
470 <xsl:call-template name="sect3.titlepage"/>
472 <xsl:variable name="toc.params">
473 <xsl:call-template name="find.path.params">
474 <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
478 <xsl:if test="contains($toc.params, 'toc')
479 and $generate.section.toc.level >= 3">
480 <xsl:call-template name="section.toc">
481 <xsl:with-param name="toc.title.p"
482 select="contains($toc.params, 'title')"/>
484 <xsl:call-template name="section.toc.separator"/>
487 <xsl:apply-templates/>
491 <xsl:template match="sect4">
492 <xsl:variable name="id">
493 <xsl:call-template name="object.id"/>
496 <xsl:element name="fo:{$section.container.element}"
497 use-attribute-sets="section.level4.properties">
498 <xsl:attribute name="id"><xsl:value-of
499 select="$id"/></xsl:attribute>
500 <xsl:call-template name="sect4.titlepage"/>
502 <xsl:variable name="toc.params">
503 <xsl:call-template name="find.path.params">
504 <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
508 <xsl:if test="contains($toc.params, 'toc')
509 and $generate.section.toc.level >= 4">
510 <xsl:call-template name="section.toc">
511 <xsl:with-param name="toc.title.p"
512 select="contains($toc.params, 'title')"/>
514 <xsl:call-template name="section.toc.separator"/>
517 <xsl:apply-templates/>
521 <xsl:template match="sect5">
522 <xsl:variable name="id">
523 <xsl:call-template name="object.id"/>
526 <xsl:element name="fo:{$section.container.element}"
527 use-attribute-sets="section.level5.properties">
528 <xsl:attribute name="id"><xsl:value-of
529 select="$id"/></xsl:attribute>
530 <xsl:call-template name="sect5.titlepage"/>
532 <xsl:variable name="toc.params">
533 <xsl:call-template name="find.path.params">
534 <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
538 <xsl:if test="contains($toc.params, 'toc')
539 and $generate.section.toc.level >= 5">
540 <xsl:call-template name="section.toc">
541 <xsl:with-param name="toc.title.p"
542 select="contains($toc.params, 'title')"/>
544 <xsl:call-template name="section.toc.separator"/>
547 <xsl:apply-templates/>
551 <xsl:template match="simplesect">
552 <xsl:variable name="id">
553 <xsl:call-template name="object.id"/>
556 <xsl:element name="fo:{$section.container.element}">
557 <xsl:attribute name="id"><xsl:value-of
558 select="$id"/></xsl:attribute>
559 <xsl:call-template name="simplesect.titlepage"/>
560 <xsl:apply-templates/>
564 <xsl:template match="sectioninfo"></xsl:template>
565 <xsl:template match="section/info"></xsl:template>
566 <xsl:template match="section/title"></xsl:template>
567 <xsl:template match="section/titleabbrev"></xsl:template>
568 <xsl:template match="section/subtitle"></xsl:template>
570 <xsl:template match="sect1info"></xsl:template>
571 <xsl:template match="sect1/info"></xsl:template>
572 <xsl:template match="sect1/title"></xsl:template>
573 <xsl:template match="sect1/titleabbrev"></xsl:template>
574 <xsl:template match="sect1/subtitle"></xsl:template>
576 <xsl:template match="sect2info"></xsl:template>
577 <xsl:template match="sect2/info"></xsl:template>
578 <xsl:template match="sect2/title"></xsl:template>
579 <xsl:template match="sect2/titleabbrev"></xsl:template>
580 <xsl:template match="sect2/subtitle"></xsl:template>
582 <xsl:template match="sect3info"></xsl:template>
583 <xsl:template match="sect3/info"></xsl:template>
584 <xsl:template match="sect3/title"></xsl:template>
585 <xsl:template match="sect3/titleabbrev"></xsl:template>
586 <xsl:template match="sect3/subtitle"></xsl:template>
588 <xsl:template match="sect4info"></xsl:template>
589 <xsl:template match="sect4/info"></xsl:template>
590 <xsl:template match="sect4/title"></xsl:template>
591 <xsl:template match="sect4/titleabbrev"></xsl:template>
592 <xsl:template match="sect4/subtitle"></xsl:template>
594 <xsl:template match="sect5info"></xsl:template>
595 <xsl:template match="sect5/info"></xsl:template>
596 <xsl:template match="sect5/title"></xsl:template>
597 <xsl:template match="sect5/titleabbrev"></xsl:template>
598 <xsl:template match="sect5/subtitle"></xsl:template>
600 <xsl:template match="simplesect/info"></xsl:template>
601 <xsl:template match="simplesect/title"></xsl:template>
602 <xsl:template match="simplesect/titleabbrev"></xsl:template>
603 <xsl:template match="simplesect/subtitle"></xsl:template>
605 <!-- ==================================================================== -->
607 <xsl:template name="section.heading">
608 <xsl:param name="level" select="1"/>
609 <xsl:param name="marker" select="1"/>
610 <xsl:param name="title"/>
611 <xsl:param name="marker.title"/>
613 <fo:block xsl:use-attribute-sets="section.title.properties">
614 <xsl:if test="$marker != 0">
615 <fo:marker marker-class-name="section.head.marker">
616 <xsl:copy-of select="$marker.title"/>
621 <xsl:when test="$level=1">
622 <fo:block xsl:use-attribute-sets="section.title.level1.properties">
623 <xsl:copy-of select="$title"/>
626 <xsl:when test="$level=2">
627 <fo:block xsl:use-attribute-sets="section.title.level2.properties">
628 <xsl:copy-of select="$title"/>
631 <xsl:when test="$level=3">
632 <fo:block xsl:use-attribute-sets="section.title.level3.properties">
633 <xsl:copy-of select="$title"/>
636 <xsl:when test="$level=4">
637 <fo:block xsl:use-attribute-sets="section.title.level4.properties">
638 <xsl:copy-of select="$title"/>
641 <xsl:when test="$level=5">
642 <fo:block xsl:use-attribute-sets="section.title.level5.properties">
643 <xsl:copy-of select="$title"/>
647 <fo:block xsl:use-attribute-sets="section.title.level6.properties">
648 <xsl:copy-of select="$title"/>
655 <!-- ==================================================================== -->
657 <xsl:template match="bridgehead">
658 <xsl:variable name="container"
659 select="(ancestor::appendix
661 |ancestor::bibliography
678 |ancestor::simplesect)[last()]"/>
680 <xsl:variable name="clevel">
682 <xsl:when test="local-name($container) = 'appendix'
683 or local-name($container) = 'chapter'
684 or local-name($container) = 'article'
685 or local-name($container) = 'bibliography'
686 or local-name($container) = 'glossary'
687 or local-name($container) = 'index'
688 or local-name($container) = 'partintro'
689 or local-name($container) = 'preface'
690 or local-name($container) = 'setindex'">2</xsl:when>
691 <xsl:when test="local-name($container) = 'glossdiv'">
692 <xsl:value-of select="count(ancestor::glossdiv)+2"/>
694 <xsl:when test="local-name($container) = 'sect1'
695 or local-name($container) = 'sect2'
696 or local-name($container) = 'sect3'
697 or local-name($container) = 'sect4'
698 or local-name($container) = 'sect5'
699 or local-name($container) = 'refsect1'
700 or local-name($container) = 'refsect2'
701 or local-name($container) = 'refsect3'
702 or local-name($container) = 'section'
703 or local-name($container) = 'simplesect'">
704 <xsl:variable name="slevel">
705 <xsl:call-template name="section.level">
706 <xsl:with-param name="node" select="$container"/>
709 <xsl:value-of select="$slevel + 1"/>
711 <xsl:otherwise>2</xsl:otherwise>
715 <xsl:variable name="level">
717 <xsl:when test="@renderas = 'sect1'">1</xsl:when>
718 <xsl:when test="@renderas = 'sect2'">2</xsl:when>
719 <xsl:when test="@renderas = 'sect3'">3</xsl:when>
720 <xsl:when test="@renderas = 'sect4'">4</xsl:when>
721 <xsl:when test="@renderas = 'sect5'">5</xsl:when>
723 <xsl:value-of select="$clevel"/>
728 <xsl:variable name="marker">
730 <xsl:when test="$level <= $marker.section.level">1</xsl:when>
731 <xsl:otherwise>0</xsl:otherwise>
735 <xsl:variable name="marker.title">
736 <xsl:apply-templates/>
739 <xsl:variable name="id">
740 <xsl:call-template name="object.id"/>
743 <fo:block id="{$id}">
744 <xsl:call-template name="section.heading">
745 <xsl:with-param name="level" select="$level"/>
746 <xsl:with-param name="title">
747 <xsl:apply-templates/>
749 <xsl:with-param name="marker" select="$marker"/>
750 <xsl:with-param name="marker.title" select="$marker.title"/>