Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Removing Dupicates

From: "Joris Gillis" <roac@-------.-->
To: 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


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent