Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Reduce duplicate XML-nodes with XSLT-transformation [Thread Next] Re: Reduce duplicate XML-nodes with XSLT-transformationTo: NULL Date: 3/1/2005 4:36:00 PM Tempore 23:19:38, die Monday 28 February 2005 AD, hinc in foro {microsoft.public.xsl} scripsit Andreas Ek <google@a...>:
> I would like to reduce duplicate nodes in my XML-source.
>
> I would like to "optimize" this to something like:
> Just like som kind of group by in SQL ;-)
Hi,
If you only need optimization for one level you can use simple grouping techniques in XSLT1.0; if you need a more universally working solution, let us know.
Here's a working sample using the muenchian grouping technique:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes" method="xml" />
<xsl:key name="Paper" match="Paper" use="Code"/>
<xsl:template match="Root">
<xsl:apply-templates select="Paper[generate-id()=generate-id(key('Paper',Code))]"/>
</xsl:template>
<xsl:template match="Paper">
<xsl:copy>
<xsl:copy-of select="Code | key('Paper',Code)/Price"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
regards,
--
Joris Gillis (http://www.ticalc.org/cgi-bin/acct-view.cgi?userid=38041)
"Et ipsa scientia potestas est" - Francis Bacon , Meditationes sacrae
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
