 |
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
|
|
|

April 30th, 2018, 07:56 AM
|
Friend of Wrox
|
|
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
|
|
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
|

April 30th, 2018, 08:09 AM
|
Authorized User
|
|
Join Date: Apr 2018
Posts: 16
Thanks: 3
Thanked 0 Times in 0 Posts
|
|
I will check on xsl version
Is there way to check the duplicate using version 1.0
|

April 30th, 2018, 08:20 AM
|
Friend of Wrox
|
|
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
|
|
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..
|

April 30th, 2018, 08:29 AM
|
Authorized User
|
|
Join Date: Apr 2018
Posts: 16
Thanks: 3
Thanked 0 Times in 0 Posts
|
|
Quote:
Originally Posted by Martin Honnen
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
|

April 30th, 2018, 08:48 AM
|
Authorized User
|
|
Join Date: Apr 2018
Posts: 16
Thanks: 3
Thanked 0 Times in 0 Posts
|
|
I tried the code suggested but it does not remove duplicate
|

April 30th, 2018, 08:55 AM
|
Friend of Wrox
|
|
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
|
|
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:
|
|

April 30th, 2018, 09:12 AM
|
Authorized User
|
|
Join Date: Apr 2018
Posts: 16
Thanks: 3
Thanked 0 Times in 0 Posts
|
|
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
|

April 30th, 2018, 10:10 AM
|
Authorized User
|
|
Join Date: Apr 2018
Posts: 16
Thanks: 3
Thanked 0 Times in 0 Posts
|
|
Code is working as expected Martin
Many thanks again
|
|
 |