Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old April 28th, 2018, 11:30 AM
Authorized User
Points: 110, Level: 2
Points: 110, Level: 2 Points: 110, Level: 2 Points: 110, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2018
Posts: 16
Thanks: 3
Thanked 0 Times in 0 Posts
Unhappy removing duplicate in xmlnotdisplaying correct result

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" omit-xml-declaration="yes"/>
<xsl:strip-space elements="*"/>

<xsl:key name="kMapping" match="Registration" use="Country"/>
<xsl:template match="@* | node()" name="Copy">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>

<xsl:template match="Registration[generate-id() = generate-id(key('kMapping', Country)[1])]">
<xsl:call-template name="Copy"/>
</xsl:template>
<xsl:template match="Registration"/>
</xsl:stylesheet>

XML Code Input file
=================

<FundsXML> <Funds> <Fund> <Name>Fund11111 </Name> <FundFacts> <KeyFacts> <Registration> <Country>AT</Country> </Registration> <Registration> <Country>AT</Country> </Registration> <Registration> <Country>BE</Country> </Registration> <Registration> <Country>BE</Country> </Registration> <Registration> <Country>BE</Country> </Registration> </KeyFacts> </FundFacts> <Name>Fund22222 </Name> <SecurityCodes> <CountrySecurityCode> <CountryCode>DE</CountryCode> </CountrySecurityCode> </SecurityCodes> <FundFacts> <KeyFacts> <Registration> <Country>AE</Country> </Registration> <Registration> <Country>AT</Country> </Registration> <Registration> <Country>AT</Country> </Registration> <Registration> <Country>BE</Country> </Registration> <Registration> <Country>BE</Country> </Registration> <Registration> <Country>BE</Country> </Registration> <Registration> <Country>PT</Country> </Registration> </KeyFacts> </FundFacts> </Fund> </Funds> </FundsXML>

Desired output
Need country code to be displayed once per fund11111 and fund22222

<FundsXML> <Funds> <Fund> <Name>Fund11111 </Name> <FundFacts> <KeyFacts> <Registration> <Country>AT</Country> </Registration> <Registration> <Country>BE</Country> </Registration> </KeyFacts> </FundFacts> <Name>Fund22222 </Name> <FundFacts> <KeyFacts> <Registration> <Country>AE</Country> </Registration> <Registration> <Country>AT</Country> </Registration> <Registration> <Country>BE</Country> </Registration> <Registration> <Country>PT</Country> </Registration> </KeyFacts> </FundFacts> </Fund> </Funds> </FundsXML>
The code is displayed singlecountry record for first fund only and removing country value records which are present in Fund22222

Output displayed by above XSLT
==============================
<FundsXML> <Funds> <Fund> <Name>Fund11111 </Name> <FundFacts> <KeyFacts> <Registration> <Country>AT</Country> </Registration> <Registration> <Country>BE</Country> </Registration> </KeyFacts> </FundFacts> <Name>Fund22222 </Name> <FundFacts> <KeyFacts> <Registration> <Country>PT</Country> </Registration> </KeyFacts> </FundFacts> </Fund> </Funds> </FundsXML>


Any help will be much appreciated
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
removing duplicate nodes nguna XSLT 6 February 16th, 2009 10:40 AM
Removing duplicate entries avantikad XSLT 2 January 2nd, 2008 12:29 PM
Removing duplicate Value Row milindsaraswala Excel VBA 0 November 14th, 2007 06:11 PM
Removing the Duplicate anukagni Access 3 August 31st, 2006 01:57 AM
Removing Duplicate Fields antonides Access 2 December 1st, 2003 07:37 PM



All times are GMT -4. The time now is 03:20 AM.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.