title: xslt grouping / restructuring from flat structure
body: <p>is there a way to transform a flat structure like:-</p>
  
  <pre><code>&lt;recordGroup&gt;
      &lt;records&gt;
          &lt;fromcode&gt;code2&lt;/fromcode&gt;
          &lt;fromname&gt;name3&lt;/fromname&gt;
          &lt;viacode&gt;code6&lt;/viacode&gt;
          &lt;vianame&gt;name7&lt;/vianame&gt;
          &lt;viacode&gt;code18&lt;/viacode&gt;
          &lt;vianame&gt;name15&lt;/vianame&gt;
          &lt;tocode&gt;code22&lt;/tocode&gt;
          &lt;toname&gt;name23&lt;/toname&gt;
          &lt;fromcode&gt;code22&lt;/fromcode&gt;
          &lt;fromname&gt;name23&lt;/fromname&gt;
          &lt;tocode&gt;code31&lt;/tocode&gt;
          &lt;toname&gt;name32&lt;/toname&gt;
          &lt;fromcode&gt;code31&lt;/fromcode&gt;
          &lt;fromname&gt;name32&lt;/fromname&gt;
          &lt;viacode&gt;code39&lt;/viacode&gt;
          &lt;vianame&gt;name40&lt;/vianame&gt;
          &lt;viacode&gt;code47&lt;/viacode&gt;
          &lt;vianame&gt;name48&lt;/vianame&gt;
          &lt;viacode&gt;code56&lt;/viacode&gt;
          &lt;vianame&gt;name57&lt;/vianame&gt;
          &lt;viacode&gt;code64&lt;/viacode&gt;
          &lt;vianame&gt;name65&lt;/vianame&gt;
          &lt;tocode&gt;code72&lt;/tocode&gt;
          &lt;toname&gt;name73&lt;/toname&gt;
      &lt;/records&gt;
  &lt;/recordGroup&gt;
  </code></pre>
  
  <p>to :-</p>
  
  <pre><code>&lt;recordGroup&gt;
      &lt;records&gt;
          &lt;record&gt;
              &lt;fromcode&gt;code2&lt;/fromcode&gt;
              &lt;fromname&gt;name3&lt;/fromname&gt;
              &lt;viacode&gt;code6&lt;/viacode&gt;
              &lt;vianame&gt;name7&lt;/vianame&gt;
              &lt;viacode&gt;code18&lt;/viacode&gt;
              &lt;vianame&gt;name15&lt;/vianame&gt;
              &lt;tocode&gt;code22&lt;/tocode&gt;
              &lt;toname&gt;name23&lt;/toname&gt;
          &lt;/record&gt;
          &lt;record&gt;
              &lt;fromcode&gt;code22&lt;/fromcode&gt;
              &lt;fromname&gt;name23&lt;/fromname&gt;
              &lt;tocode&gt;code31&lt;/tocode&gt;
              &lt;toname&gt;name32&lt;/toname&gt;
          &lt;/record&gt;
          &lt;record&gt;
              &lt;fromcode&gt;code31&lt;/fromcode&gt;
              &lt;fromname&gt;name32&lt;/fromname&gt;
              &lt;viacode&gt;code39&lt;/viacode&gt;
              &lt;vianame&gt;name40&lt;/vianame&gt;
              &lt;viacode&gt;code47&lt;/viacode&gt;
              &lt;vianame&gt;name48&lt;/vianame&gt;
              &lt;viacode&gt;code56&lt;/viacode&gt;
              &lt;vianame&gt;name57&lt;/vianame&gt;
              &lt;viacode&gt;code64&lt;/viacode&gt;
              &lt;vianame&gt;name65&lt;/vianame&gt;
              &lt;tocode&gt;code72&lt;/tocode&gt;
              &lt;toname&gt;name73&lt;/toname&gt;
          &lt;/record&gt;
      &lt;/records&gt;
  &lt;/recordGroup&gt;
  </code></pre>
  
  <p>in XSLT. the upper section of the code is a flat structure which we want to transform to an another layer of structure ie 'record'. Please let me know any sample xslt for this.</p>
  
  <p>regards</p>