Re: [xsl] XHTML table of contents with XSLT

Subject: Re: [xsl] XHTML table of contents with XSLT
From: "Daniel K. Schneider" <Daniel.Schneider@xxxxxxxxxxxxxx>
Date: Sat, 24 Feb 2007 19:29:34 +0100
Now I am talking to myself :)

The problem below went away in Firefox when I adopted the David Carlisle
and Martin Honnen solution.

Conclusion: For those who want a TOC generating or TOC-generaing, h1 and h2 numbering stylesheet for XHTML:

Simple TOC:
http://tecfa.unige.ch/guides/xml/examples/xsl-toc/xhtml-toc-ns.xsl

Numbered TOC and headers:
http://tecfa.unige.ch/guides/xml/examples/xsl-toc/xhtml-toc-ns-numbered.xsl

Directory of files (also the bad stuff I made)
http://tecfa.unige.ch/guides/xml/examples/xsl-toc/

Of course, they produce ugly looking output, but that would be easy to fix.
Thanx very much your help, I learned something about namespaces - Daniel

Daniel K. Schneider wrote:

(3) I then tried to number chapters. Sort of works, but then Firefox (both 1.5 on Linux and 2.0 on Win take like MINUTES (!) when files get bigger and I have
good hardware).
For once, no problem with IE 6 :) ... nor Saxon of course.


Works only with small files:
http://tecfa.unige.ch/guides/xml/examples/xsl-toc/xhtml-sample-numered.xml
http://tecfa.unige.ch/guides/xml/examples/xsl-toc/xhtml-toc-numbered.xsl

Is something like this bad ? (thanx for any help !!)
(the full code is in the above small xhtml-toc-numbered.xsl sample and works with small files)


<xsl:template match="*[local-name()='h2']" mode="toc">
  <span style="font-size:small;">
    <xsl:text> &#160;&#160;' </xsl:text>
    <xsl:number level="any" from="*[local-name()='body']"
                count="*[local-name()='h1']"/>
    <xsl:text>.</xsl:text>
    <xsl:number level="any" from="*[local-name()='h1']"
                count="*[local-name()='h2']"/>
    <xsl:text> </xsl:text>
    <a href="#h2_{generate-id(.)}"><xsl:value-of select="."/></a>
  </span>
</xsl:template>

<xsl:template match="*[local-name()='h2']">
<h2><a name="h2_{generate-id(.)}">
<xsl:text> &#160;&#160;' </xsl:text>
<xsl:number level="any" from="*[local-name()='body']" count="*[local-name()='h1']"/>
<xsl:text>.</xsl:text>
<xsl:number level="any" from="*[local-name()='h1']" count="*[local-name()='h2']"/>
<xsl:text> </xsl:text>
<xsl:value-of select="."/></a> (<a href="#toc">&#171;up</a>)</h2>
</xsl:template>



- greetings ! - Daniel




-- Dr Daniel K.Schneider, TECFA (Educational Technologies and Learning)

TECFA    (TEchnologies de Formation et Apprentissage)
FPSE     (Faculti de Psychologie et des Sciences de l'Education)
Universiti de Genhve
54 Route des Acacias, CH-1227 Carouge

email: Daniel.Schneider@xxxxxxxxxxxxxx
www:   http://tecfa.unige.ch/tecfa-people/schneider.html

Tel: 41 22 379 9377 - Fax: 41 22 379 9379

Current Thread