XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
C MSubject: Remove duplicates - different scenario - Please help.
Author: C M
Date: 25 Aug 2006 04:01 PM
Hi All,

I have the following xml input & the xsl code which is not giving the desired putput. I need to remove the duplicate address with the same id across different org if the org id matches & map only one. It is removing the duplicate orgs & maping all the duplicate addresses & not only one address. Basicallt the preceding sibling I have for the address is not working. Any help would be great. Please help.

Input XML:

<org>
<id>a1</id>
<listOfAddress>
<address>
<id>ad1</id>
</address>
</listOfAddress>
</org>
<org>
<id>a1</id>
<listOfAddress>
<address>
<id>ad1</id>
</address>
</listOfAddress>
</org>
<org>
<id>a1</id>
<listOfAddress>
<address>
<id>ad1</id>
</address>
</listOfAddress>
</org>
<org>
<id>a1</id>
<listOfAddress>
<address>
<id>ad1</id>
</address>
</listOfAddress>
</org>

XSL:

<ns0:listOfOrg>
<xsl:for-each select="/ns0:listOfOrg/ns0:org[not(ns0:id = preceding-sibling::ns0:org/ns0:id)]">
<xsl:variable name="acc_id" select="ns0:id"/>
<ns0:org>
<ns0:id>
<xsl:value-of select="ns0:id"/>
</ns0:id>
<ns0:listOfAddress>
<xsl:for-each select="/ns0:listOfOrg/ns0:org">
<xsl:if test="ns0:id = $acc_id">
<xsl:for-each select="ns0:listOfAddress/ns0:address[not(ns0:id = preceding-sibling::ns0:listOfOrg/ns0:org/ns0:listOfAddress/ns0:address/ns0:id)]"> <ns0:address>
<ns0:id>
<xsl:value-of select="ns0:id"/>
</ns0:id>
</ns0:address>
</xsl:for-each>
</xsl:if>
</xsl:for-each>
</ns0:listOfAddress>
</ns0:org>
</xsl:for-each>
</ns0:listOfOrg>

Thanks.

Posttop
Tony LavinioSubject: Remove duplicates - different scenario - Please help.
Author: Tony Lavinio
Date: 11 Sep 2006 04:38 PM
See http://www.jenitennison.com/xslt/index.html under
"Complex Tasks"

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.