title: XSLT: Add namespace to root element
body: <p>I need to change namespaces in the root element as follows:</p>
  
  <h2>input document:</h2>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt;
  &lt;foo xsi:schemaLocation="urn:isbn:1-931666-22-9 http://www.loc.gov/ead/ead.xsd"
  xmlns:ns2="http://www.w3.org/1999/xlink" xmlns="urn:isbn:1-931666-22-9"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
  </code></pre>
  
  <h2>desired output:</h2>
  
  <pre><code>&lt;foo audience="external" xsi:schemaLocation="urn:isbn:1-931666-22-9
       http://www.loc.gov/ead/ead.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-
      instance" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="urn:isbn:1-931666-22-9"&gt;
  </code></pre>
  
  <p>I was trying to do it as I copy over the whole document and before I give any other transformation instructions, but the following doesn't work:</p>
  
  <pre><code>&lt;xsl:template match="* | processing-instruction() | comment()"&gt;
      &lt;xsl:copy copy-namespaces="no"&gt;
          &lt;xsl:for-each select="."&gt;
              &lt;xsl:attribute name="audience" select="'external'"/&gt;
              &lt;xsl:namespace name="xlink" select="'http://www.w3.org/1999/xlink'"/&gt;
          &lt;/xsl:for-each&gt;
          &lt;xsl:copy-of select="@*"/&gt;
          &lt;xsl:apply-templates/&gt;
      &lt;/xsl:copy&gt;
  &lt;/xsl:template&gt;
  </code></pre>
  
  <p>Thanks for any advice!</p>