This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: RE: URGENT!!PROG-TIME
- From: "William Rutford" <vsd18 at rediffmail dot com>
- To: xsl-list at lists dot mulberrytech dot com
- Date: 4 Mar 2002 20:51:10 -0000
- Subject: Re: RE: [xsl] URGENT!!PROG-TIME
- Reply-to: xsl-list at lists dot mulberrytech dot com
That was beautiful Jeff.
Thanks for that.
Bill
On Tue, 05 Mar 2002 Jeff Beadle wrote :
>Hey William,
>
>This will get you the ordering you want:
>
><xsl:template match="programs">
> <xsl:for-each select="program">
> <xsl:sort data-type="text" select="ampm"/>
> <xsl:sort data-type="text" select="time"/>
> <xsl:copy-of select="."/>
> </xsl:for-each>
></xsl:template>
>
>
>You could turn this into called templates, one for the
>first half of the day and one for the other.
>
>This approach is fairly specific to your use case:
>
><xsl:template match="/">
>
> First half:
> <xsl:call-template name="first-half-of-day">
> <xsl:with-param name="programs" select="//programs"/>
> </xsl:call-template>
>
> Second half:
> <xsl:call-template name="second-half-of-day">
> <xsl:with-param name="programs" select="//programs"/>
> </xsl:call-template>
></xsl:template>
>
><xsl:template name="first-half-of-day">
> <xsl:param name="programs"/>
> <xsl:for-each select="msxsl:node-set($programs)/program">
> <xsl:sort data-type="text" select="ampm"/>
> <xsl:sort data-type="text" select="time"/>
> <xsl:variable name="dt">
> <xsl:call-template name="GetDateTime">
> <xsl:with-param name="program" select="."/>
> </xsl:call-template>
> </xsl:variable>
> <xsl:if test="(600 <= number($dt)) and (number($dt) <
>1500)">
> <xsl:copy-of select="."/>
> </xsl:if>
> </xsl:for-each>
></xsl:template>
>
><xsl:template name="second-half-of-day">
> <xsl:param name="programs"/>
> <xsl:for-each select="msxsl:node-set($programs)/program">
> <xsl:sort data-type="text" select="ampm"/>
> <xsl:sort data-type="text" select="time"/>
> <xsl:variable name="dt">
> <xsl:call-template name="GetDateTime">
> <xsl:with-param name="program" select="."/>
> </xsl:call-template>
> </xsl:variable>
> <xsl:if test="(1500 <= number($dt)) or (number($dt) <
>600)">
> <xsl:copy-of select="."/>
> </xsl:if>
> </xsl:for-each>
></xsl:template>
>
><xsl:template name="GetDateTime">
> <xsl:param name="program"/>
> <xsl:variable name="dt">
> <xsl:for-each select="msxsl:node-set($program)">
> <dt>
> <xsl:value-of select="translate(time,':','')"/>
> </dt>
> <dt>
> <xsl:choose>
> <xsl:when test="'am'=ampm">0</xsl:when>
> <xsl:otherwise>
> <xsl:choose>
> <xsl:when
> test="substring-before(time,':') !=
>'12'">1200</xsl:when>
>
><xsl:otherwise>0</xsl:otherwise>
> </xsl:choose>
> </xsl:otherwise>
> </xsl:choose>
> </dt>
> </xsl:for-each>
> </xsl:variable>
> <xsl:value-of select="sum(msxsl:node-set($dt)//dt)"/>
></xsl:template>
>
>
>hope this helps,
>Jeff
>
>
>-----Original Message-----
> From: William Rutford [mailto:vsd18@rediffmail.com]
>Sent: Monday, March 04, 2002 2:06 PM
>To: xsl-list@lists.mulberrytech.com
>Subject: [xsl] URGENT!!PROG-TIME
>
>
>I am still not able to crack the problem..
>here is the problem..
>SOMEBODY PLEASE HELP!!
>
>hi i have a problem i am not able to crack!!
>
>I have an xml file that looks like this
>
><programs>
><program id = '1'>
> <time>06:00</time>
> <ampm>pm</ampm>
> <title>Prog at 6 pm</title>
></program>
><program id = '2'>
> <time>07:00</time>
> <ampm>am</ampm>
> <title>Prog at 7 am</title>
></program>
><program id = '3'>
> <time>09:30</time>
> <ampm>pm</ampm>
> <title>Prog at 9:30 pm</title>
></program>
><program id = '4'>
> <time>10:00</time>
> <ampm>am</ampm>
> <title>Prog at 10 am</title>
></program>
></programs>
>I am required to arrainge this data in an HTML file in such a
>way
>that the programs between 06:00am to 3:00 pm is placed in the
>first half of the HTML page and the programs between 3:00pm and
>6:00am are placed in the second half of the page.
>and these times in the xml file is not ordered.. so when
>arrainging them in HTML, it should also be seen that it is done
>in
>chronological order..
>
>example out put html looks like this:
>
>07:00am: Program at 7 am
>10:00am: Program at 10 am
>
>
>06:00pm: Program at 6 pm
>09:30am: Program at 9:30am
>
>
>to add to the problem, the only way to check the time is
>through
>the combination of the <time> and <ampm>..
>
>I am really not able to crack this down.Can somebody help me??
>
>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
>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list