title: Adding a parent node to one or more child nodes of an XML using xslt
body: <p>I am new to XSLT and i am trying to accomplish the follow case</p>
  
  <p>I have an xml in the following format</p>
  
  <pre><code>&lt;A&gt;
      &lt;B&gt;..&lt;/B&gt;
      &lt;C&gt;..&lt;/C&gt;
       ..
      &lt;Z&gt;..&lt;/Z&gt;
  &lt;/A&gt;
  </code></pre>
  
  <p>I am trying to add a new node  soon after  so that the final xml will get transformed to </p>
  
  <pre><code>&lt;A&gt;
     &lt;aa&gt;
        &lt;B&gt;..&lt;/B&gt;
        &lt;C&gt;..&lt;/C&gt;
         ..
         &lt;X&gt;...&lt;/X&gt;
     &lt;/aa&gt;
  &lt;/A&gt;
  </code></pre>
  
  <p>In order to achieve this i wrote the following xslt code</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
      &lt;xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" &gt;
      &lt;xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/&gt;
  
  &lt;xsl:template match="@*|node()"&gt;
      &lt;xsl:copy&gt;
          &lt;xsl:apply-templates select="@*|node()"/&gt;
      &lt;/xsl:copy&gt;
  &lt;/xsl:template&gt;
  
  &lt;xsl:template match="B"&gt;
      &lt;aa&gt;
          &lt;xsl:copy&gt;
          &lt;xsl:apply-templates select="@*|node()"/&gt;
      &lt;/xsl:copy&gt;
      &lt;/aa&gt;
  &lt;/xsl:template&gt;
  </code></pre>
  
  <p></p>
  
  <p>By using this i get the following output</p>
  
  <pre><code>&lt;A&gt;
     &lt;aa&gt;
        &lt;B&gt;..&lt;/B&gt;
     &lt;/aa&gt;
        &lt;C&gt;..&lt;/C&gt;
         ..
         &lt;X&gt;..&lt;/X&gt;
  &lt;/A&gt;
  </code></pre>
  
  <p>I am not sure what kind of changes i need to make to the xslt to achieve the desired output</p>