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 6910 2007-06-28 23:23:30Z xmldoc $
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="$passivetex.extensions != 0">
298 <fotex:bookmark xmlns:fotex="http://www.tug.org/fotex"
299 fotex-bookmark-level="{$level + 2}"
300 fotex-bookmark-label="{$id}">
301 <xsl:value-of select="$marker.title"/>
305 <xsl:if test="$axf.extensions != 0">
306 <xsl:attribute name="axf:outline-level">
307 <xsl:value-of select="count(ancestor::*)-1"/>
309 <xsl:attribute name="axf:outline-expand">false</xsl:attribute>
310 <xsl:attribute name="axf:outline-title">
311 <xsl:value-of select="normalize-space($title)"/>
315 <xsl:call-template name="section.heading">
316 <xsl:with-param name="level" select="$level"/>
317 <xsl:with-param name="title" select="$title"/>
318 <xsl:with-param name="marker" select="$marker"/>
319 <xsl:with-param name="marker.title" select="$marker.title"/>
324 <xsl:template match="sect1">
325 <xsl:variable name="id">
326 <xsl:call-template name="object.id"/>
329 <xsl:element name="fo:{$section.container.element}"
330 use-attribute-sets="section.level1.properties">
331 <xsl:attribute name="id"><xsl:value-of
332 select="$id"/></xsl:attribute>
333 <xsl:call-template name="sect1.titlepage"/>
335 <xsl:variable name="toc.params">
336 <xsl:call-template name="find.path.params">
337 <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
341 <xsl:if test="contains($toc.params, 'toc')
342 and $generate.section.toc.level >= 1">
343 <xsl:call-template name="section.toc">
344 <xsl:with-param name="toc.title.p"
345 select="contains($toc.params, 'title')"/>
347 <xsl:call-template name="section.toc.separator"/>
350 <xsl:apply-templates/>
354 <xsl:template match="/sect1">
355 <xsl:variable name="id">
356 <xsl:call-template name="object.id"/>
358 <xsl:variable name="master-reference">
359 <xsl:call-template name="select.pagemaster"/>
362 <fo:page-sequence hyphenate="{$hyphenate}"
363 master-reference="{$master-reference}">
364 <xsl:attribute name="language">
365 <xsl:call-template name="l10n.language"/>
367 <xsl:attribute name="format">
368 <xsl:call-template name="page.number.format">
369 <xsl:with-param name="master-reference" select="$master-reference"/>
373 <xsl:attribute name="initial-page-number">
374 <xsl:call-template name="initial.page.number">
375 <xsl:with-param name="master-reference" select="$master-reference"/>
379 <xsl:attribute name="force-page-count">
380 <xsl:call-template name="force.page.count">
381 <xsl:with-param name="master-reference" select="$master-reference"/>
385 <xsl:attribute name="hyphenation-character">
386 <xsl:call-template name="gentext">
387 <xsl:with-param name="key" select="'hyphenation-character'"/>
390 <xsl:attribute name="hyphenation-push-character-count">
391 <xsl:call-template name="gentext">
392 <xsl:with-param name="key" select="'hyphenation-push-character-count'"/>
395 <xsl:attribute name="hyphenation-remain-character-count">
396 <xsl:call-template name="gentext">
397 <xsl:with-param name="key" select="'hyphenation-remain-character-count'"/>
401 <xsl:apply-templates select="." mode="running.head.mode">
402 <xsl:with-param name="master-reference" select="$master-reference"/>
403 </xsl:apply-templates>
404 <xsl:apply-templates select="." mode="running.foot.mode">
405 <xsl:with-param name="master-reference" select="$master-reference"/>
406 </xsl:apply-templates>
408 <fo:flow flow-name="xsl-region-body">
409 <xsl:call-template name="set.flow.properties">
410 <xsl:with-param name="element" select="local-name(.)"/>
411 <xsl:with-param name="master-reference" select="$master-reference"/>
415 xsl:use-attribute-sets="section.level1.properties">
416 <xsl:call-template name="sect1.titlepage"/>
419 <xsl:variable name="toc.params">
420 <xsl:call-template name="find.path.params">
421 <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
425 <xsl:if test="contains($toc.params, 'toc')
426 and $generate.section.toc.level >= 1">
427 <xsl:call-template name="section.toc">
428 <xsl:with-param name="toc.title.p"
429 select="contains($toc.params, 'title')"/>
431 <xsl:call-template name="section.toc.separator"/>
434 <xsl:apply-templates/>
439 <xsl:template match="sect2">
440 <xsl:variable name="id">
441 <xsl:call-template name="object.id"/>
444 <xsl:element name="fo:{$section.container.element}"
445 use-attribute-sets="section.level2.properties">
446 <xsl:attribute name="id"><xsl:value-of
447 select="$id"/></xsl:attribute>
448 <xsl:call-template name="sect2.titlepage"/>
450 <xsl:variable name="toc.params">
451 <xsl:call-template name="find.path.params">
452 <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
456 <xsl:if test="contains($toc.params, 'toc')
457 and $generate.section.toc.level >= 2">
458 <xsl:call-template name="section.toc">
459 <xsl:with-param name="toc.title.p"
460 select="contains($toc.params, 'title')"/>
462 <xsl:call-template name="section.toc.separator"/>
465 <xsl:apply-templates/>
469 <xsl:template match="sect3">
470 <xsl:variable name="id">
471 <xsl:call-template name="object.id"/>
474 <xsl:element name="fo:{$section.container.element}"
475 use-attribute-sets="section.level3.properties">
476 <xsl:attribute name="id"><xsl:value-of
477 select="$id"/></xsl:attribute>
478 <xsl:call-template name="sect3.titlepage"/>
480 <xsl:variable name="toc.params">
481 <xsl:call-template name="find.path.params">
482 <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
486 <xsl:if test="contains($toc.params, 'toc')
487 and $generate.section.toc.level >= 3">
488 <xsl:call-template name="section.toc">
489 <xsl:with-param name="toc.title.p"
490 select="contains($toc.params, 'title')"/>
492 <xsl:call-template name="section.toc.separator"/>
495 <xsl:apply-templates/>
499 <xsl:template match="sect4">
500 <xsl:variable name="id">
501 <xsl:call-template name="object.id"/>
504 <xsl:element name="fo:{$section.container.element}"
505 use-attribute-sets="section.level4.properties">
506 <xsl:attribute name="id"><xsl:value-of
507 select="$id"/></xsl:attribute>
508 <xsl:call-template name="sect4.titlepage"/>
510 <xsl:variable name="toc.params">
511 <xsl:call-template name="find.path.params">
512 <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
516 <xsl:if test="contains($toc.params, 'toc')
517 and $generate.section.toc.level >= 4">
518 <xsl:call-template name="section.toc">
519 <xsl:with-param name="toc.title.p"
520 select="contains($toc.params, 'title')"/>
522 <xsl:call-template name="section.toc.separator"/>
525 <xsl:apply-templates/>
529 <xsl:template match="sect5">
530 <xsl:variable name="id">
531 <xsl:call-template name="object.id"/>
534 <xsl:element name="fo:{$section.container.element}"
535 use-attribute-sets="section.level5.properties">
536 <xsl:attribute name="id"><xsl:value-of
537 select="$id"/></xsl:attribute>
538 <xsl:call-template name="sect5.titlepage"/>
540 <xsl:variable name="toc.params">
541 <xsl:call-template name="find.path.params">
542 <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
546 <xsl:if test="contains($toc.params, 'toc')
547 and $generate.section.toc.level >= 5">
548 <xsl:call-template name="section.toc">
549 <xsl:with-param name="toc.title.p"
550 select="contains($toc.params, 'title')"/>
552 <xsl:call-template name="section.toc.separator"/>
555 <xsl:apply-templates/>
559 <xsl:template match="simplesect">
560 <xsl:variable name="id">
561 <xsl:call-template name="object.id"/>
564 <xsl:element name="fo:{$section.container.element}">
565 <xsl:attribute name="id"><xsl:value-of
566 select="$id"/></xsl:attribute>
567 <xsl:call-template name="simplesect.titlepage"/>
568 <xsl:apply-templates/>
572 <xsl:template match="sectioninfo"></xsl:template>
573 <xsl:template match="section/info"></xsl:template>
574 <xsl:template match="section/title"></xsl:template>
575 <xsl:template match="section/titleabbrev"></xsl:template>
576 <xsl:template match="section/subtitle"></xsl:template>
578 <xsl:template match="sect1info"></xsl:template>
579 <xsl:template match="sect1/info"></xsl:template>
580 <xsl:template match="sect1/title"></xsl:template>
581 <xsl:template match="sect1/titleabbrev"></xsl:template>
582 <xsl:template match="sect1/subtitle"></xsl:template>
584 <xsl:template match="sect2info"></xsl:template>
585 <xsl:template match="sect2/info"></xsl:template>
586 <xsl:template match="sect2/title"></xsl:template>
587 <xsl:template match="sect2/titleabbrev"></xsl:template>
588 <xsl:template match="sect2/subtitle"></xsl:template>
590 <xsl:template match="sect3info"></xsl:template>
591 <xsl:template match="sect3/info"></xsl:template>
592 <xsl:template match="sect3/title"></xsl:template>
593 <xsl:template match="sect3/titleabbrev"></xsl:template>
594 <xsl:template match="sect3/subtitle"></xsl:template>
596 <xsl:template match="sect4info"></xsl:template>
597 <xsl:template match="sect4/info"></xsl:template>
598 <xsl:template match="sect4/title"></xsl:template>
599 <xsl:template match="sect4/titleabbrev"></xsl:template>
600 <xsl:template match="sect4/subtitle"></xsl:template>
602 <xsl:template match="sect5info"></xsl:template>
603 <xsl:template match="sect5/info"></xsl:template>
604 <xsl:template match="sect5/title"></xsl:template>
605 <xsl:template match="sect5/titleabbrev"></xsl:template>
606 <xsl:template match="sect5/subtitle"></xsl:template>
608 <xsl:template match="simplesect/info"></xsl:template>
609 <xsl:template match="simplesect/title"></xsl:template>
610 <xsl:template match="simplesect/titleabbrev"></xsl:template>
611 <xsl:template match="simplesect/subtitle"></xsl:template>
613 <!-- ==================================================================== -->
615 <xsl:template name="section.heading">
616 <xsl:param name="level" select="1"/>
617 <xsl:param name="marker" select="1"/>
618 <xsl:param name="title"/>
619 <xsl:param name="marker.title"/>
621 <fo:block xsl:use-attribute-sets="section.title.properties">
622 <xsl:if test="$marker != 0">
623 <fo:marker marker-class-name="section.head.marker">
624 <xsl:copy-of select="$marker.title"/>
629 <xsl:when test="$level=1">
630 <fo:block xsl:use-attribute-sets="section.title.level1.properties">
631 <xsl:copy-of select="$title"/>
634 <xsl:when test="$level=2">
635 <fo:block xsl:use-attribute-sets="section.title.level2.properties">
636 <xsl:copy-of select="$title"/>
639 <xsl:when test="$level=3">
640 <fo:block xsl:use-attribute-sets="section.title.level3.properties">
641 <xsl:copy-of select="$title"/>
644 <xsl:when test="$level=4">
645 <fo:block xsl:use-attribute-sets="section.title.level4.properties">
646 <xsl:copy-of select="$title"/>
649 <xsl:when test="$level=5">
650 <fo:block xsl:use-attribute-sets="section.title.level5.properties">
651 <xsl:copy-of select="$title"/>
655 <fo:block xsl:use-attribute-sets="section.title.level6.properties">
656 <xsl:copy-of select="$title"/>
663 <!-- ==================================================================== -->
665 <xsl:template match="bridgehead">
666 <xsl:variable name="container"
667 select="(ancestor::appendix
669 |ancestor::bibliography
686 |ancestor::simplesect)[last()]"/>
688 <xsl:variable name="clevel">
690 <xsl:when test="local-name($container) = 'appendix'
691 or local-name($container) = 'chapter'
692 or local-name($container) = 'article'
693 or local-name($container) = 'bibliography'
694 or local-name($container) = 'glossary'
695 or local-name($container) = 'index'
696 or local-name($container) = 'partintro'
697 or local-name($container) = 'preface'
698 or local-name($container) = 'setindex'">2</xsl:when>
699 <xsl:when test="local-name($container) = 'glossdiv'">
700 <xsl:value-of select="count(ancestor::glossdiv)+2"/>
702 <xsl:when test="local-name($container) = 'sect1'
703 or local-name($container) = 'sect2'
704 or local-name($container) = 'sect3'
705 or local-name($container) = 'sect4'
706 or local-name($container) = 'sect5'
707 or local-name($container) = 'refsect1'
708 or local-name($container) = 'refsect2'
709 or local-name($container) = 'refsect3'
710 or local-name($container) = 'section'
711 or local-name($container) = 'simplesect'">
712 <xsl:variable name="slevel">
713 <xsl:call-template name="section.level">
714 <xsl:with-param name="node" select="$container"/>
717 <xsl:value-of select="$slevel + 1"/>
719 <xsl:otherwise>2</xsl:otherwise>
723 <xsl:variable name="level">
725 <xsl:when test="@renderas = 'sect1'">1</xsl:when>
726 <xsl:when test="@renderas = 'sect2'">2</xsl:when>
727 <xsl:when test="@renderas = 'sect3'">3</xsl:when>
728 <xsl:when test="@renderas = 'sect4'">4</xsl:when>
729 <xsl:when test="@renderas = 'sect5'">5</xsl:when>
731 <xsl:value-of select="$clevel"/>
736 <xsl:variable name="marker">
738 <xsl:when test="$level <= $marker.section.level">1</xsl:when>
739 <xsl:otherwise>0</xsl:otherwise>
743 <xsl:variable name="marker.title">
744 <xsl:apply-templates/>
747 <xsl:variable name="id">
748 <xsl:call-template name="object.id"/>
751 <fo:block id="{$id}">
752 <xsl:call-template name="section.heading">
753 <xsl:with-param name="level" select="$level"/>
754 <xsl:with-param name="title">
755 <xsl:apply-templates/>
757 <xsl:with-param name="marker" select="$marker"/>
758 <xsl:with-param name="marker.title" select="$marker.title"/>