title: XSLT adds unnecessary namespaces, how to get rid of them?
body: <p>I process this XML file:</p>
  
  <pre><code>&lt;z/&gt;
  </code></pre>
  
  <p>by this XSLT 2.0 stylesheet:</p>
  
  <pre><code>&lt;xsl:stylesheet
    xmlns:xsl = "http://www.w3.org/1999/XSL/Transform"
    xmlns = "http://www.w3.org/1999/xhtml"
    xmlns:html = "http://www.w3.org/1999/xhtml"
    xmlns:data = "http://portonvictor.org/ns/misc"
    version = "2.0"
    exclude-result-prefixes = "data html"&gt;
  
    &lt;xsl:template match="/"&gt;
      &lt;xsl:variable name="x"&gt;
        &lt;data:doc&gt;
          &lt;xsl:copy-of select="*"/&gt;
        &lt;/data:doc&gt;
      &lt;/xsl:variable&gt;
      &lt;xsl:copy-of select="$x/*/*"/&gt;
    &lt;/xsl:template&gt;
  
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>Command line:</p>
  
  <pre><code>saxonb-xslt -xsl:error.xslt -s:error.xml
  </code></pre>
  
  <p>The resulting output is:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;z xmlns:data="http://portonvictor.org/ns/misc"/&gt;
  </code></pre>
  
  <p>It contains unnecessary <code>xmlns:data</code> namespace (even despite of I have <code>exclude-result-prefixes</code>). What is the easy way to get rid of such unnecessary namespaces?</p>
  
  <p>The above toy example is a simplified <a href="https://github.com/vporton/htmlsplit" rel="nofollow">real code of my free program</a>, where I process an input XHTML file in several stages, first creating <code>&lt;data:doc&gt;</code> elements and then processing them.</p>