how to remove namespace and retain only some of the elements from the original XML document using XSL? <p>Below is my XML. I wanted to parse this using XSL. What I want to achieve is to remove the namespace (xmlns) then just retain some of the elements and their attributes. I found a way to remove the namespace but when I put it together with the code to retain some of the elements, it doesn't work. I already tried the identity but still didn't work. </p> <p>I hope someone out there could share something. Thank you very much in advance.</p> <p>XML Input:</p> <pre><code>&lt;Transaction xmlns="http://www.test.com/rdc.xsd"&gt; &lt;Transaction&gt; &lt;StoreName id="aa"&gt;STORE A&lt;/StoreName&gt; &lt;TransNo&gt;TXN0001&lt;/TransNo&gt; &lt;RegisterNo&gt;REG001&lt;/RegisterNo&gt; &lt;Items&gt; &lt;Item id="1"&gt; &lt;ItemID&gt;A001&lt;/ItemID&gt; &lt;ItemDesc&gt;Keychain&lt;/ItemDesc&gt; &lt;/Item&gt; &lt;Item id="2"&gt; &lt;ItemID&gt;A002&lt;/ItemID&gt; &lt;ItemDesc&gt;Wallet&lt;/ItemDesc&gt; &lt;/Item&gt; &lt;/Items&gt; &lt;IDONTLIKETHIS_1&gt; &lt;STOREXXX&gt;XXX-&lt;/STOREXXX&gt; &lt;TRANSXXX&gt;YYY&lt;/TRANSXXX&gt; &lt;/IDONTLIKETHIS_1&gt; &lt;IDONTLIKETHIS_2&gt; &lt;STOREXXX&gt;XXX-&lt;/STOREXXX&gt; &lt;TRANSXXX&gt;YYY&lt;/TRANSXXX&gt; &lt;/IDONTLIKETHIS_2&gt; &lt;/Transaction&gt; &lt;Transaction&gt; </code></pre> <p>Expected XML Output:</p> <pre><code>&lt;Transaction&gt; &lt;Transaction&gt; &lt;StoreName id="aa"&gt;STORE A&lt;/StoreName&gt; &lt;TransNo&gt;TXN0001&lt;/TransNo&gt; &lt;RegisterNo&gt;REG001&lt;/RegisterNo&gt; &lt;Items&gt; &lt;Item id="1"&gt; &lt;ItemID&gt;A001&lt;/ItemID&gt; &lt;ItemDesc&gt;Keychain&lt;/ItemDesc&gt; &lt;/Item&gt; &lt;Item id="2"&gt; &lt;ItemID&gt;A002&lt;/ItemID&gt; &lt;ItemDesc&gt;Wallet&lt;/ItemDesc&gt; &lt;/Item&gt; &lt;/Items&gt; &lt;/Transaction&gt; &lt;Transaction&gt; </code></pre> <p>Code used to remove the namespace (xmlns):</p> <pre><code>&lt;xsl:template match="*"&gt; &lt;xsl:element name="{local-name()}"&gt; &lt;xsl:apply-templates select="@*|node()"/&gt; &lt;/xsl:element&gt; &lt;/xsl:template&gt; &lt;xsl:template match="@*"&gt; &lt;xsl:attribute name="{local-name()}"&gt; &lt;xsl:value-of select="."/&gt; &lt;/xsl:attribute&gt; &lt;/xsl:template&gt; </code></pre>