docbook-apps

Re: [docbook-apps] controlling ToC depth for an article with nested sections (DB5)

  • 1.  Re: [docbook-apps] controlling ToC depth for an article with nested sections (DB5)

    Posted 08-15-2007 16:12
    Hi Ron,
    This customization works the way you want it. If you look in
    fo/autotoc.xsl, you will see that the children of an element for which you
    are generating a toc are processed in mode="toc", and with a param named
    "toc-context", which is the element for which you are generating the toc.
    This customization handles only nested sections, and checks the
    $toc-context to see if it should proceed. If the context is article and
    the depth is greater than 1, then it does not apply-imports. You can
    adjust the values as needed.

    <xsl:param name="generate.section.toc.level">4</xsl:param>
    <xsl:param name="toc.section.depth">4</xsl:param>
    <xsl:param name="generate.toc">
    article toc,title
    section toc
    </xsl:param>


    <xsl:template match="section[ancestor::section]" mode="toc">
    <xsl:param name="toc-context" select="NOTANODE"/>

    <xsl:variable name="section.depth"
    select="count(ancestor-or-self::section)"/>
    <xsl:choose>
    <xsl:when test="$toc-context/self::article and
    $section.depth > 1">

    </xsl:when>
    <xsl:otherwise>
    <xsl:apply-imports/>
    </xsl:otherwise>
    </xsl:choose>
    </xsl:template>


    Bob Stayton
    Sagehill Enterprises
    DocBook Consulting
    bobs@sagehill.net