[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]
Subject: Re: [docbook-apps] Re: [docbook] TOC with parents
Hi Ari,You want to look at autotoc.xsl. The toc.xsl module has templates for a TOC that is created by hand using <tocentry> elements, something that almost no one does. Use autotoc.xsl for an automatically-generated TOC.
oOur first step is to turn on a table of contents for each chunk output. That is controlled by the stylesheet param named 'generate.toc', and few params that control which levels of section get a toc, all described here;
http://www.sagehill.net/docbookxsl/TOCcontrol.html That will trigger each element mentioned in 'generate.toc' to call its special template from autotoc.xsl to generate a TOC, which would be: 'division.toc' for set and book 'component.toc' for chapter, appendix, preface 'section.toc' for sectionsBy default, these will generate a "context-appropriate" TOC for each element, which means it includes only the children of the current element. So you need to redefine 'component.toc' and 'section.toc' to instead call 'division.toc'.
<xsl:template name="section.toc"> <xsl:param name="toc-context" select="."/> <xsl:param name="toc.title.p" select="true()"/> <xsl:for-each select="ancestor::d:book"> <xsl:call-template name="division.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> The xsl:for-each is necessary to change the context from the currentelement to the book element. The "d:book" is needed to match the namespace in DocBook 5, so use just "book" if you are using DocBook 4.
Do the same for redefining 'component.toc'. Templates with mode="toc" are used in the construction of a TOC to generate a TOC entry for the given element. You probably won't need to customize those for your purpose. Let me know if this doesn't work for you. Bob Stayton Sagehill Enterprises bobs@sagehill.net On 11/18/2015 2:57 PM, Aristedes Maniatis wrote:
Thanks for your help, but the webhelp output was just way too different. So I've struggled to try and modify the TOC output from docbook. But nothing I try seems to be able to customise it. Even when I try: <xsl:import href="@rootDir@/build/xslt/docbook/html/chunk.xsl"/> <xsl:template name="section.toc" mode="toc"> <xsl:text>******************</xsl:text> </xsl:template> <xsl:template match="section/toc" mode="toc"> <xsl:text>******************</xsl:text> </xsl:template> with or without the mode (I don't really understand how the mode is used in XSLT). I'm a bit confused by the presence of both toc.xsl and autotoc.xsl. But nothing I try seems to allow me to modify them. I have no problem modifying other things like <xsl:template name="user.head.content"> I feel like I'm missing something really obvious. Ari On 22/10/2015 12:46pm, Peter Desjardins wrote:[moving to docbook-apps] What you are describing sounds like the webhelp output. Did you consider using that? Webhelp produces HTML pages with the full TOC on each page. I have customized the HTML and CSS significantly to match different web sites and branding. Peter On Wed, Oct 21, 2015 at 9:39 PM, Aristedes Maniatis <ari@ish.com.au> wrote:I have chunked html output from docbook 5, and want to output the entire TOC on every page, including all parents of the chapter currently being rendered. I found one approach here: http://markmail.org/message/xpmrfboyu3tr5ehn But it is 11 years old, and not quite right, so I modified it a little... <!-- show all sections in TOC, including parents of the current section --> <xsl:template match="chapter" mode="toc"> <xsl:param name="toc-context" select="."/> <xsl:for-each select="ancestor::book"> <xsl:apply-templates select="book" mode="toc"> <xsl:with-param name="toc-context" select="."/> </xsl:apply-templates> </xsl:for-each> </xsl:template> but it doesn't work. I'm a bit out of my depth with this level of XSLT hackery. Any help would be welcome... Ari -- --------------------------> Aristedes Maniatis ish http://www.ish.com.au Level 1, 30 Wilson Street Newtown 2042 Australia phone +61 2 9550 5001 fax +61 2 9550 4001 GPG fingerprint CBFB 84B4 738D 4E87 5E5C 5EFA EF6A 7D2E 3E49 102A
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]