title: XSLT grouping every 4 adjacent elements
body: <p>I have a xml like below.</p>
  
  <p><strong>Source XML:</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="Windows-1252"?&gt;
  &lt;XML&gt;
    &lt;Attributes&gt;
      &lt;Attribute&gt;
        &lt;Name&gt;Collection&lt;/Name&gt;
        &lt;Value /&gt;
      &lt;/Attribute&gt;
      &lt;Attribute&gt;
        &lt;Name&gt;A&lt;/Name&gt;
        &lt;Value&gt;Testing&lt;/Value&gt;
      &lt;/Attribute&gt;
      &lt;Attribute&gt;
        &lt;Name&gt;B&lt;/Name&gt;
        &lt;Value&gt;Blank&lt;/Value&gt;
      &lt;/Attribute&gt;
      &lt;Attribute&gt;
        &lt;Name&gt;C&lt;/Name&gt;
        &lt;Value&gt;11&lt;/Value&gt;
      &lt;/Attribute&gt;
      &lt;Attribute&gt;
        &lt;Name&gt;D&lt;/Name&gt;
        &lt;Value&gt;NA&lt;/Value&gt;
      &lt;/Attribute&gt;
      &lt;Attribute&gt;
        &lt;Name&gt;A&lt;/Name&gt;
        &lt;Value&gt;Testing1&lt;/Value&gt;
      &lt;/Attribute&gt;
      &lt;Attribute&gt;
        &lt;Name&gt;B&lt;/Name&gt;
        &lt;Value&gt;Red&lt;/Value&gt;
      &lt;/Attribute&gt;
      &lt;Attribute&gt;
        &lt;Name&gt;C&lt;/Name&gt;
        &lt;Value&gt;12&lt;/Value&gt;
      &lt;/Attribute&gt;
      &lt;Attribute&gt;
        &lt;Name&gt;D&lt;/Name&gt;
        &lt;Value&gt;NAT&lt;/Value&gt;
      &lt;/Attribute&gt;
    &lt;/Attributes&gt;
  &lt;/XML&gt;
  </code></pre>
  
  <p>From the above xml how I can I do this. I only want to group them in groups of 4. So first 4 (in the source xml) element where /attribute/Name='A' - /attribute/Name='D' will be in the first group. and next 4 where /attribute/Name='A' - /attribute/Name='D' will be in the second group .... like below</p>
  
  <p>Thanks in Advance</p>
  
  <p><strong>Output</strong></p>
  
  <pre><code> &lt;Collection name="Collection" &gt;
             &lt;ComplexAttr&gt;
                    &lt;Attr name="A" value="Testing" /&gt;
                    &lt;Attr name="B" value="Blank" /&gt;
                    &lt;Attr name="C" value="11" /&gt;
                    &lt;Attr name="D" value="NA" /&gt;
             &lt;/ComplexAttr&gt;
             &lt;ComplexAttr &gt;
                    &lt;Attr name="A" value="Testing1" /&gt;
                    &lt;Attr name="B" value="Red" /&gt;
                    &lt;Attr name="C" value="12" /&gt;
                    &lt;Attr name="D" value="NA" /&gt;
             &lt;/ComplexAttr&gt;
      &lt;/Collection&gt;
  </code></pre>