title: XSLT to change namespace in element
body: <p>I'm trying to change the namespace of an element attribute using the below xsl code:</p>
  
  <pre><code>&lt;xsl:stylesheet version='2.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform' xmlns:ns2="http://www.ean-ucc.org/schemas/1.3.1/eanucc"&gt; 
      &lt;xsl:output encoding='UTF-8' indent='yes' method='xml'/&gt;
  
      &lt;!-- copy everything into the output --&gt;
      &lt;xsl:template match='@*|node()'&gt;
          &lt;xsl:copy&gt;
              &lt;xsl:apply-templates select='@*|node()'/&gt;
          &lt;/xsl:copy&gt;
      &lt;/xsl:template&gt;
  
      &lt;xsl:template match="IRenvelope"&gt;
          &lt;IRL xmlns:xsd="http://www.xx.com"&gt;
              &lt;xsl:copy-of select="node()|@*"/&gt;
          &lt;/IRL&gt;
      &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>The xml message i use for testing is:</p>
  
  <pre><code>&lt;GMessage xmlns="http://www.giffgaff.uk/CM/envelope"&gt;
  &lt;EnvelopeVersion&gt;2.0&lt;/EnvelopeVersion&gt;
    &lt;body&gt;
      &lt;IRenvelope xmlns="http://www.mnv.com/elc/sap"&gt;
              &lt;Keys&gt;
                  &lt;Key Type="TaxOfficeNumber"&gt;635&lt;/Key&gt;
              &lt;/Keys&gt;
          &lt;/IRenvelope&gt;
     &lt;/body&gt;
   &lt;/GMessage&gt;
  </code></pre>
  
  <p>I couldnt make it work and the namespace is not changing but provinding the same result. any help please?</p>
  
  <p>The output xml to be as follows:</p>
  
  <pre><code>     &lt;GMessage xmlns="http://www.giffgaff.uk/CM/envelope"&gt;
           &lt;EnvelopeVersion&gt;2.0&lt;/EnvelopeVersion&gt;
             &lt;body&gt;
               &lt;IRenvelope xmlns="http://www.xx.com"&gt;
                 &lt;Keys&gt;
                    &lt;Key Type="TaxOfficeNumber"&gt;635&lt;/Key&gt;
                  &lt;/Keys&gt;
                 &lt;/IRenvelope&gt;
              &lt;/body&gt;
         &lt;/GMessage&gt;
  </code></pre>