This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: copying <xsl:stylesheet> tag to output xsl file
- From: Jeni Tennison <jeni at jenitennison dot com>
- To: "tony" <dhirajtorane at yahoo dot com>
- Cc: xsl-list at lists dot mulberrytech dot com
- Date: Wed, 2 Jan 2002 14:47:13 +0000
- Subject: Re: [xsl] copying <xsl:stylesheet> tag to output xsl file
- Organization: Jeni Tennison Consulting Ltd
- References: <001301c19397$2de7df40$947d7d7d@dhiraj>
- Reply-to: xsl-list at lists dot mulberrytech dot com
Hi Tony,
> Can some one tell me a way by which i can copy the <xsl:stylesheet>
> element to the output XSL file, & apply the templates on to the XML
> file so that the output of comes between
> <xsl:stylesheet version="1.0" xmlns:my="http://mysite.com/mynamespace">
> <!-- output from the XML file after applying the templates -->
> </xsl:stylesheet>
> tags.
The xsl:apply-templates applies templates to the children of the
xsl:stylesheet element because that's the current node at the point
where the xsl:apply-templates is used.
To apply templates to some other nodes, you need to select those nodes
explicitly. I'd store the document element of the XML file in a
variable, and then apply templates to that element, as follows:
<xsl:template match="/">
<xsl:variable name="XMLcontent" select="*" />
<xsl:for-each select="document('')/xsl:stylesheet">
<xsl:copy>
<xsl:apply-templates select="$XMLcontent" />
</xsl:copy>
</xsl:for-each>
</xsl:template>
I hope that helps,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list