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: "Chris Bayes" <Chris at Bayes dot co dot uk>
- Date: Wed, 16 May 2001 19:52:56 +0100
- Reply-To: xsl-list at lists dot mulberrytech dot com
>is it possible to construct an xslt stylesheet that is more similar to a
>"complete" page, i.e. with nested templates:
>
no
>(btw, this is not syntactically complete, but you get the idea :)
>
><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>
>
>
>The above seems to be illegal, though I can't think of a good reason why.
>
i've often wondered that myself
it would get around a lot of problems and avoid a lot of cases where you
need to use modes
>The idea here is for me to be able to continue building template files, etc
>the way I am used to doing it (and, indeed, the way I think it should be
>done).
>
>I'm finding the "template for every element in a list" thing fairly
>annoying, and I want a good way of getting around it.
>
>---
>
>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.
>
yes you can
look at apply-imports etc.
Ciao Chris
XML/XSL Portal
http://www.bayes.co.uk/xml
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list