This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: XSL month sorting (chronologically)
- From: "murli bk" <bkmurali at hotmail dot com>
- To: XSL-List at lists dot mulberrytech dot com
- Date: Fri, 12 Apr 2002 12:11:52
- Subject: Re: [xsl] XSL month sorting (chronologically)
- Reply-to: xsl-list at lists dot mulberrytech dot com
Hi,
I tried out Michael's suggestion using string-length. I am getting
"Whitespace required before attributes" exception. What could be the
problem.
The sorting is done first on the year, then on the month and then on the
day.
The xml file I use is
<?xml version="1.0" encoding="UTF-8"?>
<eventlog>
<event>
<date>10 Apr 2002</date>
<data>Test5</data>
</event>
<event>
<date>14 Apr 2001</date>
<data>Test1</data>
</event>
<event>
<date>09 Mar 2002</date>
<data>Test4</data>
</event>
<event>
<date>08 Mar 2003</date>
<data>Test6</data>
</event>
<event>
<date>01 Jan 2002</date>
<data>Test2</data>
</event>
<event>
<date>11 Feb 2002</date>
<data>Test3</data>
</event>
</eventlog>
The xsl script(which gives a html output) I used is
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<HTML>
<HEAD>
<TITLE>
<xsl:for-each select="eventlog">
</xsl:for-each>
MURALI'S MAGIC
</TITLE>
</HEAD>
<BODY>
<H3 ALIGN="CENTRE">
EventLog Information
</H3>
<xsl:for-each select="eventlog">
<TABLE border="1">
<THEAD>
<TR>
<TH>Date</TH>
<TH>Data</TH>
</TR>
</THEAD>
<TBODY>
<xsl:for-each select="event">
<xsl:sort select="substring(date, 8, 4)" data-type="number" />
<xsl:sort
select="string-length(substring-before("JanFebMarAprMayJunJulAugSepOctNovDec",
substring("date",4,3))" data-type="number" />
<xsl:sort select="substring(date, 1, 2)" data-type="number" />
<TR>
<TD><xsl:value-of select="date"/></TD>
<TD><xsl:value-of select="data"/></TD>
</TR>
</xsl:for-each>
</TBODY>
</TABLE>
</xsl:for-each>
</BODY>
</HTML>
</xsl:template>
</xsl:stylesheet>
_________________________________________________________________
Join the world’s largest e-mail service with MSN Hotmail.
http://www.hotmail.com
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list