xsl-list
[Top] [All Lists]

Re: html toc

2005-02-23 11:18:12
Tempore 18:38:40, die 02/23/2005 AD, hinc in xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com scripsit <carst(_at_)ocean7(_dot_)com>:

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

--~------------------------------------------------------------------
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>