2 <xsl:stylesheet exclude-result-prefixes="d"
3 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4 xmlns:d="http://docbook.org/ns/docbook"
5 xmlns:fo="http://www.w3.org/1999/XSL/Format"
6 xmlns:axf="http://www.antennahouse.com/names/XSL/Extensions"
9 <!-- ********************************************************************
11 This file is part of the XSL DocBook Stylesheet distribution.
12 See ../README or http://cdn.docbook.org/release/xsl/current/ for
13 copyright and other information.
15 ******************************************************************** -->
17 <!-- ==================================================================== -->
19 <xsl:template match="d: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::d: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="/d: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::d: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="d:section/d:title
216 |d:simplesect/d:title
222 |d:section/d:info/d:title
223 |d:simplesect/d:info/d:title
224 |d:sect1/d:info/d:title
225 |d:sect2/d:info/d:title
226 |d:sect3/d:info/d:title
227 |d:sect4/d:info/d:title
228 |d:sect5/d:info/d:title
229 |d:section/d:sectioninfo/d:title
230 |d:sect1/d:sect1info/d:title
231 |d:sect2/d:sect2info/d:title
232 |d:sect3/d:sect3info/d:title
233 |d:sect4/d:sect4info/d:title
234 |d:sect5/d:sect5info/d:title"
235 mode="titlepage.mode"
238 <xsl:variable name="section"
239 select="(ancestor::d:section |
240 ancestor::d:simplesect |
245 ancestor::d: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 and
298 $xsl1.1.bookmarks = 0 and
299 $show.bookmarks != 0">
300 <xsl:attribute name="axf:outline-level">
301 <xsl:value-of select="count(ancestor::*)-1"/>
303 <xsl:attribute name="axf:outline-expand">false</xsl:attribute>
304 <xsl:attribute name="axf:outline-title">
305 <xsl:value-of select="normalize-space($title)"/>
309 <xsl:call-template name="section.heading">
310 <xsl:with-param name="level" select="$level"/>
311 <xsl:with-param name="title" select="$title"/>
312 <xsl:with-param name="marker" select="$marker"/>
313 <xsl:with-param name="marker.title" select="$marker.title"/>
318 <xsl:template match="d:sect1">
319 <xsl:variable name="id">
320 <xsl:call-template name="object.id"/>
323 <xsl:element name="fo:{$section.container.element}"
324 use-attribute-sets="section.level1.properties">
325 <xsl:attribute name="id"><xsl:value-of
326 select="$id"/></xsl:attribute>
327 <xsl:call-template name="sect1.titlepage"/>
329 <xsl:variable name="toc.params">
330 <xsl:call-template name="find.path.params">
331 <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
335 <xsl:if test="contains($toc.params, 'toc')
336 and $generate.section.toc.level >= 1">
337 <xsl:call-template name="section.toc">
338 <xsl:with-param name="toc.title.p"
339 select="contains($toc.params, 'title')"/>
341 <xsl:call-template name="section.toc.separator"/>
344 <xsl:apply-templates/>
348 <xsl:template match="/d:sect1">
349 <xsl:variable name="id">
350 <xsl:call-template name="object.id"/>
352 <xsl:variable name="master-reference">
353 <xsl:call-template name="select.pagemaster"/>
356 <fo:page-sequence hyphenate="{$hyphenate}"
357 master-reference="{$master-reference}">
358 <xsl:attribute name="language">
359 <xsl:call-template name="l10n.language"/>
361 <xsl:attribute name="format">
362 <xsl:call-template name="page.number.format">
363 <xsl:with-param name="master-reference" select="$master-reference"/>
367 <xsl:attribute name="initial-page-number">
368 <xsl:call-template name="initial.page.number">
369 <xsl:with-param name="master-reference" select="$master-reference"/>
373 <xsl:attribute name="force-page-count">
374 <xsl:call-template name="force.page.count">
375 <xsl:with-param name="master-reference" select="$master-reference"/>
379 <xsl:attribute name="hyphenation-character">
380 <xsl:call-template name="gentext">
381 <xsl:with-param name="key" select="'hyphenation-character'"/>
384 <xsl:attribute name="hyphenation-push-character-count">
385 <xsl:call-template name="gentext">
386 <xsl:with-param name="key" select="'hyphenation-push-character-count'"/>
389 <xsl:attribute name="hyphenation-remain-character-count">
390 <xsl:call-template name="gentext">
391 <xsl:with-param name="key" select="'hyphenation-remain-character-count'"/>
395 <xsl:apply-templates select="." mode="running.head.mode">
396 <xsl:with-param name="master-reference" select="$master-reference"/>
397 </xsl:apply-templates>
398 <xsl:apply-templates select="." mode="running.foot.mode">
399 <xsl:with-param name="master-reference" select="$master-reference"/>
400 </xsl:apply-templates>
402 <fo:flow flow-name="xsl-region-body">
403 <xsl:call-template name="set.flow.properties">
404 <xsl:with-param name="element" select="local-name(.)"/>
405 <xsl:with-param name="master-reference" select="$master-reference"/>
409 xsl:use-attribute-sets="section.level1.properties">
410 <xsl:call-template name="sect1.titlepage"/>
413 <xsl:variable name="toc.params">
414 <xsl:call-template name="find.path.params">
415 <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
419 <xsl:if test="contains($toc.params, 'toc')
420 and $generate.section.toc.level >= 1">
421 <xsl:call-template name="section.toc">
422 <xsl:with-param name="toc.title.p"
423 select="contains($toc.params, 'title')"/>
425 <xsl:call-template name="section.toc.separator"/>
428 <xsl:apply-templates/>
433 <xsl:template match="d:sect2">
434 <xsl:variable name="id">
435 <xsl:call-template name="object.id"/>
438 <xsl:element name="fo:{$section.container.element}"
439 use-attribute-sets="section.level2.properties">
440 <xsl:attribute name="id"><xsl:value-of
441 select="$id"/></xsl:attribute>
442 <xsl:call-template name="sect2.titlepage"/>
444 <xsl:variable name="toc.params">
445 <xsl:call-template name="find.path.params">
446 <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
450 <xsl:if test="contains($toc.params, 'toc')
451 and $generate.section.toc.level >= 2">
452 <xsl:call-template name="section.toc">
453 <xsl:with-param name="toc.title.p"
454 select="contains($toc.params, 'title')"/>
456 <xsl:call-template name="section.toc.separator"/>
459 <xsl:apply-templates/>
463 <xsl:template match="d:sect3">
464 <xsl:variable name="id">
465 <xsl:call-template name="object.id"/>
468 <xsl:element name="fo:{$section.container.element}"
469 use-attribute-sets="section.level3.properties">
470 <xsl:attribute name="id"><xsl:value-of
471 select="$id"/></xsl:attribute>
472 <xsl:call-template name="sect3.titlepage"/>
474 <xsl:variable name="toc.params">
475 <xsl:call-template name="find.path.params">
476 <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
480 <xsl:if test="contains($toc.params, 'toc')
481 and $generate.section.toc.level >= 3">
482 <xsl:call-template name="section.toc">
483 <xsl:with-param name="toc.title.p"
484 select="contains($toc.params, 'title')"/>
486 <xsl:call-template name="section.toc.separator"/>
489 <xsl:apply-templates/>
493 <xsl:template match="d:sect4">
494 <xsl:variable name="id">
495 <xsl:call-template name="object.id"/>
498 <xsl:element name="fo:{$section.container.element}"
499 use-attribute-sets="section.level4.properties">
500 <xsl:attribute name="id"><xsl:value-of
501 select="$id"/></xsl:attribute>
502 <xsl:call-template name="sect4.titlepage"/>
504 <xsl:variable name="toc.params">
505 <xsl:call-template name="find.path.params">
506 <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
510 <xsl:if test="contains($toc.params, 'toc')
511 and $generate.section.toc.level >= 4">
512 <xsl:call-template name="section.toc">
513 <xsl:with-param name="toc.title.p"
514 select="contains($toc.params, 'title')"/>
516 <xsl:call-template name="section.toc.separator"/>
519 <xsl:apply-templates/>
523 <xsl:template match="d:sect5">
524 <xsl:variable name="id">
525 <xsl:call-template name="object.id"/>
528 <xsl:element name="fo:{$section.container.element}"
529 use-attribute-sets="section.level5.properties">
530 <xsl:attribute name="id"><xsl:value-of
531 select="$id"/></xsl:attribute>
532 <xsl:call-template name="sect5.titlepage"/>
534 <xsl:variable name="toc.params">
535 <xsl:call-template name="find.path.params">
536 <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
540 <xsl:if test="contains($toc.params, 'toc')
541 and $generate.section.toc.level >= 5">
542 <xsl:call-template name="section.toc">
543 <xsl:with-param name="toc.title.p"
544 select="contains($toc.params, 'title')"/>
546 <xsl:call-template name="section.toc.separator"/>
549 <xsl:apply-templates/>
553 <xsl:template match="d:simplesect">
554 <xsl:variable name="id">
555 <xsl:call-template name="object.id"/>
558 <xsl:element name="fo:{$section.container.element}">
559 <xsl:attribute name="id"><xsl:value-of
560 select="$id"/></xsl:attribute>
561 <xsl:call-template name="simplesect.titlepage"/>
562 <xsl:apply-templates/>
566 <xsl:template match="d:sectioninfo"></xsl:template>
567 <xsl:template match="d:section/d:info"></xsl:template>
568 <xsl:template match="d:section/d:title"></xsl:template>
569 <xsl:template match="d:section/d:titleabbrev"></xsl:template>
570 <xsl:template match="d:section/d:subtitle"></xsl:template>
572 <xsl:template match="d:sect1info"></xsl:template>
573 <xsl:template match="d:sect1/d:info"></xsl:template>
574 <xsl:template match="d:sect1/d:title"></xsl:template>
575 <xsl:template match="d:sect1/d:titleabbrev"></xsl:template>
576 <xsl:template match="d:sect1/d:subtitle"></xsl:template>
578 <xsl:template match="d:sect2info"></xsl:template>
579 <xsl:template match="d:sect2/d:info"></xsl:template>
580 <xsl:template match="d:sect2/d:title"></xsl:template>
581 <xsl:template match="d:sect2/d:titleabbrev"></xsl:template>
582 <xsl:template match="d:sect2/d:subtitle"></xsl:template>
584 <xsl:template match="d:sect3info"></xsl:template>
585 <xsl:template match="d:sect3/d:info"></xsl:template>
586 <xsl:template match="d:sect3/d:title"></xsl:template>
587 <xsl:template match="d:sect3/d:titleabbrev"></xsl:template>
588 <xsl:template match="d:sect3/d:subtitle"></xsl:template>
590 <xsl:template match="d:sect4info"></xsl:template>
591 <xsl:template match="d:sect4/d:info"></xsl:template>
592 <xsl:template match="d:sect4/d:title"></xsl:template>
593 <xsl:template match="d:sect4/d:titleabbrev"></xsl:template>
594 <xsl:template match="d:sect4/d:subtitle"></xsl:template>
596 <xsl:template match="d:sect5info"></xsl:template>
597 <xsl:template match="d:sect5/d:info"></xsl:template>
598 <xsl:template match="d:sect5/d:title"></xsl:template>
599 <xsl:template match="d:sect5/d:titleabbrev"></xsl:template>
600 <xsl:template match="d:sect5/d:subtitle"></xsl:template>
602 <xsl:template match="d:simplesect/d:info"></xsl:template>
603 <xsl:template match="d:simplesect/d:title"></xsl:template>
604 <xsl:template match="d:simplesect/d:titleabbrev"></xsl:template>
605 <xsl:template match="d:simplesect/d:subtitle"></xsl:template>
607 <!-- ==================================================================== -->
609 <xsl:template name="section.heading">
610 <xsl:param name="level" select="1"/>
611 <xsl:param name="marker" select="1"/>
612 <xsl:param name="title"/>
613 <xsl:param name="marker.title"/>
615 <fo:block xsl:use-attribute-sets="section.title.properties">
616 <xsl:if test="$marker != 0">
617 <fo:marker marker-class-name="section.head.marker">
618 <xsl:copy-of select="$marker.title"/>
623 <xsl:when test="$level=1">
624 <fo:block xsl:use-attribute-sets="section.title.level1.properties">
625 <xsl:copy-of select="$title"/>
628 <xsl:when test="$level=2">
629 <fo:block xsl:use-attribute-sets="section.title.level2.properties">
630 <xsl:copy-of select="$title"/>
633 <xsl:when test="$level=3">
634 <fo:block xsl:use-attribute-sets="section.title.level3.properties">
635 <xsl:copy-of select="$title"/>
638 <xsl:when test="$level=4">
639 <fo:block xsl:use-attribute-sets="section.title.level4.properties">
640 <xsl:copy-of select="$title"/>
643 <xsl:when test="$level=5">
644 <fo:block xsl:use-attribute-sets="section.title.level5.properties">
645 <xsl:copy-of select="$title"/>
649 <fo:block xsl:use-attribute-sets="section.title.level6.properties">
650 <xsl:copy-of select="$title"/>
657 <!-- ==================================================================== -->
659 <xsl:template match="d:bridgehead">
660 <xsl:variable name="container"
661 select="(ancestor::d:appendix
663 |ancestor::d:bibliography
665 |ancestor::d:glossary
666 |ancestor::d:glossdiv
668 |ancestor::d:partintro
670 |ancestor::d:refsect1
671 |ancestor::d:refsect2
672 |ancestor::d:refsect3
679 |ancestor::d:setindex
680 |ancestor::d:simplesect)[last()]"/>
682 <xsl:variable name="clevel">
684 <xsl:when test="local-name($container) = 'appendix'
685 or local-name($container) = 'chapter'
686 or local-name($container) = 'article'
687 or local-name($container) = 'bibliography'
688 or local-name($container) = 'glossary'
689 or local-name($container) = 'index'
690 or local-name($container) = 'partintro'
691 or local-name($container) = 'preface'
692 or local-name($container) = 'setindex'">2</xsl:when>
693 <xsl:when test="local-name($container) = 'glossdiv'">
694 <xsl:value-of select="count(ancestor::d:glossdiv)+2"/>
696 <xsl:when test="local-name($container) = 'sect1'
697 or local-name($container) = 'sect2'
698 or local-name($container) = 'sect3'
699 or local-name($container) = 'sect4'
700 or local-name($container) = 'sect5'
701 or local-name($container) = 'refsect1'
702 or local-name($container) = 'refsect2'
703 or local-name($container) = 'refsect3'
704 or local-name($container) = 'section'
705 or local-name($container) = 'simplesect'">
706 <xsl:variable name="slevel">
707 <xsl:call-template name="section.level">
708 <xsl:with-param name="node" select="$container"/>
711 <xsl:value-of select="$slevel + 1"/>
713 <xsl:otherwise>2</xsl:otherwise>
717 <xsl:variable name="level">
719 <xsl:when test="@renderas = 'sect1'">1</xsl:when>
720 <xsl:when test="@renderas = 'sect2'">2</xsl:when>
721 <xsl:when test="@renderas = 'sect3'">3</xsl:when>
722 <xsl:when test="@renderas = 'sect4'">4</xsl:when>
723 <xsl:when test="@renderas = 'sect5'">5</xsl:when>
725 <xsl:value-of select="$clevel"/>
730 <xsl:variable name="marker">
732 <xsl:when test="$level <= $marker.section.level">1</xsl:when>
733 <xsl:otherwise>0</xsl:otherwise>
737 <xsl:variable name="marker.title">
738 <xsl:apply-templates/>
741 <xsl:variable name="id">
742 <xsl:call-template name="object.id"/>
745 <fo:block id="{$id}">
746 <xsl:call-template name="section.heading">
747 <xsl:with-param name="level" select="$level"/>
748 <xsl:with-param name="title">
749 <xsl:apply-templates/>
751 <xsl:with-param name="marker" select="$marker"/>
752 <xsl:with-param name="marker.title" select="$marker.title"/>