This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: nested templates?
- To: <xsl-list at lists dot mulberrytech dot com>
- Subject: RE: [xsl] nested templates?
- From: "Tim Watts" <timw at 3d3 dot com>
- Date: Thu, 17 May 2001 10:04:12 +1000
- Reply-To: xsl-list at lists dot mulberrytech dot com
The way the template example you gave can be structured something like ...
<xsl:stylesheet>
<!-- template -->
<xsl:template match="/">
<!-- top level -->
<div align="center">
<!-- folder -->
<xsl:apply-templates select="folder">
</xsl:apply-templates>
<!-- /folder -->
</div>
<!-- /top level -->
</xsl:template>
<xsl:template match="folder">
<a href="/"><xsl:value-of select="@name"/></a><br />
<!-- item -->
<xsl:apply-templates select="*">
</xsl:apply-templates>
<!-- /item -->
<p/>
</xsl:template>
<xsl:template match="*">
<a href="{href}">
<xsl:value-of select="href" />
</a><br />
</xsl:template>
</xsl:stylesheet>
On your related question, try looking into <xsl:include> and <xsl:import>
Best wishes as you learn xsl templates... :-)
Tim Watts
-----Original Message-----
From: Alex Black
Sent: Thursday, 17 May 2001 4:07 AM
Subject: [xsl] nested templates?
<xsl:stylesheet>
<!-- template -->
<xsl:template match="/*">
<!-- top level -->
<div align="center">
<!-- folder -->
<xsl:template match="folder">
<a href="/"><xsl:value-of select="@name"/></a><br />
<!-- item -->
<xsl:template match="folder/*">
<a class="subnav">
<xsl:attribute name="href">
<xsl:value-of select="href" />
</xsl:attribute>
<xsl:value-of select="href" />
</a><br />
</xsl:template>
<xsl:apply-templates/>
<!-- /item -->
<p/>
</xsl:template>
<xsl:apply-templates/>
<!-- /folder -->
</div>
<!-- /top level -->
</xsl:template>
<!-- template -->
</xsl:stylesheet>
---
A related question:
-Can I import another xsl at runtime to handle a template operation for
me? Say I have an element <field> that I want to transform into an html
<input type="foo"> tag, and I'd like to select that element (<field>) and
pass it off to another template. I suppose I could write a php-helper to do
this, but that seems kludgey to me.
_alex
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list