This is the mail archive of the
docbook-apps@lists.oasis-open.org
mailing list .
Re: [docbook-apps] Generate TOCs above current section
- From: "Bob Stayton" <bobs at sagehill dot net>
- To: <docbook-apps at lists dot oasis-open dot org>, "Tristan Fiedler" <fiedler at cshl dot edu>
- Date: Tue, 14 Dec 2004 15:34:14 -0800
- Subject: Re: [docbook-apps] Generate TOCs above current section
- References: <7A7678D0-4D47-11D9-93CF-000D933B5D9E@cshl.edu>
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
bobs@sagehill.net
----- Original Message -----
From: "Tristan Fiedler" <fiedler@cshl.edu>
To: <docbook-apps@lists.oasis-open.org>
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
>
>
>