[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: XHTML table of contents with XSLT
Thanx for your help :)
(1) Martin Honnen replied: > You can use the generate-id function to generate ids for the hn elements and > use them as anchors in your table of contents. > <http://www.w3.org/TR/xslt#function-generate-id> Thanx a lot, that did it. Sorry for this, I forgot that XSLT also has functions, I just spent time going through the XPath spec :( (2) David Carlisle told me to replace the ugly "*[local-name()='xxx']" by "h:xxx" but then I run into namespace problems (this why I put them there in the first place). Of course it's likely that I did something wrong again but I tried several combinations. If you have another 3 minutes to spare, could you look at bad files below. I think I did as you told... Main problem is a wrong namespace declaration: html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://www.w3.org/1999/xhtml"> Good: http://tecfa.unige.ch/guides/xml/examples/xsl-toc/xhtml-sample.xml http://tecfa.unige.ch/guides/xml/examples/xsl-toc/xhtml-toc.xsl Bad: http://tecfa.unige.ch/guides/xml/examples/xsl-toc/xhtml-sample-bad.xml http://tecfa.unige.ch/guides/xml/examples/xsl-toc/xhtml-toc-bad.xsl http://tecfa.unige.ch/guides/xml/examples/xsl-toc/xhtml-sample-bad2.xml http://tecfa.unige.ch/guides/xml/examples/xsl-toc/xhtml-toc-bad2.xsl Note: If I batch process the files and name output as *.html they will show of course, but are not valid.... (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>   ' </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>   ' </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">«up</a>)</h2> </xsl:template> - greetings ! - Daniel
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|