Subject: [xsl] Re: copying <xsl:stylesheet> tag to output xsl file From: Dimitre Novatchev <dnovatchev@xxxxxxxxx> Date: Wed, 2 Jan 2002 08:16:39 -0800 (PST) |
> I have this XSL file as below..i want to copy the <xsl:stylesheet> tag to > the output xsl file, as i need the "my" namespace declaration in the > generated output xsl file. In order to have ***just*** the namespace declaration in the output, you don't need to copy the xsl:stylesheet node (or any element, on which the given namespace is defined) from the stylesheet. All you have to do is just copy the namespace node itself. Bellow is a modified identity stylesheet, which copies the "my" namespace declaration to the top element of its output: copyNamespace.xsl: ----------------- <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:my="http://mysite.com/mynamespace" > <xsl:output omit-xml-declaration="yes"/> <xsl:template match="/*"> <xsl:copy> <xsl:copy-of select="document('')/*/namespace::* [name()='my']"/> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> </xsl:stylesheet> When applied with Saxon 6.5 on this sample source xml: copyNamespace.xml: ----------------- <t> <a> <b /> </a> <c> <d /> </c> </t> the result is: <t xmlns:my="http://mysite.com/mynamespace"> <a> <b/> </a> <c> <d/> </c> </t> Hope this helped. Cheers, Dimitre Novatchev. __________________________________________________ Do You Yahoo!? Send your FREE holiday greetings online! http://greetings.yahoo.com XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Lare XML files, Gilles Maurice | Thread | [xsl] Re:, Elliotte Rusty Harol |
For expressions and / operator in X, Jeni Tennison | Date | Re: [xsl] Re: Assignment no, dynami, Gunther Schadow |
Month |