[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|