Showing posts with label xslt. Show all posts
Showing posts with label xslt. Show all posts

Thursday, March 24, 2011

Generic XSLT code to remove namespaces from XML

Generic XSLT Code to Remove ALL Namespaces from XML.
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method="xml" version="1.0" encoding="UTF-8" />
        <xsl:template match="*">
                <xsl:element name="{local-name()}" >
                        <xsl:apply-templates select="@* | node()"/>
                </xsl:element>
        </xsl:template>
</xsl:stylesheet>

Generic XSLT Code to Remove Namespaces EXCEPT namespace="urn:sap-com:document:sap:rfc:functions"
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method="xml" version="1.0" encoding="UTF-8" />
        <xsl:template match="*">
                <xsl:element name="{local-name()}" namespace="urn:sap-com:document:sap:rfc:functions">
                        <xsl:apply-templates select="@* | node()"/>
                </xsl:element>
        </xsl:template>
</xsl:stylesheet>