title: Group by in xslt 2.0
body: <p>I am facing this requirement to group by in xslt 2.0.
  I have been doing some basic xslt's lately with apply-templates, identity transform and this is my bit advanced case for now. </p>
  
  <p>I would really appreciate the inputs.</p>
  
  <p><strong>Here is my input XML:</strong></p>
  
  <pre><code>&lt;root&gt;
      &lt;worker&gt;
          &lt;change1&gt;
              &lt;date_of_change&gt;date1&lt;/date_of_change&gt;
              &lt;field1&gt;field1&lt;/field1&gt;
              &lt;field2&gt;field2&lt;/field2&gt;
              &lt;field4&gt;field4&lt;/field4&gt;
          &lt;/change1&gt;
          &lt;change2&gt;
              &lt;date_of_change&gt;date1&lt;/date_of_change&gt;
              &lt;field1&gt;field1&lt;/field1&gt;
              &lt;field2&gt;field2&lt;/field2&gt;
              &lt;field3&gt;field3&lt;/field3&gt;
          &lt;/change2&gt;
          &lt;change3&gt;
              &lt;date_of_change&gt;date2&lt;/date_of_change&gt;          
              &lt;field2&gt;field2&lt;/field2&gt;
              &lt;field3&gt;field3&lt;/field3&gt;
              &lt;field4&gt;field4&lt;/field4&gt;
          &lt;/change3&gt;
      &lt;/worker&gt;
      &lt;worker&gt;
          &lt;change1&gt;
              &lt;date_of_change&gt;date1&lt;/date_of_change&gt;
              &lt;field1&gt;field1&lt;/field1&gt;
              &lt;field2&gt;field2&lt;/field2&gt;
              &lt;field3&gt;field3&lt;/field3&gt;
          &lt;/change1&gt;
          &lt;change2&gt;
              &lt;date_of_change&gt;date2&lt;/date_of_change&gt;
              &lt;field1&gt;field1&lt;/field1&gt;         
              &lt;field3&gt;field3&lt;/field3&gt;
          &lt;/change2&gt;
          &lt;change3&gt;
              &lt;date_of_change&gt;date2&lt;/date_of_change&gt;          
              &lt;field3&gt;field3&lt;/field3&gt;
              &lt;field4&gt;field4&lt;/field4&gt;
          &lt;/change3&gt;
      &lt;/worker&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p><strong>Here is the expected output XML:</strong></p>
  
  <pre><code>&lt;root&gt;
      &lt;worker&gt;
          &lt;row1&gt;
              &lt;date_of_change&gt;date1&lt;/date_of_change&gt;
              &lt;field1&gt;field1&lt;/field1&gt;
              &lt;field2&gt;field2&lt;/field2&gt;
              &lt;field3&gt;field3&lt;/field3&gt;
              &lt;field4&gt;field4&lt;/field4&gt;
          &lt;/row1&gt;
          &lt;row2&gt;
              &lt;date_of_change&gt;date2&lt;/date_of_change&gt;          
              &lt;field2&gt;field2&lt;/field2&gt;
              &lt;field3&gt;field3&lt;/field3&gt;
              &lt;field4&gt;field4&lt;/field4&gt;
          &lt;/row2&gt;
      &lt;/worker&gt;
      &lt;worker&gt;
          &lt;row1&gt;
              &lt;date_of_change&gt;date1&lt;/date_of_change&gt;
              &lt;field1&gt;field1&lt;/field1&gt;
              &lt;field2&gt;field2&lt;/field2&gt;
              &lt;field3&gt;field3&lt;/field3&gt;
          &lt;/row1&gt;
          &lt;row2&gt;
              &lt;date_of_change&gt;date2&lt;/date_of_change&gt;
              &lt;field1&gt;field1&lt;/field1&gt;         
              &lt;field3&gt;field3&lt;/field3&gt;
              &lt;field4&gt;field4&lt;/field4&gt;
          &lt;/row2&gt;     
      &lt;/worker&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p>Requirement is when a worker have multiple changes happened on the same date_of_change, then it needs to be grouped to the same row with all the available fields from those multiple changes. </p>