[daisy] RE: Auto TOC for a document?
shivshan
shivshan at hotmail.com
Thu Sep 27 09:59:28 CDT 2007
Hi
Thanks for your replies. This and section editing (in non-included docs) are
two areas where i wish i could contribute. However, i am totally new to
Cocoon and XSLT :(
1. Since we dont use included documents much, we can probably use the XSLT
approach. I assume this change should be made somewhere in layout.xsl,
correct?
2. After a quick check, i found many javascript solutions for creating a TOC
from a doc. I quite like the way Dokuwiki and Dekiwiki do TOC. Will continue
to investigate.
Thanks
Shiva
Bruno Dumon wrote:
>
> On Thu, 2007-09-13 at 20:09 +0200, Vincent Mouton wrote:
>> >
>> >
>> > Hi
>> > Many pages created in our Daisy site are quite big, and have multiple
>> > sections. Sometimes, its a pain to search for the relevant section. Is
>> > there
>> > a way a TOC can be automatically included, based on the h1, h2 and h3
>> > headers?
>>
>> Shiva,
>>
>> You could accomplish this through XSLT (i.e. in the skin).
>>
>> Pretty rough, but you could loop through all tags at the first level
>> inside
>> a part, and check for h1, h2, h3, ... tags
>>
>> <!-- UNTESTED -->
>> <!-- This it the TOC -->
>>
>> <ul>
>> <xsl:for-each select="d:parts/d:part[@name =
>> 'PART_NAME_TO_DEFINE']/html/body/*[name() = 'h1' or name() = 'h2' or
>> name()
>> = 'h2']">
>>
>> <li> #{name()}_{position()} <xsl:apply-templates
>> /> </li>
>>
>> </xsl:for-each>
>> </ul>
>>
>>
>> <!--
>> This is the actual content rendering
>> You repeat this principle for all tags, to render the content, and
>> when encountering a heading, add an id="" attribute to it
>> -->
>>
>> <xsl:for-each select="d:parts/d:part[@name =
>> 'PART_NAME_TO_DEFINE']/html/body/*">
>> <xsl:if test="name() = 'h1' or name() = 'h2' or name() = 'h2'">
>>
>> <!-- Even better would be to define the id attribute to the
>> h1, h2, ... tags itself -->
>> </xsl:if>
>> <xsl:apply-templates />
>> </xsl:for-each>
>
>
>
> A problem with the XSLT approach is that it won't work with included
> documents, each included document will have its own TOC while one global
> TOC would be better.
>
> I would consider implementing this client-side, in javascript. If anyone
> does this, patches are of course welcome.
>
> BTW, in the document editor, there is already such TOC functionality via
> the 'goto' button on the toolbar.
>
>
>
> --
> Bruno Dumon http://outerthought.org/
> Outerthought - Open Source, Java & XML Competence Support Center
> bruno at outerthought.org bruno at apache.org
>
> _______________________________________________
> daisy community mailing list
> Professional Daisy support:
> http://outerthought.org/site/services/daisy/daisysupport.html
> mail to: daisy at lists.cocoondev.org
> list information: http://lists.cocoondev.org/mailman/listinfo/daisy
>
>
--
View this message in context: http://www.nabble.com/Auto-TOC-for-a-document--tf4435727.html#a12923152
Sent from the Daisy - General mailing list archive at Nabble.com.
More information about the daisy
mailing list