title: Changing namespace for XML file in XSL Translation
body: <p>So I have an input file that uses my company's namespace in the default namespace (<code>xmlns="companyURL"</code>) but I want my output file to use something other than the default namespace (<code>xmlns:cmp="companyURL"</code>). So I construct my file using the <code>cmp</code> namespace, but then I want to copy some of the inner elements:</p>
  
  <pre><code>&lt;xsl:element name="cmp:container"&gt;
    &lt;xsl:for-each select="foo"&gt;
      &lt;xsl:copy-of select="." /&gt;
    &lt;/xsl:for-each&gt;
  &lt;/xsl:element&gt;
  </code></pre>
  
  <p>Unfortunately, what this does is define the default namespace for each of those inner elements, making the file incredibly verbose and ugly. Simplified example:</p>
  
  <p><b>Source</b>:</p>
  
  <pre><code>&lt;foo xmlns="companyURL"&gt;
    &lt;num1&gt;asdf&lt;/num1&gt;
    &lt;num2&gt;ghjkl&lt;/num2&gt;
  &lt;/foo&gt;
  </code></pre>
  
  <p>Turns into:</p>
  
  <pre><code>&lt;cmp:container xmlns:cmp="companyURL"&gt;
    &lt;num1 xmlns="companyURL"&gt;asdf&lt;/num1&gt;
    &lt;num2 xmlns="companyURL"&gt;ghjkl&lt;/num2&gt;
  &lt;/cmp:container&gt;
  </code></pre>
  
  <p>Of course, <code>companyURL</code> is big and long and ugly, and it's the same in both places, so I would prefer the above result to just be the following:</p>
  
  <pre><code>&lt;cmp:container xmlns:cmp="companyURL"&gt;
    &lt;cmp:num1&gt;asdf&lt;/cmp:num1&gt;
    &lt;cmp:num2&gt;ghjkl&lt;/cmp:num2&gt;
  &lt;/cmp:container&gt;
  </code></pre>
  
  <p>Is there an easy way to do this, or should I convert everything under the <code>cmp</code> namespace to the default namespace? I would prefer to use the explicit namespace naming if possible, it aids in understanding the XSLT in my experience.</p>