[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: XHTML table of contents with XSLT

Subject: Re: XHTML table of contents with XSLT
From: "Daniel K. Schneider" <Daniel.Schneider@xxxxxxxxxxxxxx>
Date: Sat, 24 Feb 2007 16:35:58 +0100
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> &#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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.