This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: Recursive Template Application
- To: <xsl-list at mulberrytech dot com>
- Subject: RE: Recursive Template Application
- From: "Ronald Walraven" <RWalraven at nl dot alpnet dot com>
- Date: Mon, 19 Jun 2000 08:32:37 +0200
- Reply-To: xsl-list at mulberrytech dot com
XSLT is about recursion. You have to apply templates within templates. By
adding <xsl:apply-templates/> to your first fragment starts processing its
<section> childs. So the first template becomes:
<!-- Template T1: transform <toc> to <section> -->
<xsl:template match="toc">
<section numbered="false" title="Contents"/>
<xsl:apply-templates/>
...
</xsl:template>
Note: <section> is not a valid HTML element. I guess you more looking for
something like the following:
<!-- Template T1: transform <toc> to <section> -->
<xsl:template match="toc">
<div numbered="false" title="Contents">
<xsl:apply-templates/>
...
</div>
</xsl:template>
Regards, Ronald
-----Original Message-----
From: owner-xsl-list@mulberrytech.com
[mailto:owner-xsl-list@mulberrytech.com]On Behalf Of Philip Koester
Sent: maandag 19 juni 2000 0:15
To: XSL-List@mulberrytech.com
Subject: Recursive Template Application
Hello, my Name is Philip Koester and I am new to this list (and to XSL). To
dive into the matter, I am trying to transform a structured document into
HTML. I ran into troubles with templates that I want to be applied
recursively. Some snippets:
<!-- Template T1: transform <toc> to <section> -->
<xsl:template match="toc">
<section numbered="false" title="Contents"/>
...
</xsl:template>
<!-- Template T2: transform <section> to <h2> -->
<xsl:template match="section">
<h2><xsl:value-of select="@title"/></h2>
</xsl:template>
This stylesheet works only half-way in that it correctly transforms "<toc/>"
to "<section .../>" but leaves it at that. The output of T1 is not matched
by T2. But how can I enforce this, so that "<toc/>" is finally transformed
to "<h2>..."? Should I run the XSL processor twice? Or is there a more
efficient way to accomplish this?
Regards,
Philip
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list