Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Re: change of xml [Thread Next] Re: change of xmlTo: NULL Date: 8/23/2007 2:59:00 AM
On Aug 17, 2:16 pm, Martin Honnen <mahotr...@yahoo.de> wrote:
> pitadel wrote:
> > to transform this new xml grouping by country with the totally of the
> > salary of this groups depends on country
>
finally I make a xslt to change xml to a xml - excel... This is the
result final...
<xsl:stylesheet version="1.0"
xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:user="urn:my-scripts"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" >
<xsl:key name="country-group" match="authors" use="country"/>
<xsl:template match="/">
<xsl:processing-instruction name='mso-application'>
<xsl:text>progid='Excel.Sheet'</xsl:text>
</xsl:processing-instruction>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40">
<xsl:apply-templates/>
</Workbook>
</xsl:template>
<xsl:template match="/*">
<Worksheet>
<xsl:attribute name="ss:Name">
<xsl:value-of select="local-name(/*/*)"/>
</xsl:attribute>
<Table x:FullColumns="1" x:FullRows="1">
<Row>
<xsl:for-each select="*[position() = 1]/*">
<Cell><Data ss:Type="String">
<xsl:value-of select="local-name()"/>
</Data></Cell>
</xsl:for-each>
</Row>
<xsl:apply-templates select="authors[generate-id() = generate-
id(key('country-group', country)[1])]" mode="group"/>
</Table>
</Worksheet>
</xsl:template>
<xsl:template match="authors" mode="group">
<xsl:apply-templates select="key('country-group', country)"/>
<Row>
<Cell><Data ss:Type="String"><xsl:value-of select="country"/></
Data></Cell>
<Cell><Data ss:Type="String"><xsl:value-of
select="sum(key('country-group', country)/salary)"/></Data></
Cell>
</Row>
</xsl:template>
<xsl:template match="/*/*">
<Row>
<xsl:apply-templates/>
</Row>
</xsl:template>
<xsl:template match="/*/*/*">
<Cell><Data ss:Type="String">
<xsl:value-of select="."/>
</Data></Cell>
</xsl:template>
</xsl:stylesheet>
Thank you, Martin Honnen , you are invited one beer when you
want... :-)
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
