[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: XSL month sorting (chronologically)

Subject: Re: XSL month sorting (chronologically)
From: "murli bk" <bkmurali@xxxxxxxxxxx>
Date: Fri, 12 Apr 2002 12:11:52
bk murli
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



Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.