This is the mail archive of the docbook-apps@lists.oasis-open.org mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [docbook-apps] Different TOC levels for chunked xhtml


You can't do what you want just with parameters.  The two parameters
that are available toc.section.depth and toc.max.depth don't handle
your needs[1].

But this short customization will do it.

<xsl:template match="preface|chapter|appendix|article" mode="toc">
  <xsl:param name="toc-context" select="."/>

  <xsl:choose>
    <xsl:when test="local-name($toc-context) = 'book'">
      <xsl:call-template name="subtoc">
        <xsl:with-param name="toc-context" select="$toc-context"/>
        <xsl:with-param name="nodes" select="foo"/>
      </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
      <xsl:call-template name="subtoc">
        <xsl:with-param name="toc-context" select="$toc-context"/>
        <xsl:with-param name="nodes"
select="section|sect1|glossary|bibliography|index
|bridgehead[$bridgehead.in.toc != 0]"/>
      </xsl:call-template>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

It is a copy of a template in html/autotoc.xsl, modified to add a
choose statement.  It processes the chapter element in mode="toc"
to generate lines in your TOC.  The $toc-context template parameter
contains the element in which the TOC is appearing.  So if
you take the local-name of that element and compare it to
'book', the template can take a different action.  In this
case, you tell it to select foo children of the chapter element,
which will be an empty node set.  Then the depth of the
chapter toc can be controlled by toc.section.depth.

Bob Stayton
Sagehill Enterprises
DocBook Consulting
bobs@sagehill.net

[1] http://www.sagehill.net/docbookxsl/TOCcontrol.html#TOClevels

----- Original Message ----- 
From: "Janeene Webb" <webdesign@dawnmist.net>
To: <docbook-apps@lists.oasis-open.org>
Sent: Monday, February 09, 2004 8:49 PM
Subject: [docbook-apps] Different TOC levels for chunked xhtml


> Hi,
>
> Am working on a document which is a collation of documents around a
particular
> topic. Would like to be able to process the document into xhtml with a
main
> page as the table of contents listing only each chapter, then a table of
> contents within each chapter listing the sections within it.
>
> i.e.
> <book>
>   <title>Collation of insects</title>
>   <chapter>
>     <title>Ants</title>
>     <sect1>
>        <title>What are they</title>
>        <para>Some stuff</para>
>        <sect2>
>           <title>yada, yada</title>
>           <para>More stuff</para>
>        <sect2>
>     </sect1>
>     <sect1>
>        <title>Where are they</title>
>        <para>Some stuff</para>
>        <sect2>
>           <title>yada, yada</title>
>           <para>More stuff</para>
>        <sect2>
>     </sect1>
>   </chapter>
>   <chapter>
>     <title>Bees</title>
>     <sect1>
>        <title>Who cares</title>
>        <para>Some stuff</para>
>    </sect1>
>  </chapter>
> </book>
>
> Then the Book TOC to be:
> Table of Contents
>   Ants
>   Bees
>
> And the Ants Chapter TOC to be:
> Table of Contents
>   What are they
>       yada, yada
>   Where are they
>       yada, yada
>
> Are there any options where I could use different depths for the toc
depending
> on where it is? At the moment, I can set it to depth 2 for the sections,
but
> I get all the sections then displayed in the book level one as well. And
the
> level between the book and the chapter varies - the book level I want only
1
> depth (chapter only), whereas in the chapters I actually need to include
to
> at least sect3 level (for the real document).
>
> Essentially the book is to becomes an automated web site navigation
document
> with separate related topics.
>
> Cheers, Janeene Webb.
>
> To unsubscribe from this list, send a post to
docbook-apps-unsubscribe@lists.oasis-open.org, or visit
http://www.oasis-open.org/mlmanage/.
>
>
>



To unsubscribe from this list, send a post to docbook-apps-unsubscribe@lists.oasis-open.org, or visit http://www.oasis-open.org/mlmanage/.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]