title: Namespace output with XSLT 1.0 causing problems
body: <p>I'm using XSLT 1.0 to transform some XML. </p>
  
  <p>I'm not quite sure the best way to explain this, so will use some examples. </p>
  
  <p>My input XML contains a specialization, using the xsi:type declaration. See the Payload node:</p>
  
  <pre><code>&lt;ns0:RootNode xmlns:ns0="namespace1" xmlns:ns1="namespace2" xmlns:xsi="http://www.w3.org/2001/XMLSchema"&gt;
    &lt;ns0:Payload xsi:type="ns1:SpecialPayload"&gt;
      &lt;ns1:InnerNode&gt;Hello&lt;/ns1:InnerNode&gt;
    &lt;/ns0:Payload&gt;
  &lt;/ns0:RootNode&gt;
  </code></pre>
  
  <p>When I send this through my XSLT (let's assume a 1 to 1 copy), I get the following output</p>
  
  <pre><code>&lt;ns0:RootNode xmlns:ns0="namespace1" xmlns:xsi="http://www.w3.org/2001/XMLSchema"&gt;
    &lt;ns0:Payload xsi:type="ns1:SpecialPayload"&gt;
      &lt;ns1:InnerNode xmlns:ns1="namespace2"&gt;Hello&lt;/ns1:InnerNode&gt;
    &lt;/ns0:Payload&gt;
  &lt;/ns0:RootNode&gt;
  </code></pre>
  
  <p>Notice the ns1 namespace has been attached to the individual nodes within the payload node. In most cases this would be fine, however I need that declaration to happen earlier, i.e. on the root node, as it makes the xsi:type definition on the payload node invalid, because at this point the serializer does not know about the ns1 namespace, which prevents correct parsing downstream.</p>
  
  <p>What can I do to force this namespace to be output a little earlier?</p>
  
  <p>Edited XSLT Code:</p>
  
  <pre><code>  &lt;!-- Replace The ESBMessage node with the SOAP method --&gt;
    &lt;xsl:template match="s1:ESBMessage" mode="copy"&gt;
      &lt;s0:SendESBMessage&gt;
        &lt;s0:msg&gt;
          &lt;xsl:apply-templates select="*" mode="copy"/&gt;
        &lt;/s0:msg&gt;
      &lt;/s0:SendESBMessage&gt;
    &lt;/xsl:template&gt;
  
    &lt;!-- Generic Copy --&gt;
    &lt;xsl:template match="*" mode="copy"&gt;
      &lt;xsl:element name="{name(.)}" namespace="{namespace-uri(.)}"&gt;
        &lt;xsl:copy-of select="@*"/&gt;
        &lt;xsl:apply-templates mode="copy"/&gt;
      &lt;/xsl:element&gt;
    &lt;/xsl:template&gt;
  </code></pre>