how to apply group by on xslt elements
Posted
by Amit
on Stack Overflow
See other posts from Stack Overflow
or by Amit
Published on 2010-01-27T12:04:13Z
Indexed on
2010/04/20
22:03 UTC
Read the original article
Hit count: 275
Hello All,
I need to group the value based on some attribute and populate it.
below mentioned is i/p xml and if you see there are 4 rows for Users and for id 2,4 Division is same i.e. HR
while generating actual o/p I need to group by Division ... Any help ???
I/P XML
<Users>
<User id="2" name="ABC" Division="HR"/>
<User id="3" name="xyz" Division="Admin"/>
<User id="4" name="LMN" Division="Payroll"/>
<User id="5" name="PQR" Division="HR"/>
</Users>
expected Result: I need to group the values based on Division and populate i.e.
<AllUsers>
<Division value="HR">
<User>
<id>2</id>
<name>ABC</name>
</User>
<User>
<id>5</id>
<name>PQR</name>
</User>
</Division>
<Division value="ADMIN">
<User>
<id>3</id>
<name>XYZ</name>
</User>
</Division>
<Division value="Payroll">
<User>
<id>4</id>
<name>LMN</name>
</User>
</Division>
</AllUsers>
© Stack Overflow or respective owner