This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: copying <xsl:stylesheet> tag to output xsl file


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]