Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 30th, 2018, 07:56 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 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
 
Old April 30th, 2018, 08:09 AM
Authorized User
 
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
 
Old April 30th, 2018, 08:20 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 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..
 
Old April 30th, 2018, 08:29 AM
Authorized User
 
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
 
Old April 30th, 2018, 08:48 AM
Authorized User
 
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
 
Old April 30th, 2018, 08:55 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 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
The Following User Says Thank You to Martin Honnen For This Useful Post:
virgosaggi (April 30th, 2018)
 
Old April 30th, 2018, 09:12 AM
Authorized User
 
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
 
Old April 30th, 2018, 10:10 AM
Authorized User
 
Join Date: Apr 2018
Posts: 16
Thanks: 3
Thanked 0 Times in 0 Posts
Default

Code is working as expected Martin
Many thanks again





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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.