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 in a list - Urgent
Author: C M
Date: 25 Aug 2006 01:31 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 person with the same id & map only one. Here representedBy is the repeating node.

input:

<ns0:listOfRepresentedBy>
<ns0:representedBy>
<ns0:person>
<ns0:id>c1</ns0:id>
</ns0:person>
</ns0:representedBy>
<ns0:representedBy>
<ns0:person>
<ns0:id>c1</ns0:id>
</ns0:person>
</ns0:representedBy>
<ns0:representedBy>
<ns0:person>
<ns0:id>c1</ns0:id>
</ns0:person>
</ns0:representedBy>
<ns0:representedBy>
<ns0:person>
<ns0:id>c1</ns0:id>
</ns0:person>
</ns0:representedBy>
</ns0:listOfRepresentedBy>

xsl:

<ns0:listOfRepresentedBy>
<xsl:for-each select="ns0:listOfRelationship/ns0:listOfRepresentedBy/ns0:representedBy[not(ns0:person/ns0:id = preceding::ns0:person/ns0:id)]">
<ns0:representedBy>
<ns0:person>
<ns0:id>
<xsl:value-of select="ns0:person/ns0:id"/>
</ns0:id>
</ns0:person>
</ns0:representedBy>
</xsl:for-each>

Any help would be greatly appreciated.

Thanks.

Postnext
James DurningSubject: Remove duplicates in a list - Urgent
Author: James Durning
Date: 25 Aug 2006 02:33 PM
Originally Posted: 25 Aug 2006 02:32 PM
Not sure why it isn't working for you. Try preceding-sibling axis instead?
<ns0:listOfRepresentedBy>
<xsl:copy-of select="ns0:listOfRelationship/ns0:listOfRepresentedBy/ns0:representedBy[not(ns0:person/ns0:id = preceding-sibling::/ns0:representedBy/ns0:person/ns0:id)]">
</ns0:listOfRepresentedBy>

Posttop
C MSubject: Remove duplicates in a list - Urgent
Author: C M
Date: 25 Aug 2006 03:47 PM
Great. That did the trick.
Thanks.

 
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.