title: XSL Create Parent Child hierarchy from denormalized data set
body: <p>Need your guidance in this.</p>
  
  <p>I am trying to create a parent-child XML out of an XML that is denormalized:</p>
  
  <p>FROM:</p>
  
  <pre><code>&lt;Parent&gt;Parent1&lt;/Parent&gt;
  &lt;Child&gt;Child1&lt;/Child&gt;
  &lt;Parent&gt;Parent2&lt;/Parent&gt;
  &lt;Child&gt;Child1&lt;/Child&gt;
  &lt;Child&gt;Child2&lt;/Child&gt;
  &lt;Parent&gt;Parent3&lt;/Parent&gt;
  &lt;Child&gt;Child1&lt;/Child&gt;
  </code></pre>
  
  <p>TO:</p>
  
  <pre><code>&lt;Parent&gt;
  &lt;ParentValue&gt;Parent1&lt;/ParentValue&gt;
  &lt;Child&gt;
      &lt;ChildValue&gt;Child1&lt;/ChildValue&gt;
  &lt;/Child&gt;
  &lt;/Parent&gt;
  &lt;Parent&gt;
  &lt;ParentValue&gt;Parent2&lt;/ParentValue&gt;
  &lt;Child&gt;
      &lt;ChildValue&gt;Child1&lt;/ChildValue&gt;
  &lt;/Child&gt;
  &lt;Child&gt;
      &lt;ChildValue&gt;Child2&lt;/ChildValue&gt;
  &lt;/Child&gt;
  &lt;/Parent&gt;
  &lt;Parent&gt;
  &lt;ParentValue&gt;Parent3&lt;/ParentValue&gt;
  &lt;Child&gt;
      &lt;ChildValue&gt;Child1&lt;/ChildValue&gt;
  &lt;/Child&gt;
  &lt;/Parent&gt;
  </code></pre>
  
  <p>The problem is that I cant figure out the logic to say, get all Child element between each parent elements.</p>
  
  <p>Any help is appreciated. </p>
  
  <p>Thanks a lot for looking into this.</p>