123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332 |
- <?xml version="1.0" encoding="ASCII"?>
- <!--This file was created automatically by html2xhtml-->
- <!--from the HTML stylesheets.-->
- <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml" version="1.0">
- <!-- ********************************************************************
- $Id: toc.xsl 9297 2012-04-22 03:56:16Z 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 match="set/toc | book/toc | part/toc">
- <xsl:variable name="toc.params">
- <xsl:call-template name="find.path.params">
- <xsl:with-param name="node" select="parent::*"/>
- <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
- </xsl:call-template>
- </xsl:variable>
- <!-- Do not output the toc element if one is already generated
- by the use of $generate.toc parameter, or if
- generating a source toc is turned off -->
- <xsl:if test="not(contains($toc.params, 'toc')) and ($process.source.toc != 0 or $process.empty.source.toc != 0)">
- <xsl:variable name="content">
- <xsl:choose>
- <xsl:when test="* and $process.source.toc != 0">
- <xsl:apply-templates/>
- </xsl:when>
- <xsl:when test="count(*) = 0 and $process.empty.source.toc != 0">
- <!-- trick to switch context node to parent element -->
- <xsl:for-each select="parent::*">
- <xsl:choose>
- <xsl:when test="self::set">
- <xsl:call-template name="set.toc">
- <xsl:with-param name="toc.title.p" select="contains($toc.params, 'title')"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:when test="self::book">
- <xsl:call-template name="division.toc">
- <xsl:with-param name="toc.title.p" select="contains($toc.params, 'title')"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:when test="self::part">
- <xsl:call-template name="division.toc">
- <xsl:with-param name="toc.title.p" select="contains($toc.params, 'title')"/>
- </xsl:call-template>
- </xsl:when>
- </xsl:choose>
- </xsl:for-each>
- </xsl:when>
- </xsl:choose>
- </xsl:variable>
- <xsl:if test="string-length(normalize-space($content)) != 0">
- <xsl:copy-of select="$content"/>
- </xsl:if>
- </xsl:if>
- </xsl:template>
-
- <xsl:template match="chapter/toc | appendix/toc | preface/toc | article/toc">
- <xsl:variable name="toc.params">
- <xsl:call-template name="find.path.params">
- <xsl:with-param name="node" select="parent::*"/>
- <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
- </xsl:call-template>
- </xsl:variable>
- <!-- Do not output the toc element if one is already generated
- by the use of $generate.toc parameter, or if
- generating a source toc is turned off -->
- <xsl:if test="not(contains($toc.params, 'toc')) and ($process.source.toc != 0 or $process.empty.source.toc != 0)">
- <xsl:choose>
- <xsl:when test="* and $process.source.toc != 0">
- <div>
- <xsl:apply-templates select="." mode="common.html.attributes"/>
- <xsl:call-template name="id.attribute"/>
- <xsl:apply-templates select="title"/>
- <dl>
- <xsl:apply-templates select="." mode="common.html.attributes"/>
- <xsl:apply-templates select="*[not(self::title)]"/>
- </dl>
- </div>
- <xsl:call-template name="component.toc.separator"/>
- </xsl:when>
- <xsl:when test="count(*) = 0 and $process.empty.source.toc != 0">
- <!-- trick to switch context node to section element -->
- <xsl:for-each select="parent::*">
- <xsl:call-template name="component.toc">
- <xsl:with-param name="toc.title.p" select="contains($toc.params, 'title')"/>
- </xsl:call-template>
- </xsl:for-each>
- <xsl:call-template name="component.toc.separator"/>
- </xsl:when>
- </xsl:choose>
- </xsl:if>
- </xsl:template>
- <xsl:template match="section/toc |sect1/toc |sect2/toc |sect3/toc |sect4/toc |sect5/toc">
- <xsl:variable name="toc.params">
- <xsl:call-template name="find.path.params">
- <xsl:with-param name="node" select="parent::*"/>
- <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
- </xsl:call-template>
- </xsl:variable>
- <!-- Do not output the toc element if one is already generated
- by the use of $generate.toc parameter, or if
- generating a source toc is turned off -->
- <xsl:if test="not(contains($toc.params, 'toc')) and ($process.source.toc != 0 or $process.empty.source.toc != 0)">
- <xsl:choose>
- <xsl:when test="* and $process.source.toc != 0">
- <div>
- <xsl:apply-templates select="." mode="common.html.attributes"/>
- <xsl:call-template name="id.attribute"/>
- <xsl:apply-templates select="title"/>
- <dl>
- <xsl:apply-templates select="." mode="common.html.attributes"/>
- <xsl:apply-templates select="*[not(self::title)]"/>
- </dl>
- </div>
- <xsl:call-template name="section.toc.separator"/>
- </xsl:when>
- <xsl:when test="count(*) = 0 and $process.empty.source.toc != 0">
- <!-- trick to switch context node to section element -->
- <xsl:for-each select="parent::*">
- <xsl:call-template name="section.toc">
- <xsl:with-param name="toc.title.p" select="contains($toc.params, 'title')"/>
- </xsl:call-template>
- </xsl:for-each>
- <xsl:call-template name="section.toc.separator"/>
- </xsl:when>
- </xsl:choose>
- </xsl:if>
- </xsl:template>
- <!-- ==================================================================== -->
- <xsl:template match="tocpart|tocchap |toclevel1|toclevel2|toclevel3|toclevel4|toclevel5">
- <xsl:variable name="sub-toc">
- <xsl:if test="tocchap|toclevel1|toclevel2|toclevel3|toclevel4|toclevel5">
- <xsl:choose>
- <xsl:when test="$toc.list.type = 'dl'">
- <dd>
- <xsl:apply-templates select="." mode="common.html.attributes"/>
- <xsl:element name="{$toc.list.type}" namespace="http://www.w3.org/1999/xhtml">
- <xsl:apply-templates select="." mode="common.html.attributes"/>
- <xsl:apply-templates select="tocchap|toclevel1|toclevel2| toclevel3|toclevel4|toclevel5"/>
- </xsl:element>
- </dd>
- </xsl:when>
- <xsl:otherwise>
- <xsl:element name="{$toc.list.type}" namespace="http://www.w3.org/1999/xhtml">
- <xsl:apply-templates select="." mode="common.html.attributes"/>
- <xsl:apply-templates select="tocchap|toclevel1|toclevel2| toclevel3|toclevel4|toclevel5"/>
- </xsl:element>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:if>
- </xsl:variable>
- <xsl:apply-templates select="tocentry[position() != last()]"/>
- <xsl:choose>
- <xsl:when test="$toc.list.type = 'dl'">
- <dt>
- <xsl:apply-templates select="." mode="common.html.attributes"/>
- <xsl:apply-templates select="tocentry[position() = last()]"/>
- </dt>
- <xsl:copy-of select="$sub-toc"/>
- </xsl:when>
- <xsl:otherwise>
- <li>
- <xsl:apply-templates select="." mode="common.html.attributes"/>
- <xsl:apply-templates select="tocentry[position() = last()]"/>
- <xsl:copy-of select="$sub-toc"/>
- </li>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <xsl:template match="tocentry|tocdiv|lotentry|tocfront|tocback">
- <xsl:choose>
- <xsl:when test="$toc.list.type = 'dl'">
- <dt>
- <xsl:apply-templates select="." mode="common.html.attributes"/>
- <xsl:call-template name="tocentry-content"/>
- </dt>
- </xsl:when>
- <xsl:otherwise>
- <li>
- <xsl:apply-templates select="." mode="common.html.attributes"/>
- <xsl:call-template name="tocentry-content"/>
- </li>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <xsl:template match="tocentry[position() = last()]" priority="2">
- <xsl:call-template name="tocentry-content"/>
- </xsl:template>
- <xsl:template name="tocentry-content">
- <xsl:variable name="targets" select="key('id',@linkend)"/>
- <xsl:variable name="target" select="$targets[1]"/>
- <xsl:choose>
- <xsl:when test="@linkend">
- <xsl:call-template name="check.id.unique">
- <xsl:with-param name="linkend" select="@linkend"/>
- </xsl:call-template>
- <a>
- <xsl:attribute name="href">
- <xsl:call-template name="href.target">
- <xsl:with-param name="object" select="$target"/>
- </xsl:call-template>
- </xsl:attribute>
- <xsl:apply-templates/>
- </a>
- </xsl:when>
- <xsl:otherwise>
- <xsl:apply-templates/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <xsl:template match="toc/title">
- <div>
- <xsl:apply-templates select="." mode="common.html.attributes"/>
- <xsl:apply-templates/>
- </div>
- </xsl:template>
- <xsl:template match="toc/subtitle">
- <div>
- <xsl:apply-templates select="." mode="common.html.attributes"/>
- <xsl:apply-templates/>
- </div>
- </xsl:template>
- <xsl:template match="toc/titleabbrev">
- </xsl:template>
- <!-- ==================================================================== -->
- <!-- A lot element must have content, because there is no attribute
- to select what kind of list should be generated -->
- <xsl:template match="book/lot | part/lot">
- <!-- Don't generate a page sequence unless there is content -->
- <xsl:variable name="content">
- <xsl:choose>
- <xsl:when test="* and $process.source.toc != 0">
- <div>
- <xsl:apply-templates select="." mode="common.html.attributes"/>
- <xsl:apply-templates/>
- </div>
- </xsl:when>
- <xsl:when test="not(child::*) and $process.empty.source.toc != 0">
- <xsl:call-template name="process.empty.lot"/>
- </xsl:when>
- </xsl:choose>
- </xsl:variable>
- <xsl:if test="string-length(normalize-space($content)) != 0">
- <xsl:copy-of select="$content"/>
- </xsl:if>
- </xsl:template>
-
- <xsl:template match="chapter/lot | appendix/lot | preface/lot | article/lot">
- <xsl:choose>
- <xsl:when test="* and $process.source.toc != 0">
- <div>
- <xsl:apply-templates select="." mode="common.html.attributes"/>
- <xsl:apply-templates/>
- </div>
- <xsl:call-template name="component.toc.separator"/>
- </xsl:when>
- <xsl:when test="not(child::*) and $process.empty.source.toc != 0">
- <xsl:call-template name="process.empty.lot"/>
- </xsl:when>
- </xsl:choose>
- </xsl:template>
- <xsl:template match="section/lot |sect1/lot |sect2/lot |sect3/lot |sect4/lot |sect5/lot">
- <xsl:choose>
- <xsl:when test="* and $process.source.toc != 0">
- <div>
- <xsl:apply-templates select="." mode="common.html.attributes"/>
- <xsl:apply-templates/>
- </div>
- <xsl:call-template name="section.toc.separator"/>
- </xsl:when>
- <xsl:when test="not(child::*) and $process.empty.source.toc != 0">
- <xsl:call-template name="process.empty.lot"/>
- </xsl:when>
- </xsl:choose>
- </xsl:template>
- <xsl:template name="process.empty.lot">
- <!-- An empty lot element does not provide any information to indicate
- what should be included in it. You can customize this
- template to generate a lot based on @role or something -->
- <xsl:message>
- <xsl:text>Warning: don't know what to generate for </xsl:text>
- <xsl:text>lot that has no children.</xsl:text>
- </xsl:message>
- </xsl:template>
- <xsl:template match="lot/title">
- <div>
- <xsl:apply-templates select="." mode="common.html.attributes"/>
- <xsl:apply-templates/>
- </div>
- </xsl:template>
- <xsl:template match="lot/subtitle">
- <div>
- <xsl:apply-templates select="." mode="common.html.attributes"/>
- <xsl:apply-templates/>
- </div>
- </xsl:template>
- <xsl:template match="lot/titleabbrev">
- </xsl:template>
- </xsl:stylesheet>
|