|
Subject: [xsl] How to sort and compare with different element value in XSL From: "Rahul Singh rahulsinghindia15@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Fri, 9 Sep 2016 09:25:20 -0000 |
I have only one XML. and there <Nid> contains same data like 892828740. I
want get the Id,LastModifiedDate,Nid for Contact based on updated
LastModifiedDate if <Nid> has more then one same kind of data. Below is my
Input data, XSL, expected output. But my code is not working fine
Below is XML:
<?xml version="1.0" encoding="UTF-8"?>
<objects>
<Contact>
<Id>003j000001DQMkcAAH</Id>
<LastModifiedDate>2016-09-08T10:31:24.000Z</LastModifiedDate>
<Nid>892828740</Nid>
</Contact>
<Contact>
<Id>003j000001DQMlXAAX</Id>
<LastModifiedDate>2016-09-08T10:22:47.000Z</LastModifiedDate>
<Nid>879284114</Nid>
</Contact>
<Contact>
<Id>003j000001DQMlYAAX</Id>
<LastModifiedDate>2016-09-08T10:22:47.000Z</LastModifiedDate>
<Nid>882692370</Nid>
</Contact>
<Contact>
<Id>003j000001DQMlZAAX</Id>
<LastModifiedDate>2016-09-08T10:22:47.000Z</LastModifiedDate>
<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>
<LastModifiedDate>
<xsl:value-of select="//LastModifiedDate"/>
</LastModifiedDate>
<Nid/>
</Nid>
</Nids>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
Expected output:
<objects>
<Contact>
<Id>003j000001DQMkcAAH</Id>
<LastModifiedDate>2016-09-08T10:31:24.000Z</LastModifiedDate>
<Nid>892828740</Nid>
</Contact>
<Contact>
<Id>003j000001DQMlXAAX</Id>
<LastModifiedDate>2016-09-08T10:22:47.000Z</LastModifiedDate>
<Nid>879284114</Nid>
</Contact>
<Contact>
<Id>003j000001DQMlYAAX</Id>
<LastModifiedDate>2016-09-08T10:22:47.000Z</LastModifiedDate>
<Nid>882692370</Nid>
</Contact>
</objects>
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [xsl] "Tuple types, and type aliase, Dimitre Novatchev dn | Thread | Re: [xsl] How to sort and compare w, Martin Honnen martin |
| [xsl] "Tuple types, and type aliase, Dimitre Novatchev dn | Date | Re: [xsl] How to sort and compare w, Martin Honnen martin |
| Month |