Subject: Re: [xsl] Controlling namespace in output From: Martin Honnen <Martin.Honnen@xxxxxx> Date: Fri, 17 Dec 2010 13:18:20 +0100 |
I rewrote my stylesheet so it transforms instead of copies. Is this something like what you meant?
Peter
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" indent="yes"/> <xsl:template match="root"> <xsl:element name="section" namespace="http://docbook.org/ns/docbook"> <xsl:attribute name="version">5.0</xsl:attribute> <xsl:attribute name="xml:id">myIdentifier</xsl:attribute> <xsl:apply-templates /> </xsl:element> </xsl:template> <xsl:template match="*"> <xsl:variable name="elementName"> <xsl:value-of select="name()" /> </xsl:variable> <xsl:element name="{$elementName}" namespace="http://docbook.org/ns/docbook"> <xsl:for-each select="@*"> <xsl:copy-of select="." /> </xsl:for-each> <xsl:apply-templates /> </xsl:element> </xsl:template> </xsl:stylesheet>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://docbook.org/ns/docbook"> <xsl:output method="xml" indent="yes"/>
<xsl:template match="*"> <xsl:element name="{local-name()}"> <xsl:copy-of select="@*" /> <xsl:apply-templates /> </xsl:element> </xsl:template>
<xsl:template match="root"> <section version="5.0" xml:id="myIdentifier"> <xsl:apply-templates /> </section> </xsl:template>
Martin Honnen http://msmvps.com/blogs/martin_honnen/
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Controlling namespace in , Peter Desjardins | Thread | [xsl] Christmas reading, David Carlisle |
Re: [xsl] multiple passes for one s, Martin Honnen | Date | [xsl] XSLT 3.0, Andrew Welch |
Month |