Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - Re: Filtering dupes [Thread Next] Re: Filtering dupesTo: NULL Date: 10/4/2004 12:55:00 PM Fantastic! Exactly what I needed.
"Oleg Tkachenko [MVP]" wrote:
> JeD wrote:
>
> > Can someone help me write the appropriate xsl transformation to output a xml
> > document where duplicates have been filtered out. In my input document, two
> > "rows" are duplicates if they use the same unique identifier field (as
> > determined by an attribute called 'uniqueidfield') and the value in this
> > field is the same. In the following example, there are two duplicate accounts
> > with the accountid 'ABC' but there is also a contact with the same id. The
> > output document should contain one of the two 'ABC' accounts (I don't really
> > care which one) and it should also containt the 'ABC' contact.
>
> You can use a composite key here:
>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> <xsl:key name="resultKey" match="result"
> use="concat(@uniqueidfield, ' | ', *[name()=../@uniqueidfield])"/>
> <xsl:template match="resultset">
> <resultset>
> <xsl:apply-templates
> select="result[generate-id()=generate-id(key('resultKey',
> concat(@uniqueidfield, ' | ', *[name()=../@uniqueidfield]))[1])]"/>
> </resultset>
> </xsl:template>
> <xsl:template match="result">
> <xsl:copy-of select="."/>
> </xsl:template>
> </xsl:stylesheet>
>
>
> --
> Oleg Tkachenko [XML MVP]
> http://blog.tkachenko.com
>
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
