XSLT - group response as per month and year combination
Posted
by
alisha
on Stack Overflow
See other posts from Stack Overflow
or by alisha
Published on 2011-01-09T05:36:27Z
Indexed on
2011/01/09
5:54 UTC
Read the original article
Hit count: 224
xslt-1.0
I want into write xslt to get response for the input xml. thanks in advance. I want to group output such that month year combination is not repeated for each of the employee details.
Input XML:
<resultset>
<row>
<column>
<name>Month</name>
<value>2</value>
</column>
<column>
<name>Year</name>
<value>2010</value>
</column>
<column>
<name>EmpName</name>
<value>Anu</value>
</column>
<column>
<name>Age</name>
<value>24</value>
</column>
</row>
<row>
<column>
<name>Month</name>
<value>2</value>
</column>
<column>
<name>Year</name>
<value>2010</value>
</column>
<column>
<name>EmpName</name>
<value>Nancy</value>
</column>
<column>
<name>Age</name>
<value>26</value>
</column>
</row>
<row>
<column>
<name>Month</name>
<value>3</value>
</column>
<column>
<name>Year</name>
<value>2010</value>
</column>
<column>
<name>EmpName</name>
<value>Ned</value>
</column>
<column>
<name>Age</name>
<value>25</value>
</column>
</row>
</resultset>
Output expected:
<Response>
<PeriodInfo>
<Month>2</Month>
<Year>2010</Year>
<EmployeeDetails>
<Name>Anu</Name>
<Age>24</Age>
</EmployeeDetails>
<EmployeeDetails>
<Name>Nancy</Name>
<Age>26</Age>
</EmployeeDetails>
</PeriodInfo>
<PeriodInfo>
<Month>3</Month>
<Year>2010</Year>
<EmployeeDetails>
<Name>Ned</Name>
<Age>25</Age>
</EmployeeDetails>
</PeriodInfo>
</Response>
© Stack Overflow or respective owner