title: Splitting XML message into multiple messages with generic root and common header
body: <p>I am a beginner to XSLT and have spent sometime trying to figure out how to do the following transformation...</p>
  
  <p>I want to divide an XML message that has one header and multiple items into multiple XML messages, where each message is having only one item element while the rest of the xml is the same.</p>
  
  <p>So if we look at the following XML Input Message:</p>
  
  <pre><code>&lt;RequestOne xmlns:h="http://www.w3.org/TR/myns/"    xmlns:f="http://www.w3schools.com/furniture"    xmlns:p="http://www.w3.org/p"&gt;
  &lt;Header&gt;
      &lt;ID&gt;AB1234&lt;/ID&gt;
      &lt;Number&gt;61&lt;/Number&gt;
  &lt;/Header&gt;
  
  &lt;Item&gt;
      &lt;Name&gt;Item1&lt;/Name&gt;
      &lt;ItemID&gt;I001&lt;/ItemID&gt;
  &lt;/Item&gt;
  &lt;Item&gt;
      &lt;Name&gt;Item2&lt;/Name&gt;
      &lt;ItemID&gt;I002&lt;/ItemID&gt;
  &lt;/Item&gt;
  &lt;Item&gt;
      &lt;Name&gt;Item3&lt;/Name&gt;
      &lt;ItemID&gt;I003&lt;/ItemID&gt;
  &lt;/Item&gt;
  &lt;/RequestOne&gt;
  </code></pre>
  
  <p>I want to transform it to 3 messages having the same structure and elements, except that each message has one item of the original XML.</p>
  
  <p>One important requirement is that the XSL code would be generic to any root element name and namespaces. That is, the request message's root can be <code>&lt;RequestOne&gt;, &lt;RequestTwo&gt; ... &lt;RequestN&gt;</code> and all its namespaces should be copied too.</p>
  
  <p>I managed to create the following piece of code. I think it is missing copying the root element along with its namespaces.</p>
  
  <pre><code>&lt;xsl:for-each select="//*[local-name()='Item']"&gt; 
      &lt;!-- Missing here the part that would copy the root element along with the namespaces --&gt;
      &lt;xsl:copy-of select="../Item"/&gt;
      &lt;xsl:copy-of select="." /&gt;
  &lt;/xsl:for-each&gt; 
  </code></pre>
  
  <p>If there is more than one way to do this, would it be possible to do it in only one template?</p>
  
  <p>UPDATE:</p>
  
  <p>Sorry for not providing the expected output. Here it is below</p>
  
  <p>Message N:</p>
  
  <pre><code>&lt;RequestN xmlns:h="http://www.w3.org/TR/myns/"  xmlns:f="http://www.w3schools.com/furniture"    xmlns:p="http://www.w3.org/p"&gt;
      &lt;Header&gt;
          &lt;ID&gt;AB1234&lt;/ID&gt;
          &lt;Number&gt;61&lt;/Number&gt;
      &lt;/Header&gt;
      &lt;Item&gt;
          &lt;Name&gt;ItemN&lt;/Name&gt;
          &lt;ItemID&gt;I00N&lt;/ItemID&gt;
      &lt;/Item&gt;
  &lt;/RequestN&gt;
  </code></pre>