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

RE: TIME-PROG

Subject: RE: TIME-PROG
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Mon, 4 Mar 2002 17:50:14 -0000
time prog
> 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

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.