[Home] [By Thread] [By Date] [Recent Entries]
Bafna, Kamlesh wrote:
The requirement is to group by Company, then by Business, then by Department & finally the Account. This should do: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output indent="yes"/> <xsl:key name="by-company"
match="Row"
use="Company"/> <xsl:key name="by-business"
match="Row"
use="concat(Company, '|', Business)"/> <xsl:key name="by-department"
match="Row"
use="concat(Company, '|', Business, '|', Department)"/><xsl:key name="by-account" match="Row" use="concat(Company, '|', Business, '|', Department, '|', Account)"/> <xsl:template match="Data"> <Message> <xsl:apply-templates select="Rows/Row[generate-id() = generate-id(key('by-company', Company)[1])]" mode="company"/> </Message> </xsl:template> <xsl:template match="Row" mode="company"> <Company> <Code> <xsl:value-of select="Company"/> </Code> <xsl:apply-templates select="key('by-company', Company)[generate-id() = generate-id(key('by-business', concat(Company, '|', Business))[1])]" mode="business"/> </Company> </xsl:template> <xsl:template match="Row" mode="business"> <Business> <Code> <xsl:value-of select="Business"/> </Code> <xsl:apply-templates select="key('by-business', concat(Company, '|', Business))[generate-id() = generate-id(key('by-department', concat(Company, '|', Business, '|', Department))[1])]" mode="department"/> </Business> </xsl:template> <xsl:template match="Row" mode="department"> <Department> <Code> <xsl:value-of select="Department"/> </Code> <xsl:apply-templates select="key('by-department', concat(Company, '|', Business, '|', Department))[generate-id() = generate-id(key('by-account', concat(Company, '|', Business, '|', Department, '|', Account))[1])]" mode="account"/> </Department> </xsl:template> <xsl:template match="Row" mode="account">
<Account>
<xsl:value-of select="Account"/>
</Account>
</xsl:template></xsl:stylesheet> -- Martin Honnen http://JavaScript.FAQTs.com/
|

Cart



