This question is related to this post http://stackoverflow.com/questions/3461728/find-maximum-value-of-all-child-elements-and-get-its-parent-element-in-xslt. I asked my question incorrectly. Actually I need output little different. I need to match site node id with worksite node and find out the person who worked more hours for that site.
<root>
<Site id="S1">
<othernodes></othernodes>
</Site>
<Site id="S2">
<othernodes></othernodes>
</Site>
<Site id="S3">
<othernodes></othernodes>
</Site>
<WorkSite Person="P1" Site="S1">
<Hours>8</Hours>
</WorkSite>
<WorkSite Person="P1" Site="S2">
<Hours>2</Hours>
</WorkSite>
<WorkSite Person="P1" Site="S3">
<Hours>20</Hours>
</WorkSite>
<WorkSite Person="P2" Site="S1">
<Hours>6</Hours>
</WorkSite>
<WorkSite Person="P2" Site="S2">
<Hours>10</Hours>
</WorkSite>
<WorkSite Person="P2" Site="S3">
<Hours>21</Hours>
</WorkSite>
</root>
The transformed content should be like this
<root>
<site id="S1">
<othernodes></othernodes>
<person>P1</person>
</site>
<site id="S2">
<othernodes></othernodes>
<person>P2</person>
</site>
<site id="S3">
<othernodes></othernodes>
<person>P1</person>
</site>
</root>
Can someone help on this?