OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

docbook-apps message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]


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


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 &gt; 1">
      <!-- do nothing -->
    </xsl:when>
    <xsl:otherwise>
      <xsl:apply-imports/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>


Bob Stayton
Sagehill Enterprises
DocBook Consulting
bobs@sagehill.net


----- Original Message ----- 
From: "Brett Leber" <bleber+@cs.cmu.edu>
To: "Ron Catterall" <ron@catterall.net>
Cc: <docbook-apps@lists.oasis-open.org>
Sent: Tuesday, August 14, 2007 11:45 AM
Subject: Re: [docbook-apps] controlling ToC depth for an article with 
nested sections (DB5)


> Thanks, Ron. With toc.section.depth set to 4, I now get the ToCs at the
> desired section levels. Setting this parameter, however, has the
> undesired consequence of increasing the depth of even the top-level
> article ToC. What I want is shallow ToCs, but generated for sections
> nested four levels deep.
>
> My understanding was that:
>
> - toc.section.depth controls depth of recursive sections in individual 
> ToCs
> - generate.section.toc.level controls the depth of sections for which
> ToCs should be generated.
>
> But looking at Table 9.3 in Bob's book now, I see that there is an
> interaction between these two parameters, which is undesirable in my
> case. Quoting from DocBook XSL: The Complete Guide :
>
> "In other cases, there is no TOC because the toc.section.depth parameter
> prevents it from having any entries."
>
> But if I increase toc.section.depth, then I get deeper ToCs at the
> higher levels (article and article/section, for example)!
>
> I have to admit this is rather frustrating. I might have to abandon deep
> ToCs altogether, as I'm trying to create a navigable PDF that documents
> a DTD. Since XML elements are described in their own sections, I'm
> getting very deep ToCs where I don't want them.
>
> Thanks,
>
> Brett
>
>
> On 8/14/2007 10:55 AM, Ron Catterall wrote:
>> 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 140 
>> http://catterall.net/
>> San Felipe del Agua                                        tel: +52 951 
>> 520 1821
>> Oaxaca      68020  Mexico                          fax: +1 530 348 8309
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: docbook-apps-unsubscribe@lists.oasis-open.org
> For additional commands, e-mail: docbook-apps-help@lists.oasis-open.org
>
>
> 




[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]