|
Subject: [xsl] Need xsl help From: "Rahul Singh rahulsinghindia15@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Thu, 8 Sep 2016 18:07:55 -0000 |
Hi.
I have only one XML. and there <Nid> contains same data like 892828740. I
want get the Id,Updateeddate,Nid for Contact based on Updateeddate if Nid
has more then one same data. Below is my input, XSL, expected output
Below is XML:
<?xml version="1.0" encoding="UTF-8"?>
<objects>
<Contact>
<Id>003j000001DQMkcAAH</Id>
<Updateeddate>2016-09-08T10:31:24.000Z</Updateeddate>
<Nid>892828740</Nid>
</Contact>
<Contact>
<Id>003j000001DQMlXAAX</Id>
<Updateeddate>2016-09-08T10:22:47.000Z</Updateeddate>
<Nid>879284114</Nid>
</Contact>
<Contact>
<Id>003j000001DQMlYAAX</Id>
<Updateeddate>2016-09-08T10:22:47.000Z</Updateeddate>
<Nid>882692370</Nid>
</Contact>
<Contact>
<Id>003j000001DQMlZAAX</Id>
<Updateeddate>2016-09-08T10:22:47.000Z</Updateeddate>
<Nid>892828740</Nid>
</Contact>
</objects>
Below in XSL:
<xsl:stylesheet version="2.0" xmlns:xsl="
http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="objects">
<xsl:if test="count(//Contact/Nid[(. =
../following-sibling::Contact/Nid)])">
<Nids>
<Nid>
<Id>
<xsl:value-of
select="//Contact/Nid[(. =
../following-sibling::Contact/Nid)]"/>
</Id>
<updateDate>
<xsl:value-of select="//Updateeddate"/>
</updateDate>
<Nid/>
</Nid>
</Nids>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
Expected output:
<objects>
<Contact>
<Id>003j000001DQMkcAAH</Id>
<Updateeddate>2016-09-08T10:31:24.000Z</Updateeddate>
<Nid>892828740</Nid>
</Contact>
<Contact>
<Id>003j000001DQMlXAAX</Id>
<Updateeddate>2016-09-08T10:22:47.000Z</Updateeddate>
<Nid>879284114</Nid>
</Contact>
<Contact>
<Id>003j000001DQMlYAAX</Id>
<Updateeddate>2016-09-08T10:22:47.000Z</Updateeddate>
<Nid>882692370</Nid>
</Contact>
</objects>
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [xsl] Fw(3): s1, Cleyton Jordan cleyt | Thread | Re: [xsl] Need xsl help, David Carlisle d.p.c |
| Re: [xsl] How to find out if Xml co, Vasu Chakkera vchakk | Date | Re: [xsl] Need xsl help, David Carlisle d.p.c |
| Month |