I'm having a problem with XSLT V1.0 with removing the duplicated nodes. I have this for entry
<?xml version="1.0" encoding="utf-8"?>
<myRoot xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Mappings>
<Mapping fieldName="field1" >
</Mapping>
<Mapping fieldName="field1">
</Mapping>
<Mapping fieldName="field2" >
</Mapping>
<Mapping fieldName="field3" >
</Mapping>
<Mapping fieldName="field4">
</Mapping>
</Mappings>
</myRoot>
I have this XSL file
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="utf-8" indent="yes"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="Mappings">
<xsl:if test="not(following::Mappings[Mapping/@fieldName=current()/Mapping/@fieldName])">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
And I have the same entry XML file as result !!
How can I get rid of duplicated node () ?
I tried everything and no result :(
I tried Removing duplicates in xml with xslt Transform to remove duplicate and copy rest Removing consecutive duplicates with XSLT XSLT 1.0 textlist to individual elements and duplicate removal
......
What should I do to have this result ??
<?xml version="1.0" encoding="utf-8"?>
<myRoot xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Mappings>
<Mapping fieldName="field1">
</Mapping>
<Mapping fieldName="field2" >
</Mapping>
<Mapping fieldName="field3" >
</Mapping>
<Mapping fieldName="field4">
</Mapping>
</Mappings>
</myRoot>
Thanks