This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: XSL month sorting (chronologically)


You need to use different quotes inside the attribute: change
        <xsl:sort
select="string-length(substring-before("JanFebMarAprMayJunJulAugSepOctNovDec
",
substring("date",4,3))"  data-type="number" />

to

        <xsl:sort
select="string-length(substring-before('JanFebMarAprMayJunJulAugSepOctNovDec
',
substring(date,4,3))"  data-type="number" />

note also the removal of quotes around "date".

Michael Kay
Software AG
home: Michael.H.Kay@ntlworld.com
work: Michael.Kay@softwareag.com

> -----Original Message-----
> From: owner-xsl-list@lists.mulberrytech.com
> [mailto:owner-xsl-list@lists.mulberrytech.com]On Behalf Of murli bk
> Sent: 12 April 2002 12:12
> To: XSL-List@lists.mulberrytech.com
> Subject: Re: [xsl] XSL month sorting (chronologically)
>
>
> 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("JanFebMarAprMayJunJulA
> ugSepOctNovDec",
> 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
>


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]