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

RE: [xsl] TIME-PROG


Subject: RE: [xsl] TIME-PROG
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Mon, 4 Mar 2002 17:50:14 -0000

> I want the out put to be classified according to the logic that
> programs shown  between 6:00 am and 3:00pm are to be shown on the
> first half of the HTML page  and the program shown after 3:00 pm
> to morning 6:00 am should be shown on the second half of the
> page..

Select groups as appropriate:

<first-half-of-page>
  <xsl:apply-templates
     select="prog[((substring-before(time, ':') +
                  translate('pm', 'apm', '06')*2 +
                  18) mod 24) &lt;= 9]"/>
</first-half-of-page>
<second-half-of-page>
  <xsl:apply-templates
     select="prog[((substring-before(time, ':') +
                  translate(ampm, 'apm', '06')*2 +
                  18) mod 24) &gt; 9]"/>
</second-half-of-page>

This works as follows:
First calculate a normalized time
hour = substring-before(time, ':') + (if pm then 12 else 0)

Get the hours into line:
xhour = (hour + 18) mod 24

The use of translate() is completely wacky, but XPath 1.0 has no conditional
expression so such horrible tricks are quite handy. It turns "am" into "0"
and "pm" into 6, then multiplies by 2.

not tested.

Michael Kay
Software AG
home: Michael.H.Kay@xxxxxxxxxxxx
work: Michael.Kay@xxxxxxxxxxxxxx
>
> example : this should be the output
>
> 03:00 am - morning prog1
> 07:00 am - morning prog5
>
> <hr></hr>
>
> 5:30 pm evening prog6
> 6:00 pm evening prog2
> 10:00 pm evening prog3
> 12:30 pm evening prog4
>
> Also note that the output programs are in the increasing order of
> the time..
>
> Can someone help me regarding how i can solve this problem????
>
> Many Thanks
>
>
>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>


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



Current Thread
Keywords