Re: [xsl] How to sort and compare with different element value in XSL

Subject: Re: [xsl] How to sort and compare with different element value in XSL
From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 9 Sep 2016 09:38:04 -0000
On 09.09.2016 11:25, Rahul Singh rahulsinghindia15@xxxxxxxxx wrote:
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

Here is an enhancement of the stylesheet David posted after your last question:


<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:xs="http://www.w3.org/2001/XMLSchema";>

<xsl:output method="xml" indent="yes" omit-xml-declaration="no"/>

<xsl:strip-space elements="*"/>

<xsl:template match="objects">
<xsl:copy>
<xsl:for-each-group select="Contact" group-by="Nid">
<xsl:for-each select="current-group()">
<xsl:sort select="xs:dateTime(LastModifiedDate)" order="descending"/>
<xsl:if test="position() eq 1">
<xsl:copy-of select="."/>
</xsl:if>
</xsl:for-each>
</xsl:for-each-group>
</xsl:copy>
</xsl:template>

</xsl:stylesheet>


Current Thread