title: Add Existing node to another node's Child node
body: <p>I have following XML and i want to transform it to my desire XML using XSLT ,i have succeded somewhat but not whole problem is solved .So 
  I need help </p>
  
  <p>Given is My Input XML</p>
  
  <pre><code>&lt;?xml version = '1.0'?&gt;
  &lt;ROWSET&gt;
  &lt;irp_account num="1"&gt;
  &lt;IRP_CARRIER_ID_NUMBER&gt;274845&lt;/IRP_CARRIER_ID_NUMBER&gt;
  &lt;IRP_ACCOUNT_NUMBER&gt;55002&lt;/IRP_ACCOUNT_NUMBER&gt;
  &lt;/irp_account&gt;     
  &lt;irp_account num="97"&gt;
  &lt;IRP_CARRIER_ID_NUMBER&gt;957858&lt;/IRP_CARRIER_ID_NUMBER&gt;
  &lt;IRP_ACCOUNT_NUMBER&gt;59940&lt;/IRP_ACCOUNT_NUMBER&gt;
  &lt;NAME_TYPE&gt;LG&lt;/NAME_TYPE&gt;
  &lt;NAME&gt;SONNY DAVIS INC&lt;/NAME&gt;
  &lt;ADDRESS_TYPE&gt;MA&lt;/ADDRESS_TYPE&gt;
  &lt;/irp_account&gt;
  &lt;irp_account num="98"&gt;
  &lt;IRP_CARRIER_ID_NUMBER&gt;957858&lt;/IRP_CARRIER_ID_NUMBER&gt;
  &lt;IRP_ACCOUNT_NUMBER&gt;59940&lt;/IRP_ACCOUNT_NUMBER&gt; 
  &lt;NAME_TYPE&gt;LG&lt;/NAME_TYPE&gt;
  &lt;NAME&gt;SONNY DAVIS INC&lt;/NAME&gt;
  &lt;ADDRESS_TYPE&gt;PH&lt;/ADDRESS_TYPE&gt;
  &lt;/irp_account&gt; 
  &lt;/ROWSET&gt;
  </code></pre>
  
  <p>With the use of XSLT i want to generate Output XML like this.</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt; 
  &lt;T0020&gt;
  &lt;IRP_ACCOUNT&gt;
  &lt;IRP_CARRIER_ID_NUMBER&gt;274845&lt;/IRP_CARRIER_ID_NUMBER&gt; 
  &lt;IRP_ACCOUNT_NUMBER&gt;55002&lt;/IRP_ACCOUNT_NUMBER&gt; 
  &lt;IRP_NAME&gt;
  &lt;NAME_TYPE&gt;LG&lt;/NAME_TYPE&gt; 
  &lt;NAME&gt;A P SUPPLY CO&lt;/NAME&gt; 
  &lt;IRP_ADDRESS&gt; 
  &lt;ADDRESS_TYPE&gt;PH&lt;/ADDRESS_TYPE&gt; 
  &lt;/IRP_ADDRESS&gt;
  &lt;IRP_ADDRESS&gt;
  &lt;ADDRESS_TYPE&gt;MA&lt;/ADDRESS_TYPE&gt; 
  &lt;/IRP_ADDRESS&gt;
  &lt;/IRP_NAME&gt;
  &lt;/IRP_ACCOUNT&gt;
  &lt;/T0020&gt;
  </code></pre>
  
  <p>I have given sample output with only element to save space.</p>
  
  <p>I have tried below XSLT but it is not giving desire result</p>
  
  <pre><code>&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
  &lt;xsl:template match="/ROWSET"&gt; 
  &lt;xsl:element name="T0020"&gt;
  &lt;xsl:apply-templates select="irp_account"/&gt;
  &lt;/xsl:element&gt; 
  &lt;/xsl:template&gt;
  &lt;xsl:template match="irp_account"&gt;
  &lt;xsl:element name="IRP_ACCOUNT"&gt;
  &lt;xsl:apply-templates select="IRP_CARRIER_ID_NUMBER"/&gt;
  &lt;xsl:apply-templates select="IRP_ACCOUNT_NUMBER"/&gt;
  &lt;xsl:apply-templates select="IRP_ACCOUNT_TYPE"/&gt;
  &lt;xsl:apply-templates select="NAME_TYPE"/&gt; 
  &lt;xsl:apply-templates select="ADDRESS_TYPE"/&gt;
  &lt;/xsl:element&gt; 
  &lt;/xsl:template&gt;
  &lt;xsl:template match="IRP_CARRIER_ID_NUMBER"&gt;
  &lt;xsl:copy-of select="descendant-or-self::IRP_CARRIER_ID_NUMBER"/&gt;
  &lt;/xsl:template&gt;
  &lt;xsl:template match="IRP_ACCOUNT_NUMBER"&gt;
  &lt;xsl:copy-of select="descendant-or-self::IRP_ACCOUNT_NUMBER"/&gt;
  &lt;/xsl:template&gt;
  &lt;xsl:template match="IRP_ACCOUNT_TYPE"&gt;
  &lt;xsl:copy-of select="descendant-or-self::IRP_ACCOUNT_TYPE"/&gt;
  &lt;/xsl:template&gt;
  &lt;xsl:template match="NAME_TYPE"&gt; 
  &lt;xsl:element name="IRP_NAME"&gt;
  &lt;xsl:copy-of select="descendant-or-self::NAME_TYPE"/&gt;
  &lt;xsl:copy-of select="following-sibling::NAME"/&gt;
  &lt;/xsl:element&gt; 
  &lt;/xsl:template&gt; 
  &lt;xsl:template match="ADDRESS_TYPE"&gt;
  &lt;xsl:element name="IRP_ADDRESS"&gt;
  &lt;xsl:copy-of select="descendant-or-self::ADDRESS_TYPE"/&gt;
  &lt;xsl:copy-of select="following-sibling::NAME"/&gt;
  &lt;/xsl:element&gt; 
  &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>Please help</p>