title: Remove xmlns soap attribute from xml using xslt
body: <p>I am trying to Copying soap message to custom xml(removing soap namespace from Envelope, Header,Body and removing namespace prefix from ResponseHeader element, everything fine expect one xmlns:soap namespace coming in ResponseHeader and  ResponseData elements. </p>
  
  <p>Input:</p>
  
  <pre><code>&lt;soap:Envelope
  xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
  xmlns:ns="http:test/201/2"
  xmlns:m0="http:test/201/3"
  xmlns:ns0="http:test/201/4"
  xmlns:ns2="http:test/201/5"
  xmlns:ns1="http:test/201/6"
  xmlns:ns3="http:test/201/7"
  xmlns:ns6="http:test/201/8"
  xmlns:ns4="http:test/201/9"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  &gt;
  &lt;soap:Header&gt;
  &lt;ns0:ResponseHeader&gt;
  &lt;ns:Env&gt;Dev&lt;/ns:Env&gt;
  &lt;ns:Version&gt;1&lt;/ns:Version&gt;
  &lt;ns:Server&gt;
  &lt;ns:Name&gt;NAME&lt;/ns:Name&gt;
  &lt;/ns0:ResponseHeader&gt;
  &lt;/soap:Header&gt;
  &lt;soap:Body&gt;
  &lt;ns2:ResponseData&gt;
  &lt;ns2:Employee /&gt;
  &lt;ns2:MessageList&gt;
  &lt;ns2:Message&gt;
  &lt;ns4:Type&gt;new&lt;/ns4:Type&gt;
  &lt;ns4:Code&gt;1&lt;/ns4:Code&gt;
  &lt;ns4:Source&gt;contract&lt;/ns4:Source&gt;
  &lt;ns4:Description&gt;new hire&lt;/ns4:Description&gt;
  &lt;/ns2:Message&gt;
  &lt;/ns2:Employee&gt;
  &lt;/ns2:ResponseData&gt;
  &lt;/soap:Body&gt;
  &lt;/soap:Envelope&gt;
  </code></pre>
  
  <p>Expected Output:</p>
  
  <pre><code>&lt;Envelope   
  xmlns:ns="http:test/201/2"
  xmlns:m0="http:test/201/3"
  xmlns:ns0="http:test/201/4"
  xmlns:ns2="http:test/201/5"
  xmlns:ns1="http:test/201/6"
  xmlns:ns3="http:test/201/7"
  xmlns:ns6="http:test/201/8"
  xmlns:ns4="http:test/201/9"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  &gt;
  &lt;Header&gt;
  &lt;ResponseHeader&gt;
  &lt;ns:Env&gt;Dev&lt;/ns:Env&gt;
  &lt;ns:Version&gt;1&lt;/ns:Version&gt;
  &lt;ns:Server&gt;
  &lt;ns:Name&gt;NAME&lt;/ns:Name&gt;
  &lt;/ResponseHeader&gt;
  &lt;/Header&gt;
  &lt;Body&gt;
  &lt;ns2:ResponseData&gt;
  &lt;ns2:Employee /&gt;
  &lt;ns2:MessageList&gt;
  &lt;ns2:Message&gt;
  &lt;ns4:Type&gt;new&lt;/ns4:Type&gt;
  &lt;ns4:Code&gt;1&lt;/ns4:Code&gt;
  &lt;ns4:Source&gt;contract&lt;/ns4:Source&gt;
  &lt;ns4:Description&gt;new hire&lt;/ns4:Description&gt;
  &lt;/ns2:Message&gt;
  &lt;/ns2:Employee&gt;
  &lt;/ns2:ResponseData&gt;
  &lt;/Body&gt;
  &lt;/Envelope&gt;
  </code></pre>
  
  <p>My Xslt:</p>
  
  <pre><code>&lt;xsl:stylesheet version="2.0" extension-element-prefixes="dp" exclude-result-prefixes="soap ns3 snss  ns0 ns1 ns4 #default" 
  xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
  xmlns:ns="http:test/201/2"
  xmlns:m0="http:test/201/3"
  xmlns:ns0="http:test/201/4"
  xmlns:ns2="http:test/201/5"
  xmlns:ns1="http:test/201/6"
  xmlns:ns3="http:test/201/7"
  xmlns:ns6="http:test/201/8"
  xmlns:ns4="http:test/201/9"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  &gt;
    &lt;xsl:output method="xml" version="1.0" indent="no"/&gt;
    &lt;xsl:template match="node()|@*" exclude-result-prefixes="#all"&gt;
  
       &lt;xsl:copy&gt;
  &lt;xsl:apply-templates select="node()|@*"/&gt;
       &lt;/xsl:copy&gt;
   &lt;/xsl:template&gt;
  
   &lt;xsl:template match="soap:*" exclude-result-prefixes="#all"&gt;
    &lt;xsl:element name="{local-name()}"&gt;
      &lt;xsl:copy-of select="namespace::*[not(. = namespace-uri(..))]"/&gt;
      &lt;xsl:apply-templates select="node()|@*"/&gt;
    &lt;/xsl:element&gt;
   &lt;/xsl:template&gt;
    &lt;xsl:template match="tns:ResponseData" exclude-result-prefixes="#all"&gt;
   &lt;ResponseHeader&gt;
      &lt;xsl:copy-of select="namespace::*[not(. = namespace-uri(..))]"/&gt;
      &lt;xsl:apply-templates select="node()|@*"/&gt;
    &lt;/ResponseHeader&gt;
   &lt;/xsl:template&gt; 
  
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>Getting output:</p>
  
  <pre><code>&lt;Envelope
  
  xmlns:ns="http:test/201/2"
  xmlns:m0="http:test/201/3"
  xmlns:ns0="http:test/201/4"
  xmlns:ns2="http:test/201/5"
  xmlns:ns1="http:test/201/6"
  xmlns:ns3="http:test/201/7"
  xmlns:ns6="http:test/201/8"
  xmlns:ns4="http:test/201/9"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  &gt;
  &lt;Header&gt;
  &lt;ResponseHeader xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"&gt;
  &lt;ns:Env&gt;Dev&lt;/ns:Env&gt;
  &lt;ns:Version&gt;1&lt;/ns:Version&gt;
  &lt;ns:Server&gt;
  &lt;ns:Name&gt;NAME&lt;/ns:Name&gt;
  &lt;/ResponseHeader&gt;
  &lt;/Header&gt;
  &lt;Body&gt;
  &lt;ns2:ResponseData xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"&gt;
  &lt;ns2:Employee /&gt;
  &lt;ns2:MessageList&gt;
  &lt;ns2:Message&gt;
  &lt;ns4:Type&gt;new&lt;/ns4:Type&gt;
  &lt;ns4:Code&gt;1&lt;/ns4:Code&gt;
  &lt;ns4:Source&gt;contract&lt;/ns4:Source&gt;
  &lt;ns4:Description&gt;new hire&lt;/ns4:Description&gt;
  &lt;/ns2:Message&gt;
  &lt;/ns2:Employee&gt;
  &lt;/ns2:ResponseData&gt;
  &lt;/Body&gt;
  &lt;/Envelope&gt;
  </code></pre>
  
  <p>Please help how to get rid if xmlns:soap attribute?</p>