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-14-2007 15:27
    
    
    Try setting toc.section.depth parameter to 3 or greater, the default is 2 which gives Chapter, sect1 and sect2 in the TOC
    toc.max.depth has a default of 7, so toc.section.depth overrides
    See p.122-3 of Bob Stayton, DocBook XSL the Complete Guide

    You may have trouble with TOC for an appendix, for e.g. to get a list of figures in a TOC (with XEP) for an appendix I use:
    <!-- ==================================================================== -->
    <!-- generate tables of contents for book, preface, chapters and appendices  -->
    <xsl:param name="generate.toc" >
     appendix toc,title,figure
     book toc,title
     chapter       title
     preface       title
    </xsl:param>
    <!--
    Note.  This code works OK in a <book>, but gives fatal errors in the fo file if tried for an appendix in an article
     -->

    <!-- ==================================================================== -->
    <!-- list.of.titles code added to generate a list of figures at start of an appendix
     -->


    <xsl:template match="appendix/docinfo|appendixinfo"></xsl:template>

    <xsl:template match="appendix/title"></xsl:template>

    <xsl:template match="appendix/titleabbrev"></xsl:template>

    <xsl:template match="appendix/subtitle"></xsl:template>

    <xsl:template match="appendix">
     
    <xsl:variable name="id">
       
    <xsl:call-template name="object.id"/>
     
    </xsl:variable>

     
    <xsl:variable name="master-reference">
       
    <xsl:call-template name="select.pagemaster"/>
     
    </xsl:variable>

     
    <fo:page-sequence hyphenate="{$hyphenate}"
                        master-reference
    ="{$master-reference}">
       
    <xsl:attribute name="language">
         
    <xsl:call-template name="l10n.language"/>
       
    </xsl:attribute>
       
    <xsl:attribute name="format">
         
    <xsl:call-template name="page.number.format">
           
    <xsl:with-param name="master-reference" select="$master-reference"/>
         
    </xsl:call-template>
       
    </xsl:attribute>
       
    <xsl:attribute name="initial-page-number">
         
    <xsl:call-template name="initial.page.number">
           
    <xsl:with-param name="master-reference" select="$master-reference"/>
         
    </xsl:call-template>
       
    </xsl:attribute>

       
    <xsl:attribute name="force-page-count">
         
    <xsl:call-template name="force.page.count">
           
    <xsl:with-param name="master-reference" select="$master-reference"/>
         
    </xsl:call-template>
       
    </xsl:attribute>

       
    <xsl:attribute name="hyphenation-character">
         
    <xsl:call-template name="gentext">
           
    <xsl:with-param name="key" select="'hyphenation-character'"/>
         
    </xsl:call-template>
       
    </xsl:attribute>
       
    <xsl:attribute name="hyphenation-push-character-count">
         
    <xsl:call-template name="gentext">
           
    <xsl:with-param name="key" select="'hyphenation-push-character-count'"/>
         
    </xsl:call-template>
       
    </xsl:attribute>
       
    <xsl:attribute name="hyphenation-remain-character-count">
         
    <xsl:call-template name="gentext">
           
    <xsl:with-param name="key" select="'hyphenation-remain-character-count'"/>
         
    </xsl:call-template>
       
    </xsl:attribute>

       
    <xsl:apply-templates select="." mode="running.head.mode">
         
    <xsl:with-param name="master-reference" select="$master-reference"/>
       
    </xsl:apply-templates>

       
    <xsl:apply-templates select="." mode="running.foot.mode">
         
    <xsl:with-param name="master-reference" select="$master-reference"/>
       
    </xsl:apply-templates>

       
    <fo:flow flow-name="xsl-region-body">
         
    <xsl:call-template name="set.flow.properties">
           
    <xsl:with-param name="element" select="local-name(.)"/>
           
    <xsl:with-param name="master-reference" select="$master-reference"/>
         
    </xsl:call-template>

    <!-- list.of.titles code added to generate a list of figures at start of an appendix  -->
         
    <fo:block id="{$id}">
           
    <xsl:call-template name="appendix.titlepage"/>
           
    <xsl:call-template name="list.of.titles">
             
    <xsl:with-param name="titles" select="'figure'"/>
             
    <xsl:with-param name="nodes" select=".//figure"/>
            </xsl:call-template>
         
    </fo:block>
    <!--  -->

         
    <xsl:variable name="toc.params">
           
    <xsl:call-template name="find.path.params">
             
    <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
           
    </xsl:call-template>
         
    </xsl:variable>

         
    <xsl:if test="contains($toc.params, 'toc')">
           
    <xsl:call-template name="component.toc">
             
    <xsl:with-param name="toc.title.p"
                              select
    ="contains($toc.params, 'title')"/>
           
    </xsl:call-template>
           
    <xsl:call-template name="component.toc.separator"/>
         
    </xsl:if>
         
    <xsl:apply-templates/>
       
    </fo:flow>
     
    </fo:page-sequence>
    </xsl:template>

    I'm currently stuck in trying to get DocBook to produce ToCs in FO/PDF output for nested sections more than 0 levels deep. I see a ToC for article/section, but not one for article/section/section.

    In my customization layer, I have:

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

      <xsl:param name="generate.section.toc.level" select="5" />

    Using 1.73.0 (NS) and a DB5-valid doc.

    Any ideas?

    Thanks,

    Brett


    ---------------------------------------------------------------------
    To unsubscribe, e-mail: docbook-apps-unsubscribe@lists.oasis-open.org
    For additional commands, e-mail: docbook-apps-help@lists.oasis-open.org


    Ron Catterall, Phd, DSc       email: ron@catterall.net
    Prolongacion de Hidalgo 140http://catterall.net/
    San Felipe del Aguatel: +52 951 520 1821
    Oaxaca      68020Mexicofax: +1 530 348 8309