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 Search this Thread Display Modes
  #11 (permalink)  
Old April 30th, 2018, 07:56 AM
Friend of Wrox
Points: 6,673, Level: 34
Points: 6,673, Level: 34 Points: 6,673, Level: 34 Points: 6,673, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2007
Location: Germany
Posts: 1,242
Thanks: 0
Thanked 244 Times in 243 Posts
Default

Well, which XSLT processor do you use, which XSLT version does it support? Can you switch to Saxon 9 or another XSLT 2 or 3 processor? The third argument to the key function was introduced in XSLT 2, if your XSLT processor complaints about it it is likely an XSLT 1 processor.

As for the problem, you said you need to eliminate duplicates of the country for each fund like fund11111 or fund22222, however it seems that the Registration elements or the Country elements are not structurally related to a fund as there is only a single fund element. Would it suffice to eliminate duplicates inside of each "KeyFacts" element?
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
Reply With Quote
  #12 (permalink)  
Old April 30th, 2018, 08:09 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
Default

I will check on xsl version
Is there way to check the duplicate using version 1.0
Reply With Quote
  #13 (permalink)  
Old April 30th, 2018, 08:20 AM
Friend of Wrox
Points: 6,673, Level: 34
Points: 6,673, Level: 34 Points: 6,673, Level: 34 Points: 6,673, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2007
Location: Germany
Posts: 1,242
Thanks: 0
Thanked 244 Times in 243 Posts
Default

I am currently not sure I understood the document structure last Saturday or I understand it now, that is why I asked about the "KeyFacts" elements and whether it would suffice to eliminate duplicate Registration/Country inside of each "KeyFacts".
That would be possible in XSLT 1 by using a key with
Code:
<xsl:key name="dup" match="KeyFacts/Registration" use="concat(generate-id(..), '|', Country)"/>
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog

Last edited by Martin Honnen; April 30th, 2018 at 08:53 AM..
Reply With Quote
  #14 (permalink)  
Old April 30th, 2018, 08:29 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
Default

Quote:
Originally Posted by Martin Honnen View Post
I am currently not sure I understood the document structure last Saturday or I understand it now, that is why I asked about the "KeyFacts" elements and whether it would suffice to eliminate duplicate Registration/Country inside of each "KeyFacts".
That would be possible in XSLT 1 by using a key with
Code:
<xsl:key name="dup" match="KeyFacts/Registration" use="concat(generate-id(), '|', Country)"/>
Hello Martin

The duplicate element for country code are based on Fund
Key facts does not give uniqueness of country code
Reply With Quote
  #15 (permalink)  
Old April 30th, 2018, 08:48 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
Default

I tried the code suggested but it does not remove duplicate
Reply With Quote
  #16 (permalink)  
Old April 30th, 2018, 08:55 AM
Friend of Wrox
Points: 6,673, Level: 34
Points: 6,673, Level: 34 Points: 6,673, Level: 34 Points: 6,673, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2007
Location: Germany
Posts: 1,242
Thanks: 0
Thanked 244 Times in 243 Posts
Default

I managed to omit a crucial
..
in the key definition, now edited and corrected, the code would be
Code:
  <xsl:output indent="yes"/>
  <xsl:strip-space elements="*"/>
  
  <xsl:key name="dup" match="KeyFacts/Registration" use="concat(generate-id(..), '|', Country)"/>

  <xsl:template match="@* | node()">
    <xsl:copy>
      <xsl:apply-templates select="@* | node()"/>
    </xsl:copy>
  </xsl:template>
  
  <xsl:template match="KeyFacts/Registration[not(generate-id() = generate-id(key('dup', concat(generate-id(..), '|', Country))[1]))]"/>
online at https://xsltfiddle.liberty-development.net/bFDb2BZ, that eliminates duplicates inside a "KeyFacts".

I am still not sure how "Fund" relates to that, given that the code sample you presented as the input has exactly one "Fund" and not two.
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
Reply With Quote
The Following User Says Thank You to Martin Honnen For This Useful Post:
virgosaggi (April 30th, 2018)
  #17 (permalink)  
Old April 30th, 2018, 09:12 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
Default

Hello Martin
That seem to work

The only change I made was match=“Registration” from match=“KeyFacts/Registration”

I am validating dataset

Will revert back thanks a ton again appreciate your support
Reply With Quote
  #18 (permalink)  
Old April 30th, 2018, 10:10 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
Default

Code is working as expected Martin
Many thanks again
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 in xmlnotdisplaying correct result virgosaggi XSLT 0 April 28th, 2018 10:30 AM
removing duplicate nodes nguna XSLT 6 February 16th, 2009 10:40 AM
Removing duplicate Value Row milindsaraswala Excel VBA 0 November 14th, 2007 06:11 PM
Removing the Duplicate anukagni Access 3 August 31st, 2006 12:57 AM
Avoiding Displaying duplicate data saleaf10 Classic ASP Databases 1 November 26th, 2003 10:16 PM



All times are GMT -4. The time now is 01:51 AM.


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