Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - change of xml >Thread Next - Re: change of xml Re: change of xmlTo: NULL Date: 8/17/2007 2:17:00 PM pitadel wrote: > to transform this new xml grouping by country with the totally of the > salary of this groups depends on country XSLT 1.0 grouping approach looks like this: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:strip-space elements="*"/> <xsl:output method="xml" indent="yes"/> <xsl:key name="country-group" match="authors" use="country"/> <xsl:template match="NewDataSet"> <xsl:copy> <xsl:apply-templates select="authors[generate-id() = generate-id(key('country-group', country)[1])]" mode="group"/> </xsl:copy> </xsl:template> <xsl:template match="authors" mode="group"> <xsl:apply-templates select="key('country-group', country)"/> <salaryGroup> <salary><xsl:value-of select="sum(key('country-group', country)/salary)"/></salary> <country><xsl:value-of select="country"/></country> </salaryGroup> </xsl:template> <xsl:template match="@* | node()"> <xsl:copy> <xsl:apply-templates select="@* | node()"/> </xsl:copy> </xsl:template> </xsl:stylesheet> The result however is slightly different from the output you posted as the authors element with name Harry has two salary child elements and the above stylesheet sums up both of these elements. -- Martin Honnen --- MVP XML http://JavaScript.FAQTs.com/ | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
