title: How to copy a certain node (with children) from a XML with XSLT in Biztalk specifying a custom namespace?
body: <p>I need to copy a subnode from a XML to a certain node of a new XML in a Biztalk Map using XSLT.</p>
  
  <p>Consider the following input XML:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;ns0:root xmlns:ns0="http://not/useful/data/"&gt;
      &lt;ns0:notuseful&gt;
          &lt;ns0:foo&gt;&lt;/ns0:foo&gt;
          &lt;ns0:foo2&gt;&lt;/ns0:foo2&gt;
          &lt;ns0:blabla&gt;&lt;/ns0:blabla&gt;
      &lt;/ns0:notuseful&gt;
      &lt;ns0:data&gt;
          &lt;ns1:usefulDataList xmlns:ns1="http://useful/data/"&gt;
              &lt;ns1:usefulData&gt;
                  &lt;ns1:usefulChild1&gt;&lt;/ns1:usefulChild1&gt;
                  &lt;ns1:usefulChild2&gt;&lt;/ns1:usefulChild2&gt;
                  &lt;ns1:usefulChild3&gt;&lt;/ns1:usefulChild3&gt;
                  &lt;ns1:usefulChild4&gt;&lt;/ns1:usefulChild4&gt;
                  &lt;ns1:usefulChild5&gt;&lt;/ns1:usefulChild5&gt;
              &lt;/ns1:usefulData&gt;
          &lt;/ns1:usefulDataList&gt;
      &lt;/ns0:data&gt;
  &lt;ns0:root&gt;
  </code></pre>
  
  <p>What I need is to extract the node called "usefulDataList", so I need to copy it in a new XML like this one:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;ns2:root2 xmln:ns2="http://new/xml"&gt;
      &lt;ns2:blabla&gt;
          &lt;ns2:stuff /&gt;
      &lt;/ns2:blabla&gt;
      &lt;ns2:data&gt;
          &lt;ns2:usefulDataList&gt;
              &lt;ns2:usefulData&gt;
                  &lt;ns2:usefulChild1&gt;&lt;/ns2:usefulChild1&gt;
                  &lt;ns2:usefulChild2&gt;&lt;/ns2:usefulChild2&gt;
                  &lt;ns2:usefulChild3&gt;&lt;/ns2:usefulChild3&gt;
                  &lt;ns2:usefulChild4&gt;&lt;/ns2:usefulChild4&gt;
                  &lt;ns2:usefulChild5&gt;&lt;/ns2:usefulChild5&gt;
              &lt;/ns2:usefulData&gt;
          &lt;/ns2:usefulDataList&gt;
      &lt;/ns2:data&gt;
  &lt;/ns2:root2&gt;
  </code></pre>
  
  <p>This should be done inside a Biztalk Functoid, as you see namespaces from source and target are diferent.</p>
  
  <p>I'm an absolute beginner with XSLT, and I've been doing some tests, but I've something wrong with my XSLT expressions:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns2="http://new/xml"&gt;
      &lt;xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" /&gt;
    &lt;xsl:template name="testTemplate"  match="//*[local-name() = 'usefulDataList ']"&gt;
      &lt;xsl:element name="ns0:usefulDataList " namespace=""&gt;
        &lt;xsl:apply-templates mode="copy-no-ns" select="usefulDataList"/&gt;
      &lt;/xsl:element&gt;
    &lt;/xsl:template&gt;
    &lt;xsl:template mode="copy-no-ns" match="*"&gt;
      &lt;xsl:element name="{name(.)}" namespace="{namespace-uri(.)}"&gt;
        &lt;xsl:copy-of select="@*"/&gt;
        &lt;xsl:apply-templates mode="copy-no-ns"/&gt;
      &lt;/xsl:element&gt;
    &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>I'd appreciate any tip, with XSLT or Biztalk mapper. I don't like linking a huge amount of fields one by one if I can solve it with a XSLT expression.</p>
  
  <p>Greetings.</p>