|
Subject: [xsl] Re: How to remove duplicate record from XML From: "Rahul Singh rahulsinghindia15@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Wed, 28 Sep 2016 18:14:05 -0000 |
I had tried with new xsl code insted of that for '*How XSL will work If we
have more then one same record in XML, ignore them and extract only rest
data. my xsl code handling only duplicate value, i need only that record
which is not duplicate or more then one*'. Below is my new XSL:
<xsl:stylesheet version="1.0" xmlns:xsl="w3.org/1999/XSL/Transform">;
<xsl:output omit-xml-declaration="yes" indent="yes"/> <xsl:strip-space
elements=""/> <xsl:key name="ccid" match="creations" use="id"/>
<xsl:template match="node() | @"> <xsl:copy> <xsl:apply-templates
select="node() | @*"/> </xsl:copy> </xsl:template> <xsl:template
match="creation[not(generate-id() = generate-id(key('ccid',
creations)[1]))]"/> </xsl:stylesheet>
Input:
<?xml version="1.0"
encoding="UTF-8"?><creations><creation><id>074</id></creation><creation><id>074</id></creation><creation><id>001</id></creation><creation><id>074</id></creation></creations>
Expected output:
<creation>
<id>001</id>
</creation>
On Wed, Sep 28, 2016 at 6:33 PM, Rahul Singh <rahulsinghindia15@xxxxxxxxx>
wrote:
> How to remove duplicate record from XML, my code is working fine, i am
> deleting duplicate, but i need only that XML which is not duplicate.
>
> *Input:*
>
> <?xml version="1.0" encoding="UTF-8"?>
> <Contact-data>
> <Contact>
> <id>074</id>
> </Contact>
> <Contact>
> <id>074</id>
> </Contact>
> * <Contact>*
> * <id>001</id>*
> * </Contact>*
> </Contact-data>
>
> *XSL:*
>
> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/
> 1999/XSL/Transform">
> <xsl:output omit-xml-declaration="yes" indent="yes"/>
> <xsl:template match="/*">
> <xsl:for-each-group select="Contact" group-by="id">
> <xsl:sequence select="."/>
> </xsl:for-each-group>
> </xsl:template>
> </xsl:stylesheet>
>
> *ExpectedOutput:*
>
> <Contact-data>
> <Contact>
> <id>001</id>
> </Contact>
> </Contact-data>
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] How to remove duplicate r, Mukul Gandhi gandhi. | Thread | Re: [xsl] Re: How to remove duplica, Martin Honnen martin |
| Re: [xsl] How to remove duplicate r, Martin Honnen martin | Date | Re: [xsl] Re: How to remove duplica, Martin Honnen martin |
| Month |