XML : Removing namespace using CSLT

I am generating XML file from MuleSoft and it producing empty tags like this. How to remove this using XSLT

  <SerialNumber xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>    

I tried with XSLT code like,

    <?xml version="1.0" encoding="utf-8"?>  <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">    <xsl:output method="xml" indent="yes"/>    <xsl:template match="*">      <xsl:element name="{local-name(.)}">        <xsl:apply-templates select="@* | node()"/>      </xsl:element>    </xsl:template>    <xsl:template match="@*">      <xsl:attribute name="{local-name(.)}">        <xsl:value-of select="."/>      </xsl:attribute>    </xsl:template>    <xsl:template match="@*[local-name(.)='noNamespaceSchemaLocation']"/>  </xsl:stylesheet>    

Its producing output like, <SerialNumber nil="true"/> I want to remove entire namespace, and output should look like <SerialNumber/>

How to achieve this using XSLT?

Thanks in advance

No comments:

Post a Comment