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

Re: html toc

Subject: Re: html toc
From: "Joris Gillis" <roac@xxxxxxxxxx>
Date: Wed, 23 Feb 2005 19:18:12 +0100
id html toc
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

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.