I need to do a bit tricky mapping using xslt 1.0. need to do grouping only on the date part of the datetime element. However the element contains the both date and time.Also after grouping need to add the hours.
Here is the input:
<Records>
<Record>
<empid>1</empid>
<datetime>10/10/2010 11:11:00 AM</datetime>
<hours>5</hours>
</Record>
<Record>
<empid>1</empid>
<datetime>10/10/2010 10:11:00 AM</datetime>
<hours>5</hours>
</Record>
<Record>
<empid>1</empid>
<datetime>10/11/2010 11:11:00 AM</datetime>
<hours>5</hours>
</Record>
<Record>
<empid>2</empid>
<datetime>10/10/2010 10:11:00 AM</datetime>
<hours>2</hours>
</Record>
<Record>
<empid>2</empid>
<datetime>10/10/2010 9:11:00 AM</datetime>
<hours>5</hours>
</Record>
</Records>
Expected output is:
<Records>
<Record>
<empid>1</empid>
<detail>
<date>10/10/2010</date>
<hours>10</hours>
</detail>
<detail>
<date>10/11/2010</date>
<hours>5</hours>
</detail>
</Record>
<Record>
<empid>2</empid>
<detail>
<date>10/10/2010</date>
<hours>7</hours>
</detail>
</Record>
</Records>
Appreciate for any help.
This transformation:
when applied on the provided XML document:
produces the wanted, correct result:
Explanation:
Two nested Muenchian grouping s, the inner using a composite key.