Re: [xsl] html toc

Subject: Re: [xsl] html toc
From: "Joris Gillis" <roac@xxxxxxxxxx>
Date: Wed, 23 Feb 2005 19:18:12 +0100
Tempore 18:38:40, die 02/23/2005 AD, hinc in xsl-list@xxxxxxxxxxxxxxxxxxxxxx scripsit <carst@xxxxxxxxxx>:

my problem is that all the headline elements are part of the
same axis and i don't know how do the transformation without
something like a 'break loop', or 'select all following 'h3' until
the next 'h2' or 'h1'.


Hi,


Here you have a working XSLT 1.0 example (uses key grouping)

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:output indent="yes"/>


<xsl:key
name="header"
match="*[starts-with(local-name(),'h')]"
use="generate-id(preceding-sibling::*[local-name()=concat('h', number(substring-after(local-name(current()),'h')) - 1)][1])"/>


<xsl:template match="*[h1]">
<ul>
	<xsl:apply-templates select="h1"/>
</ul>
</xsl:template>

<xsl:template match="*[starts-with(local-name(),'h')]">
<li><xsl:value-of select="."/></li>
<xsl:if test="key('header',generate-id())">
	<ul>
		<xsl:apply-templates select="key('header',generate-id())"/>
	</ul>
</xsl:if>
</xsl:template>

</xsl:stylesheet>


regards, -- Joris Gillis (http://www.ticalc.org/cgi-bin/acct-view.cgi?userid=38041) Gaudiam omnibus traderat W3C, nec vana fides

Current Thread
  • [xsl] html toc
    • carst - Wed, 23 Feb 2005 12:38:40 -0500
      • Wendell Piez - Wed, 23 Feb 2005 13:06:51 -0500
      • Michael Kay - Wed, 23 Feb 2005 18:13:27 -0000
      • Joris Gillis - Wed, 23 Feb 2005 19:18:12 +0100 <=
        • carst - Wed, 23 Feb 2005 13:40:03 -0500