xsl-list
[Top] [All Lists]

Re: Sorting different date formats

2004-01-13 09:26:59
Hi Allan,
  I have come up with a sorting algorithm. Hope its
correct, and suits your requirement ;)

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
exclude-result-prefixes="msxsl">
<xsl:output method="xml" version="1.0"
encoding="UTF-8" indent="yes"/>
        
<xsl:template match="/dates">
  <xsl:variable name="RTF">
    <xsl:for-each select="endDate">
      <endDate>
        <xsl:value-of select="translate(.,'-','')"/>
      </endDate>
    </xsl:for-each>
  </xsl:variable>
                
  <xsl:for-each select="msxsl:node-set($RTF)/endDate">
     <xsl:sort select="." data-type="number"/>
     <endDate>
        <xsl:value-of select="substring(. , 1, 4 )"
/>-<xsl:value-of select="substring(. , 5, 2 )"
/>-<xsl:value-of select="substring(. , 7, 2 )" />-
     </endDate>
   </xsl:for-each>
</xsl:template>
        
</xsl:stylesheet>

Regards,
Mukul

 --- allan(_dot_)mccluskey(_at_)centrelink(_dot_)gov(_dot_)au wrote: > Hi
all,

Could someone please show me how to perform and
XSL:SORT on an date in this
format? <endDate>2004-02-15</endDate>

I have many other sorts that I need to perform so an
explantion would also
be much appreciated so I can fully understand how
you do it : )

Many thanks,
Allan






Important:  This e-mail is intended for the use of
the addressee and may contain information that is
confidential, commercially valuable or subject to
legal or parliamentary privilege.  If you are not
the intended recipient you are notified that any
review, re-transmission, disclosure, use or
dissemination of this communication is strictly
prohibited by several Commonwealth Acts of
Parliament.  If you have received this communication
in error please notify the sender immediately and
delete all copies of this transmission together with
any attachments.


 XSL-List info and archive: 
http://www.mulberrytech.com/xsl/xsl-list
 

________________________________________________________________________
Yahoo! India Mobile: Download the latest polyphonic ringtones.
Go to http://in.mobile.yahoo.com

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



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