123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960 |
- <?xml version='1.0'?>
- <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:fo="http://www.w3.org/1999/XSL/Format"
- xmlns:axf="http://www.antennahouse.com/names/XSL/Extensions"
- version='1.0'>
- <!-- ********************************************************************
- $Id: autotoc.xsl 9647 2012-10-26 17:42:03Z bobstayton $
- ********************************************************************
- This file is part of the XSL DocBook Stylesheet distribution.
- See ../README or http://docbook.sf.net/release/xsl/current/ for
- copyright and other information.
- ******************************************************************** -->
- <!-- ==================================================================== -->
- <xsl:template name="set.toc">
- <xsl:param name="toc-context" select="."/>
- <xsl:variable name="id">
- <xsl:call-template name="object.id"/>
- </xsl:variable>
- <xsl:variable name="cid">
- <xsl:call-template name="object.id">
- <xsl:with-param name="object" select="$toc-context"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:variable name="nodes" select="book|set|setindex"/>
- <xsl:if test="$nodes">
- <fo:block id="toc...{$id}"
- xsl:use-attribute-sets="toc.margin.properties">
- <xsl:if test="$axf.extensions != 0">
- <xsl:attribute name="axf:outline-level">1</xsl:attribute>
- <xsl:attribute name="axf:outline-expand">false</xsl:attribute>
- <xsl:attribute name="axf:outline-title">
- <xsl:call-template name="gentext">
- <xsl:with-param name="key" select="'TableofContents'"/>
- </xsl:call-template>
- </xsl:attribute>
- </xsl:if>
- <xsl:call-template name="table.of.contents.titlepage"/>
- <xsl:apply-templates select="$nodes" mode="toc">
- <xsl:with-param name="toc-context" select="$toc-context"/>
- </xsl:apply-templates>
- </fo:block>
- </xsl:if>
- </xsl:template>
- <xsl:template name="division.toc">
- <xsl:param name="toc-context" select="."/>
- <xsl:param name="toc.title.p" select="true()"/>
- <xsl:variable name="cid">
- <xsl:call-template name="object.id">
- <xsl:with-param name="object" select="$toc-context"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:variable name="nodes"
- select="$toc-context/part
- |$toc-context/reference
- |$toc-context/preface
- |$toc-context/chapter
- |$toc-context/appendix
- |$toc-context/article
- |$toc-context/topic
- |$toc-context/bibliography
- |$toc-context/glossary
- |$toc-context/index"/>
- <xsl:if test="$nodes">
- <fo:block id="toc...{$cid}"
- xsl:use-attribute-sets="toc.margin.properties">
- <xsl:if test="$axf.extensions != 0">
- <xsl:attribute name="axf:outline-level">1</xsl:attribute>
- <xsl:attribute name="axf:outline-expand">false</xsl:attribute>
- <xsl:attribute name="axf:outline-title">
- <xsl:call-template name="gentext">
- <xsl:with-param name="key" select="'TableofContents'"/>
- </xsl:call-template>
- </xsl:attribute>
- </xsl:if>
- <xsl:if test="$toc.title.p">
- <xsl:call-template name="table.of.contents.titlepage"/>
- </xsl:if>
- <xsl:apply-templates select="$nodes" mode="toc">
- <xsl:with-param name="toc-context" select="$toc-context"/>
- </xsl:apply-templates>
- </fo:block>
- </xsl:if>
- </xsl:template>
- <xsl:template name="component.toc">
- <xsl:param name="toc-context" select="."/>
- <xsl:param name="toc.title.p" select="true()"/>
- <xsl:variable name="id">
- <xsl:call-template name="object.id"/>
- </xsl:variable>
- <xsl:variable name="cid">
- <xsl:call-template name="object.id">
- <xsl:with-param name="object" select="$toc-context"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:variable name="nodes" select="section|sect1|refentry
- |article|topic|bibliography|glossary
- |qandaset[$qanda.in.toc != 0]
- |appendix|index"/>
- <xsl:if test="$nodes">
- <fo:block id="toc...{$id}"
- xsl:use-attribute-sets="toc.margin.properties">
- <xsl:if test="$toc.title.p">
- <xsl:call-template name="table.of.contents.titlepage"/>
- </xsl:if>
- <xsl:apply-templates select="$nodes" mode="toc">
- <xsl:with-param name="toc-context" select="$toc-context"/>
- </xsl:apply-templates>
- </fo:block>
- </xsl:if>
- </xsl:template>
- <xsl:template name="component.toc.separator">
- <!-- Customize to output something between
- component.toc and first output -->
- </xsl:template>
- <xsl:template name="section.toc">
- <xsl:param name="toc-context" select="."/>
- <xsl:param name="toc.title.p" select="true()"/>
- <xsl:variable name="id">
- <xsl:call-template name="object.id"/>
- </xsl:variable>
- <xsl:variable name="cid">
- <xsl:call-template name="object.id">
- <xsl:with-param name="object" select="$toc-context"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:variable name="nodes"
- select="section|sect1|sect2|sect3|sect4|sect5|refentry
- |qandaset[$qanda.in.toc != 0]
- |bridgehead[$bridgehead.in.toc != 0]"/>
- <xsl:variable name="level">
- <xsl:call-template name="section.level"/>
- </xsl:variable>
- <xsl:if test="$nodes">
- <fo:block id="toc...{$id}"
- xsl:use-attribute-sets="toc.margin.properties">
- <xsl:if test="$toc.title.p">
- <xsl:call-template name="section.heading">
- <xsl:with-param name="level" select="$level + 1"/>
- <xsl:with-param name="title">
- <fo:block space-after="0.5em">
- <xsl:call-template name="gentext">
- <xsl:with-param name="key" select="'TableofContents'"/>
- </xsl:call-template>
- </fo:block>
- </xsl:with-param>
- </xsl:call-template>
- </xsl:if>
- <xsl:apply-templates select="$nodes" mode="toc">
- <xsl:with-param name="toc-context" select="$toc-context"/>
- </xsl:apply-templates>
- </fo:block>
- </xsl:if>
- </xsl:template>
- <xsl:template name="section.toc.separator">
- <!-- Customize to output something between
- section.toc and first output -->
- </xsl:template>
- <!-- ==================================================================== -->
- <xsl:template name="toc.line">
- <xsl:param name="toc-context" select="NOTANODE"/>
- <xsl:variable name="id">
- <xsl:call-template name="object.id"/>
- </xsl:variable>
- <xsl:variable name="label">
- <xsl:apply-templates select="." mode="label.markup"/>
- </xsl:variable>
- <fo:block xsl:use-attribute-sets="toc.line.properties">
- <fo:inline keep-with-next.within-line="always">
- <fo:basic-link internal-destination="{$id}">
- <xsl:if test="$label != ''">
- <xsl:copy-of select="$label"/>
- <xsl:value-of select="$autotoc.label.separator"/>
- </xsl:if>
- <xsl:apply-templates select="." mode="titleabbrev.markup"/>
- </fo:basic-link>
- </fo:inline>
- <fo:inline keep-together.within-line="always">
- <xsl:text> </xsl:text>
- <fo:leader leader-pattern="dots"
- leader-pattern-width="3pt"
- leader-alignment="reference-area"
- keep-with-next.within-line="always"/>
- <xsl:text> </xsl:text>
- <fo:basic-link internal-destination="{$id}">
- <fo:page-number-citation ref-id="{$id}"/>
- </fo:basic-link>
- </fo:inline>
- </fo:block>
- </xsl:template>
- <!-- ==================================================================== -->
- <xsl:template name="qandaset.toc">
- <xsl:param name="toc-context" select="."/>
- <xsl:param name="toc.title.p" select="true()"/>
- <xsl:variable name="id">
- <xsl:call-template name="object.id"/>
- </xsl:variable>
- <xsl:variable name="cid">
- <xsl:call-template name="object.id">
- <xsl:with-param name="object" select="$toc-context"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:variable name="nodes" select="qandadiv|qandaentry"/>
- <xsl:if test="$nodes">
- <fo:block id="toc...{$id}"
- xsl:use-attribute-sets="toc.margin.properties">
- <xsl:if test="$toc.title.p">
- <xsl:call-template name="table.of.contents.titlepage"/>
- </xsl:if>
- <xsl:apply-templates select="$nodes" mode="toc">
- <xsl:with-param name="toc-context" select="$toc-context"/>
- </xsl:apply-templates>
- </fo:block>
- </xsl:if>
- </xsl:template>
- <xsl:template name="qandaset.toc.separator">
- <!-- Customize to output something between
- qandaset.toc and first output -->
- </xsl:template>
- <xsl:template match="qandadiv" mode="toc">
- <xsl:param name="toc-context" select="."/>
- <xsl:variable name="id">
- <xsl:call-template name="object.id"/>
- </xsl:variable>
- <xsl:variable name="cid">
- <xsl:call-template name="object.id">
- <xsl:with-param name="object" select="$toc-context"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:call-template name="toc.line">
- <xsl:with-param name="toc-context" select="$toc-context"/>
- </xsl:call-template>
- <xsl:variable name="nodes" select="qandadiv|qandaentry"/>
- <xsl:if test="$nodes">
- <fo:block id="toc.{$cid}.{$id}">
- <xsl:attribute name="margin-{$direction.align.start}">
- <xsl:call-template name="set.toc.indent"/>
- </xsl:attribute>
- <xsl:apply-templates select="$nodes" mode="toc">
- <xsl:with-param name="toc-context" select="$toc-context"/>
- </xsl:apply-templates>
- </fo:block>
- </xsl:if>
- </xsl:template>
- <xsl:template match="qandaentry" mode="toc">
- <xsl:apply-templates select="question" mode="toc"/>
- </xsl:template>
- <xsl:template match="question" mode="toc">
- <xsl:variable name="firstchunk">
- <!-- Use a titleabbrev or title if available -->
- <xsl:choose>
- <xsl:when test="../blockinfo/titleabbrev">
- <xsl:apply-templates select="../blockinfo/titleabbrev[1]/node()"/>
- </xsl:when>
- <xsl:when test="../blockinfo/title">
- <xsl:apply-templates select="../blockinfo/title[1]/node()"/>
- </xsl:when>
- <xsl:when test="../info/titleabbrev">
- <xsl:apply-templates select="../info/titleabbrev[1]/node()"/>
- </xsl:when>
- <xsl:when test="../titleabbrev">
- <xsl:apply-templates select="../titleabbrev[1]/node()"/>
- </xsl:when>
- <xsl:when test="../info/title">
- <xsl:apply-templates select="../info/title[1]/node()"/>
- </xsl:when>
- <xsl:when test="../title">
- <xsl:apply-templates select="../title[1]/node()"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:apply-templates select="(*[local-name(.)!='label'])[1]/node()"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:variable name="deflabel">
- <xsl:choose>
- <xsl:when test="ancestor-or-self::*[@defaultlabel]">
- <xsl:value-of select="(ancestor-or-self::*[@defaultlabel])[last()]
- /@defaultlabel"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$qanda.defaultlabel"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:variable name="id">
- <xsl:call-template name="object.id"/>
- </xsl:variable>
- <xsl:variable name="label">
- <xsl:apply-templates select="." mode="label.markup"/>
- </xsl:variable>
- <fo:block xsl:use-attribute-sets="toc.line.properties"
- end-indent="{$toc.indent.width}pt"
- last-line-end-indent="-{$toc.indent.width}pt">
- <xsl:attribute name="margin-{$direction.align.start}">3em</xsl:attribute>
- <xsl:attribute name="text-indent">-3em</xsl:attribute>
- <fo:inline keep-with-next.within-line="always">
- <fo:basic-link internal-destination="{$id}">
- <xsl:if test="$label != ''">
- <xsl:copy-of select="$label"/>
- <xsl:if test="$deflabel = 'number' and not(label)">
- <xsl:value-of select="$autotoc.label.separator"/>
- </xsl:if>
- <xsl:text> </xsl:text>
- </xsl:if>
- <xsl:copy-of select="$firstchunk"/>
- </fo:basic-link>
- </fo:inline>
- <fo:inline keep-together.within-line="always">
- <xsl:text> </xsl:text>
- <fo:leader leader-pattern="dots"
- leader-pattern-width="3pt"
- leader-alignment="reference-area"
- keep-with-next.within-line="always"/>
- <xsl:text> </xsl:text>
- <fo:basic-link internal-destination="{$id}">
- <fo:page-number-citation ref-id="{$id}"/>
- </fo:basic-link>
- </fo:inline>
- </fo:block>
- </xsl:template>
- <!-- ==================================================================== -->
- <xsl:template match="book|setindex" mode="toc">
- <xsl:param name="toc-context" select="."/>
- <xsl:variable name="id">
- <xsl:call-template name="object.id"/>
- </xsl:variable>
- <xsl:variable name="cid">
- <xsl:call-template name="object.id">
- <xsl:with-param name="object" select="$toc-context"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:call-template name="toc.line">
- <xsl:with-param name="toc-context" select="$toc-context"/>
- </xsl:call-template>
- <xsl:variable name="nodes" select="glossary|bibliography|preface|chapter
- |reference|part|article|topic|appendix|index"/>
- <xsl:variable name="depth.from.context" select="count(ancestor::*)-count($toc-context/ancestor::*)"/>
- <xsl:if test="$toc.max.depth > $depth.from.context
- and $nodes">
- <fo:block id="toc.{$cid}.{$id}">
- <xsl:attribute name="margin-{$direction.align.start}">
- <xsl:call-template name="set.toc.indent"/>
- </xsl:attribute>
- <xsl:apply-templates select="$nodes" mode="toc">
- <xsl:with-param name="toc-context" select="$toc-context"/>
- </xsl:apply-templates>
- </fo:block>
- </xsl:if>
- </xsl:template>
- <xsl:template match="set" mode="toc">
- <xsl:param name="toc-context" select="."/>
- <xsl:variable name="id">
- <xsl:call-template name="object.id"/>
- </xsl:variable>
- <xsl:variable name="cid">
- <xsl:call-template name="object.id">
- <xsl:with-param name="object" select="$toc-context"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:call-template name="toc.line">
- <xsl:with-param name="toc-context" select="$toc-context"/>
- </xsl:call-template>
- <xsl:variable name="nodes" select="set|book|setindex"/>
- <xsl:variable name="depth.from.context" select="count(ancestor::*)-count($toc-context/ancestor::*)"/>
- <xsl:if test="$toc.max.depth > $depth.from.context
- and $nodes">
- <fo:block id="toc.{$cid}.{$id}">
- <xsl:attribute name="margin-{$direction.align.start}">
- <xsl:call-template name="set.toc.indent"/>
- </xsl:attribute>
-
- <xsl:apply-templates select="$nodes" mode="toc">
- <xsl:with-param name="toc-context" select="$toc-context"/>
- </xsl:apply-templates>
- </fo:block>
- </xsl:if>
- </xsl:template>
- <xsl:template match="part" mode="toc">
- <xsl:param name="toc-context" select="."/>
- <xsl:variable name="id">
- <xsl:call-template name="object.id"/>
- </xsl:variable>
- <xsl:variable name="cid">
- <xsl:call-template name="object.id">
- <xsl:with-param name="object" select="$toc-context"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:call-template name="toc.line">
- <xsl:with-param name="toc-context" select="$toc-context"/>
- </xsl:call-template>
- <xsl:variable name="nodes" select="chapter|appendix|preface|reference|
- refentry|article|topic|index|glossary|
- bibliography"/>
- <xsl:variable name="depth.from.context" select="count(ancestor::*)-count($toc-context/ancestor::*)"/>
- <xsl:if test="$toc.max.depth > $depth.from.context
- and $nodes">
- <fo:block id="toc.{$cid}.{$id}">
- <xsl:attribute name="margin-{$direction.align.start}">
- <xsl:call-template name="set.toc.indent"/>
- </xsl:attribute>
-
- <xsl:apply-templates select="$nodes" mode="toc">
- <xsl:with-param name="toc-context" select="$toc-context"/>
- </xsl:apply-templates>
- </fo:block>
- </xsl:if>
- </xsl:template>
- <xsl:template match="reference" mode="toc">
- <xsl:param name="toc-context" select="."/>
- <xsl:variable name="id">
- <xsl:call-template name="object.id"/>
- </xsl:variable>
- <xsl:variable name="cid">
- <xsl:call-template name="object.id">
- <xsl:with-param name="object" select="$toc-context"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:variable name="depth.from.context" select="count(ancestor::*)-count($toc-context/ancestor::*)"/>
- <xsl:call-template name="toc.line">
- <xsl:with-param name="toc-context" select="$toc-context"/>
- </xsl:call-template>
- <xsl:if test="$toc.section.depth > 0
- and $toc.max.depth > $depth.from.context
- and refentry">
- <fo:block id="toc.{$cid}.{$id}">
- <xsl:attribute name="margin-{$direction.align.start}">
- <xsl:call-template name="set.toc.indent"/>
- </xsl:attribute>
-
- <xsl:apply-templates select="refentry" mode="toc">
- <xsl:with-param name="toc-context" select="$toc-context"/>
- </xsl:apply-templates>
- </fo:block>
- </xsl:if>
- </xsl:template>
- <xsl:template match="refentry" mode="toc">
- <xsl:param name="toc-context" select="."/>
- <xsl:call-template name="toc.line">
- <xsl:with-param name="toc-context" select="$toc-context"/>
- </xsl:call-template>
- </xsl:template>
- <xsl:template match="preface|chapter|appendix|article"
- mode="toc">
- <xsl:param name="toc-context" select="."/>
- <xsl:variable name="id">
- <xsl:call-template name="object.id"/>
- </xsl:variable>
- <xsl:variable name="cid">
- <xsl:call-template name="object.id">
- <xsl:with-param name="object" select="$toc-context"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:call-template name="toc.line">
- <xsl:with-param name="toc-context" select="$toc-context"/>
- </xsl:call-template>
- <xsl:variable name="nodes" select="section|sect1
- |qandaset[$qanda.in.toc != 0]
- |simplesect[$simplesect.in.toc != 0]
- |topic
- |refentry|appendix"/>
- <xsl:variable name="depth.from.context" select="count(ancestor::*)-count($toc-context/ancestor::*)"/>
- <xsl:if test="$toc.section.depth > 0
- and $toc.max.depth > $depth.from.context
- and $nodes">
- <fo:block id="toc.{$cid}.{$id}">
- <xsl:attribute name="margin-{$direction.align.start}">
- <xsl:call-template name="set.toc.indent"/>
- </xsl:attribute>
-
- <xsl:apply-templates select="$nodes" mode="toc">
- <xsl:with-param name="toc-context" select="$toc-context"/>
- </xsl:apply-templates>
- </fo:block>
- </xsl:if>
- </xsl:template>
- <xsl:template match="sect1" mode="toc">
- <xsl:param name="toc-context" select="."/>
- <xsl:variable name="id">
- <xsl:call-template name="object.id"/>
- </xsl:variable>
- <xsl:variable name="cid">
- <xsl:call-template name="object.id">
- <xsl:with-param name="object" select="$toc-context"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:call-template name="toc.line">
- <xsl:with-param name="toc-context" select="$toc-context"/>
- </xsl:call-template>
- <xsl:variable name="depth.from.context" select="count(ancestor::*)-count($toc-context/ancestor::*)"/>
- <xsl:if test="$toc.section.depth > 1
- and $toc.max.depth > $depth.from.context
- and sect2">
- <fo:block id="toc.{$cid}.{$id}">
- <xsl:attribute name="margin-{$direction.align.start}">
- <xsl:call-template name="set.toc.indent"/>
- </xsl:attribute>
-
- <xsl:apply-templates select="sect2|qandaset[$qanda.in.toc != 0]"
- mode="toc">
- <xsl:with-param name="toc-context" select="$toc-context"/>
- </xsl:apply-templates>
- </fo:block>
- </xsl:if>
- </xsl:template>
- <xsl:template match="sect2" mode="toc">
- <xsl:param name="toc-context" select="."/>
- <xsl:variable name="id">
- <xsl:call-template name="object.id"/>
- </xsl:variable>
- <xsl:variable name="cid">
- <xsl:call-template name="object.id">
- <xsl:with-param name="object" select="$toc-context"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:call-template name="toc.line">
- <xsl:with-param name="toc-context" select="$toc-context"/>
- </xsl:call-template>
- <xsl:variable name="reldepth"
- select="count(ancestor::*)-count($toc-context/ancestor::*)"/>
- <xsl:variable name="depth.from.context" select="count(ancestor::*)-count($toc-context/ancestor::*)"/>
- <xsl:if test="$toc.section.depth > 2
- and $toc.max.depth > $depth.from.context
- and sect3">
- <fo:block id="toc.{$cid}.{$id}">
- <xsl:attribute name="margin-{$direction.align.start}">
- <xsl:call-template name="set.toc.indent">
- <xsl:with-param name="reldepth" select="$reldepth"/>
- </xsl:call-template>
- </xsl:attribute>
-
- <xsl:apply-templates select="sect3|qandaset[$qanda.in.toc != 0]"
- mode="toc">
- <xsl:with-param name="toc-context" select="$toc-context"/>
- </xsl:apply-templates>
- </fo:block>
- </xsl:if>
- </xsl:template>
- <xsl:template match="sect3" mode="toc">
- <xsl:param name="toc-context" select="."/>
- <xsl:variable name="id">
- <xsl:call-template name="object.id"/>
- </xsl:variable>
- <xsl:variable name="cid">
- <xsl:call-template name="object.id">
- <xsl:with-param name="object" select="$toc-context"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:call-template name="toc.line">
- <xsl:with-param name="toc-context" select="$toc-context"/>
- </xsl:call-template>
- <xsl:variable name="reldepth"
- select="count(ancestor::*)-count($toc-context/ancestor::*)"/>
- <xsl:variable name="depth.from.context" select="count(ancestor::*)-count($toc-context/ancestor::*)"/>
- <xsl:if test="$toc.section.depth > 3
- and $toc.max.depth > $depth.from.context
- and sect4">
- <fo:block id="toc.{$cid}.{$id}">
- <xsl:attribute name="margin-{$direction.align.start}">
- <xsl:call-template name="set.toc.indent">
- <xsl:with-param name="reldepth" select="$reldepth"/>
- </xsl:call-template>
- </xsl:attribute>
-
- <xsl:apply-templates select="sect4|qandaset[$qanda.in.toc != 0]"
- mode="toc">
- <xsl:with-param name="toc-context" select="$toc-context"/>
- </xsl:apply-templates>
- </fo:block>
- </xsl:if>
- </xsl:template>
- <xsl:template match="sect4" mode="toc">
- <xsl:param name="toc-context" select="."/>
- <xsl:variable name="id">
- <xsl:call-template name="object.id"/>
- </xsl:variable>
- <xsl:variable name="cid">
- <xsl:call-template name="object.id">
- <xsl:with-param name="object" select="$toc-context"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:call-template name="toc.line">
- <xsl:with-param name="toc-context" select="$toc-context"/>
- </xsl:call-template>
- <xsl:variable name="reldepth"
- select="count(ancestor::*)-count($toc-context/ancestor::*)"/>
- <xsl:variable name="depth.from.context" select="count(ancestor::*)-count($toc-context/ancestor::*)"/>
- <xsl:if test="$toc.section.depth > 4
- and $toc.max.depth > $depth.from.context
- and sect5">
- <fo:block id="toc.{$cid}.{$id}">
- <xsl:attribute name="margin-{$direction.align.start}">
- <xsl:call-template name="set.toc.indent">
- <xsl:with-param name="reldepth" select="$reldepth"/>
- </xsl:call-template>
- </xsl:attribute>
-
- <xsl:apply-templates select="sect5|qandaset[$qanda.in.toc != 0]"
- mode="toc">
- <xsl:with-param name="toc-context" select="$toc-context"/>
- </xsl:apply-templates>
- </fo:block>
- </xsl:if>
- </xsl:template>
- <xsl:template match="sect5|simplesect" mode="toc">
- <xsl:param name="toc-context" select="."/>
- <xsl:call-template name="toc.line">
- <xsl:with-param name="toc-context" select="$toc-context"/>
- </xsl:call-template>
- </xsl:template>
- <xsl:template match="topic" mode="toc">
- <xsl:param name="toc-context" select="."/>
- <xsl:call-template name="toc.line">
- <xsl:with-param name="toc-context" select="$toc-context"/>
- </xsl:call-template>
- </xsl:template>
- <xsl:template name="set.toc.indent">
- <xsl:param name="reldepth"/>
- <xsl:variable name="depth">
- <xsl:choose>
- <xsl:when test="$reldepth != ''">
- <xsl:value-of select="$reldepth"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="count(ancestor::*)"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:choose>
- <xsl:when test="$fop.extensions != 0">
- <xsl:value-of select="concat($depth*$toc.indent.width, 'pt')"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="concat($toc.indent.width, 'pt')"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <xsl:template match="section" mode="toc">
- <xsl:param name="toc-context" select="."/>
- <xsl:variable name="id">
- <xsl:call-template name="object.id"/>
- </xsl:variable>
- <xsl:variable name="cid">
- <xsl:call-template name="object.id">
- <xsl:with-param name="object" select="$toc-context"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:variable name="depth" select="count(ancestor::section) + 1"/>
- <xsl:variable name="reldepth"
- select="count(ancestor::*)-count($toc-context/ancestor::*)"/>
- <xsl:variable name="depth.from.context" select="count(ancestor::*)-count($toc-context/ancestor::*)"/>
- <xsl:if test="$toc.section.depth >= $depth">
- <xsl:call-template name="toc.line">
- <xsl:with-param name="toc-context" select="$toc-context"/>
- </xsl:call-template>
- <xsl:if test="$toc.section.depth > $depth
- and $toc.max.depth > $depth.from.context
- and section">
- <fo:block id="toc.{$cid}.{$id}">
- <xsl:attribute name="margin-{$direction.align.start}">
- <xsl:call-template name="set.toc.indent">
- <xsl:with-param name="reldepth" select="$reldepth"/>
- </xsl:call-template>
- </xsl:attribute>
-
- <xsl:apply-templates select="section|qandaset[$qanda.in.toc != 0]"
- mode="toc">
- <xsl:with-param name="toc-context" select="$toc-context"/>
- </xsl:apply-templates>
- </fo:block>
- </xsl:if>
- </xsl:if>
- </xsl:template>
- <xsl:template match="bibliography|glossary"
- mode="toc">
- <xsl:param name="toc-context" select="."/>
- <xsl:call-template name="toc.line">
- <xsl:with-param name="toc-context" select="$toc-context"/>
- </xsl:call-template>
- </xsl:template>
- <xsl:template match="index" mode="toc">
- <xsl:param name="toc-context" select="."/>
- <xsl:if test="* or $generate.index != 0">
- <xsl:call-template name="toc.line">
- <xsl:with-param name="toc-context" select="$toc-context"/>
- </xsl:call-template>
- </xsl:if>
- </xsl:template>
- <xsl:template match="title" mode="toc">
- <xsl:apply-templates/>
- </xsl:template>
- <!-- ==================================================================== -->
- <xsl:template name="list.of.titles">
- <xsl:param name="titles" select="'table'"/>
- <xsl:param name="nodes" select=".//table"/>
- <xsl:param name="toc-context" select="."/>
- <xsl:variable name="id">
- <xsl:call-template name="object.id"/>
- </xsl:variable>
- <xsl:if test="$nodes">
- <fo:block id="lot...{$titles}...{$id}">
- <xsl:choose>
- <xsl:when test="$titles='table'">
- <xsl:call-template name="list.of.tables.titlepage"/>
- </xsl:when>
- <xsl:when test="$titles='figure'">
- <xsl:call-template name="list.of.figures.titlepage"/>
- </xsl:when>
- <xsl:when test="$titles='equation'">
- <xsl:call-template name="list.of.equations.titlepage"/>
- </xsl:when>
- <xsl:when test="$titles='example'">
- <xsl:call-template name="list.of.examples.titlepage"/>
- </xsl:when>
- <xsl:when test="$titles='procedure'">
- <xsl:call-template name="list.of.procedures.titlepage"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="list.of.unknowns.titlepage"/>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:apply-templates select="$nodes" mode="toc">
- <xsl:with-param name="toc-context" select="$toc-context"/>
- </xsl:apply-templates>
- </fo:block>
- </xsl:if>
- </xsl:template>
- <xsl:template name="component.list.of.titles">
- <xsl:param name="titles" select="'table'"/>
- <xsl:param name="nodes" select=".//table"/>
- <xsl:param name="toc-context" select="."/>
- <xsl:variable name="id">
- <xsl:call-template name="object.id"/>
- </xsl:variable>
- <xsl:if test="$nodes">
- <fo:block id="lot...{$titles}...{$id}">
- <xsl:choose>
- <xsl:when test="$titles='table'">
- <xsl:call-template name="component.list.of.tables.titlepage"/>
- </xsl:when>
- <xsl:when test="$titles='figure'">
- <xsl:call-template name="component.list.of.figures.titlepage"/>
- </xsl:when>
- <xsl:when test="$titles='equation'">
- <xsl:call-template name="component.list.of.equations.titlepage"/>
- </xsl:when>
- <xsl:when test="$titles='example'">
- <xsl:call-template name="component.list.of.examples.titlepage"/>
- </xsl:when>
- <xsl:when test="$titles='procedure'">
- <xsl:call-template name="component.list.of.procedures.titlepage"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="component.list.of.unknowns.titlepage"/>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:apply-templates select="$nodes" mode="toc">
- <xsl:with-param name="toc-context" select="$toc-context"/>
- </xsl:apply-templates>
- </fo:block>
- </xsl:if>
- </xsl:template>
- <xsl:template match="figure|table|example|equation|procedure" mode="toc">
- <xsl:param name="toc-context" select="."/>
- <xsl:call-template name="toc.line">
- <xsl:with-param name="toc-context" select="$toc-context"/>
- </xsl:call-template>
- </xsl:template>
- <!-- ==================================================================== -->
- <!-- qandaset handled like a section when qanda.in.toc is set -->
- <xsl:template match="qandaset" mode="toc">
- <xsl:param name="toc-context" select="."/>
- <xsl:variable name="id">
- <xsl:call-template name="object.id"/>
- </xsl:variable>
- <xsl:variable name="cid">
- <xsl:call-template name="object.id">
- <xsl:with-param name="object" select="$toc-context"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:variable name="depth" select="count(ancestor::section) + 1"/>
- <xsl:variable name="reldepth"
- select="count(ancestor::*)-count($toc-context/ancestor::*)"/>
- <xsl:variable name="depth.from.context" select="count(ancestor::*)-count($toc-context/ancestor::*)"/>
- <xsl:if test="$toc.section.depth >= $depth">
- <xsl:call-template name="toc.line">
- <xsl:with-param name="toc-context" select="$toc-context"/>
- </xsl:call-template>
- <xsl:if test="$toc.section.depth > $depth
- and $toc.max.depth > $depth.from.context
- and (child::qandadiv or child::qandaentry)">
- <fo:block id="toc.{$cid}.{$id}">
- <xsl:attribute name="margin-{$direction.align.start}">
- <xsl:call-template name="set.toc.indent">
- <xsl:with-param name="reldepth" select="$reldepth"/>
- </xsl:call-template>
- </xsl:attribute>
-
- <xsl:apply-templates select="qandadiv|qandaentry" mode="toc">
- <xsl:with-param name="toc-context" select="$toc-context"/>
- </xsl:apply-templates>
- </fo:block>
- </xsl:if>
- </xsl:if>
- </xsl:template>
- </xsl:stylesheet>
|