This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
String match Revisited
- To: <xsl-list at lists dot mulberrytech dot com>
- Subject: [xsl] String match Revisited
- From: tanz at tmohammad dot fsnet dot co dot uk
- Date: Mon, 7 May 2001 15:36:45 +0100
- References: <IKEEJDFDEJLFMMIPCGFPCEGPDAAA.jarno@codeonline.com> <150125769787.20010419200456@jenitennison.com> <00ed01c0d6ee$18496e80$1322883e@d2a5i8>
- Reply-To: xsl-list at lists dot mulberrytech dot com
I have the following template, which I call in place of the
<xsl:apply-templates select="/eventsCalendar/eventRecord"/>
(see below for xml, xsl).
As a mechanism to check that:
> If the 'start month' is the same - to apply eventRecord template
> but as soon as the 'start month' differs then to apply ViewEvents template
<xsl:template name="monthMatch">
<xsl:param name="text" select="/eventsCalendar/eventRecord/start/month"
/>
<xsl:variable name="match" select="contains($text, .)" />
<xsl:choose>
<xsl:when test="$match">
<xsl:call-template name="monthMatch">
<xsl:with-param name="text"
select="substring-before($text, $match)" />
</xsl:call-template>
<xsl:apply-templates select="/eventsCalendar/eventRecord"/>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="ViewEvents"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
Can someone point out where I am going wrong.
Thanks
Tanz
----- Original Message -----
From: <tanz@tmohammad.fsnet.co.uk>
To: <xsl-list@lists.mulberrytech.com>
Sent: Monday, May 07, 2001 1:05 PM
Subject: [xsl] String match
> My xml is as follows:
> <eventsCalendar>
> <eventRecord>
> <title>Whatever</title>
> <start>
> <day>12</day>
> <month>January</month>
> <year>2002</year>
> </start>
> <end>
> <day>18</day>
> <month>January</month>
> <year>2002</year>
> </end>
> </eventRecord>
> -------
> <eventRecord>
> <title>Bla bla</title>
> <start>
> <day>05</day>
> <month>February</month>
> <year>2002</year>
> </start>
> <end>
> <day>14</day>
> <month>February</month>
> <year>2002</year>
> </end>
> </eventsCalendar>
>
> At the moment my output produces the following:
>
> January
> Title Date
> Whatever 12 January 2002 - 18 January 2002
> Blabla 05 February 2002 - 14 February 2002
>
> My xsl is as follows:
> <xsl:template name="ViewEvents">
> <table>
> <tr> <td> <xsl:value-of
> select="/eventsCalendar/eventRecord/start/month"/>
> </td></tr>
> </table>
> <table>
> <tr> <!-- deals with displaying the words Title and Date -->
> </tr>
> <xsl:apply-templates select="/eventsCalendar/eventRecord"/>
> <table>
> </template>
>
> <template match="eventRecord">
> <td> <xsl:value-of select="title"/>
> </td>
> -----
> </xsl:template>
>
> My problem is that I need the following output:
> January
> Title Date
> Whatever 12 January 2002 - 18 January 2002
> ---- <!-- containg January related events -->
>
> February
> Title Date
> Blabla 05 February 2002 - 14 February 2002
> <!-- containg February related events -->
>
> Hence a mechanism to check that:
> If the 'start month' is the same - to apply eventRecord template
> but as soon as the 'start month' differs then to apply ViewEvents template
>
> Thanks:
>
> Tanz
>
>
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
>
>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list