Thread: sorting nodes
View Single Post
  #5 (permalink)  
Old July 7th, 2009, 02:32 AM
scubin scubin is offline
Authorized User
Points: 51, Level: 1
Points: 51, Level: 1 Points: 51, Level: 1 Points: 51, Level: 1
Activity: 10%
Activity: 10% Activity: 10% Activity: 10%
 
Join Date: Jul 2009
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you Michael that helped a lot and i was able to get result what i want but there is one more thing that troubling me ,in the below XML if i want Employee Id to be outputted along with
Input XML:
<Company>
<Employees>
<Id>123</Id>
<employee >
<TypeCde>FN</TypeCde>
<salary>100000</salary>
</employee>
<employee>
<TypeCde>CL</TypeCde>
<salary>95000</salary>
</employee>
</Employees>
<Employees>
<Id>234</Id>
<employee>
<TypeCde>UH</TypeCde>
<salary>89000</salary>
</employee>
<employee>
<TypeCde>FN</TypeCde>
<salary>10000</salary>
</employee>
</Employees>
<Company>
Below is the my output should be

<Company>
<Employees>
<employee >
<TypeCde>FN</TypeCde>
<salary>100000</salary>
<Id>123</Id>
<Id>234</Id>
</employee>
<employee>
<TypeCde>CL</TypeCde>
<salary>95000</salary>
<Id>123</Id>
</employee>
<employee>
<TypeCde>UH</TypeCde>
<salary>89000</salary>
<Id>234</Id>
</employee>
</Employees>
</Comapny>

based on my muenchian method below is my code snippet
<xsl:for-each select="//employee[generate-id(.) = generate-id(key('k',
TypeCde)[1])]">
<xsl:for-each select="key('k', TypeCde)">
<xsl:sort select="salary" data-type="number" order="descending"/>
<xsl:if test="position() = 1">
<xsl:copy-of select="."/>
</xsl:if>
</xsl:for-each>
</xsl:for-each>
what can i do to get the <Id> of Employees in output xml?


Thnaks in advance
Reply With Quote