[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Selecting the Latest Date


Subject: Re: [xsl] Selecting the Latest Date
From: Mukul Gandhi <gandhi.mukul@xxxxxxxxx>
Date: Wed, 8 Feb 2006 09:40:24 +0530

You may try something like this

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">

<xsl:output method="text" />

<xsl:template match="/data">
  <xsl:for-each select="items/date">
    <xsl:sort select="translate(., '.', '')" order="descending"
data-type="number" />
    <xsl:if test="position() = 1">
      <xsl:value-of select="." />
    </xsl:if>
  </xsl:for-each>
</xsl:template>

</xsl:stylesheet>

Regards,
Mukul

On 2/8/06, jeb501@xxxxxxxxxxxxxxx <jeb501@xxxxxxxxxxxxxxx> wrote:
> Hi all,
>
> From the below XML file how to pick the late date from date node..
>
>  <?xml version="1.0" encoding="Windows-1252" standalone="yes" ?>
>    - <data>
>      - <items>
>         <ref>28834</ref>
>         <pdate>01.02.2006</pdate>
>         <qty>5</qty>
>         <clno>ax588</clno>
>         <date>01.02.2006</date>
>         <clrf>Normal 1</clrf>
>         <clno>bx588</clno>
>         <date>03.02.2006</date>
>         <clrf>Normal 2</clrf>
>         <clno>bx588</clno>
>         <date>06.02.2006</date>
>         <clrf>Normal 3</clrf>
>     </items>
>   </data>
>
>  Regards
>  Eugene


Current Thread
Keywords
xml