xsl-list
[Top] [All Lists]

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

2016-09-09 04:38:09
On 09.09.2016 11:25, Rahul Singh rahulsinghindia15(_at_)gmail(_dot_)com 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>
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>