xsl-list
[Top] [All Lists]

Re: [xsl] XHTML table of contents with XSLT

2007-02-24 11:29:56
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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



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

TECFA    (TEchnologies de Formation et Apprentissage)
FPSE     (Faculté de Psychologie et des Sciences de l'Education)
Université de Genève
54 Route des Acacias, CH-1227 Carouge

email: Daniel(_dot_)Schneider(_at_)tecfa(_dot_)unige(_dot_)ch
www:   http://tecfa.unige.ch/tecfa-people/schneider.html

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


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>