Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Filtering dupes

From: "Oleg Tkachenko [MVP]" <oleg@--_!----!_------!---------.--->
To: NULL
Date: 10/4/2004 5:06:00 PM
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


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