Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Removing Dupicates >Thread Next - Re: Removing Dupicates Re: Removing DupicatesTo: NULL Date: 3/13/2005 9:37:00 AM Tempore 09:56:13, die Sunday 13 March 2005 AD, hinc in foro {microsoft.public.xsl} scripsit volume <a@a...>:
> How do I remove all dupicates nodes from an xml document?
>
> For example, remove all dupicates "item" nodes from the following:
>
> <items>
> <item>aaa</item>
> <item>zzz</item>
> <item>aaa</item>
> </items>
Hi,
one of the most common ways to do this (in XSLT1.0) is with the combination of 'generate-id()' and key()': the mueanchian grouping technique.
here's a sample:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" />
<xsl:key name="item" match="item" use="."/>
<xsl:template match="items">
<xsl:copy-of select="item[generate-id(key('item',.)[1])=generate-id()]"/>
</xsl:template>
</xsl:stylesheet>
regards,
--
Joris Gillis (http://www.ticalc.org/cgi-bin/acct-view.cgi?userid=38041)
Ceterum censeo XML omnibus esse utendum
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
