Next in thread → Next in month →

Re: [docbook-apps] Generate TOCs above current section

From
Bob Stayton <>
Date
2004-12-14T23:34:20+00:00
ID
007f01c4e235$6c22f1b0$6400a8c0@toshiro
Thread
Re: [docbook-apps] Generate TOCs above current section
What you want can't be done with parameters alone, but it can be done with a
customization. Try this cute trick:

<xsl:template name="section.toc">
  <xsl:param name="toc-context" select="."/>
  <xsl:param name="toc.title.p" select="true()"/>

  <xsl:for-each
select="ancestor::article|ancestor::chapter|ancestor::appendix">
    <xsl:call-template name="component.toc">
      <xsl:with-param name="toc-context" select="."/>
      <xsl:with-param name="toc.title.p" select="$toc.title.p"/>
    </xsl:call-template>
  </xsl:for-each>

</xsl:template>

This customizes the "section.toc" template, which generates the TOC for a
section. It is changed to call the "component.toc" template instead. For it
to work, you have to change the context node, which is what the xsl:for-each
does.  Since there is only one ancestor article or chapter permitted, then
changing the context is all it does.

If you select ancestor::book and call 'division.toc' instead, you can get
the whole book's toc in each section!

Bob Stayton
Sagehill Enterprises
DocBook Consulting



----- Original Message ----- 
From: "Tristan Fiedler" <>
To: <>
Sent: Monday, December 13, 2004 12:42 PM
Subject: [docbook-apps] Generate TOCs above current section


> Hi All,
>
> After carefully studying Bob Stayton's excellent tutorial :
> http://www.sagehill.net/docbookxsl/TOCcontrol.html
>
> I am still unclear how I can generate a TOC for each page in a
> 'chunked' html output, where each TOC shows the complete TOC for the
> article, not just sub-sections of the current section.  I am using only
> <sect1> elements, since all sections are equivalent.
>
> For example,
>
> <article>
> <sect1>   fun stuff in section 1 </sect1>
> <sect1>   fun stuff in section 2 </sect1>
> <sect1>   fun stuff in section 3 </sect1>
> <sect1>   fun stuff in section 4 </sect1>
> </article>
>
> Now, when the user is viewing the page which shows :
> 'fun stuff in section 3'
>
> I would like a TOC to be displayed which shows the entire 'article',
> ie, all the sections.
>
>
> Cheers,
>
> Tristan
> ------------------------------
> Tristan J. Fiedler
> Postdoctoral Fellow - Stein Lab
> Cold Spring Harbor Laboratory
>
>
>
Next in thread → Next in month →