This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: An XSLT puzzle
- To: xsl-list at lists dot mulberrytech dot com
- Subject: Re: [xsl] An XSLT puzzle
- From: Oliver Becker <obecker at informatik dot hu-berlin dot de>
- Date: Mon, 30 Jul 2001 15:26:01 +0200 (MET DST)
- Reply-To: xsl-list at lists dot mulberrytech dot com
Hi Alexander
> Imagine the following exotic situation.
> A stylesheet contains a named template, say
>
> <xsl:template name="qq">...</xsl:template>
>
> with "..." an arbitrary valid XSLT code.
> This template is to be used in two different "regimes".
> The first regime is the usual one: the template
> is called via
>
> <xsl:call-template name="qq"/>
>
> The second regime is exotic: the template's
> content is identically copied into the output
> (as a result tree fragment).
use xsl:copy-of ;-)
> For instance, let the stylesheet be as follows:
>
> <xsl:template name="qq">
> <node attr="{2+2=4}"/>
> </xsl:template>
>
> <xsl:template match="/">
> <results>
> <usual-result>
> <xsl:call-template name="qq"/>
> </usual-result>
> <exotic-result>
> ... your code ...
> </exotic-result>
> </results>
> </xsl:template>
Alright: replace "... your code ..." with
<xsl:copy-of select="document('')/*/xsl:template[@name='qq']/node()" />
But note: this solution won't work with includes or imports.
Cheers,
Oliver
/-------------------------------------------------------------------\
| ob|do Dipl.Inf. Oliver Becker |
| --+-- E-Mail: obecker@informatik.hu-berlin.de |
| op|qo WWW: http://www.informatik.hu-berlin.de/~obecker |
\-------------------------------------------------------------------/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list