|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Building a calendar
At 99/09/01 10:21 -0400, Richard Lander wrote:
I'd like to build a calendar, a table really, by processing a set of events. My That's the way I thought of doing it. I have looked at Oren Ben-Kiki's queens.xsl to see if I could find any other ideas. I see that he uses recursion to build his tables. That's the way to do "loops" ... because there are no global (varying) variables, one must walk through a template as many times as desired. It seemed to work for me ... an example is below using XT-19990822. I hope this helps. ........ Ken p.s. since there is ambiguity between Tuesday/Thursday and Saturday/Sunday using a letter for the day of the week, I'm using a number to start the month with Sunday="1" p.p.s. I didn't include the generated HTML because it screws up mailers
<xsl:output method="html"/> <xsl:template match="/"> <!--root rule--> <xsl:apply-templates select="CALENDAR"/> <!--restrict instances--> </xsl:template> <xsl:template match="CALENDAR"> <!--each month belongs in a table-->
<html>
<xsl:for-each select="MONTH">
<table border="1" valign="top">
<xsl:call-template name="doweek">
<xsl:with-param name="start" select="@start - 1"/>
<xsl:with-param name="end" select="@end"/>
</xsl:call-template>
</table>
</xsl:for-each>
</html>
</xsl:template><xsl:template name="doweek"> <!--each week belongs in a row-->
<xsl:param name="start" select="0"/>
<xsl:param name="end"/>
<xsl:param name="day" select="1"/>
<xsl:if test="$day <= $end">
<tr valign="top">
<xsl:call-template name="doday">
<xsl:with-param name="day" select="$day"/>
<xsl:with-param name="start" select="$start"/>
<xsl:with-param name="end" select="$end"/>
</xsl:call-template>
</tr>
<xsl:call-template name="doweek">
<xsl:with-param name="day" select="$day+7-$start"/>
<xsl:with-param name="end" select="$end"/>
</xsl:call-template>
</xsl:if>
</xsl:template><xsl:template name="doday"> <!--each day belongs in a column-->
<xsl:param name="start" select="0"/> <!--only def'd first time-->
<xsl:param name="end"/>
<xsl:param name="day"/>
<xsl:param name="weekday" select="7"/>
<xsl:choose>
<xsl:when test="$start>0"> <!--not started days yet-->
<td>
</td>
<xsl:call-template name="doday">
<xsl:with-param name="start" select="$start - 1"/>
<xsl:with-param name="end" select="$end"/>
<xsl:with-param name="day" select="$day"/>
<xsl:with-param name="weekday" select="$weekday - 1"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise> <!--a typical day of the week-->
<td>
<b><xsl:value-of select="substring('SFTWTMS', $weekday, 1)"
/><xsl:text> </xsl:text><xsl:value-of select="$day"/>:</b><br/>
<xsl:for-each select=".//EVENT[@date=$day]">
<p><i><xsl:value-of select="position()"/>: </i>
<xsl:value-of select="PARA[1]"/></p>
<xsl:for-each select="PARA[position()>1]">
<p><xsl:value-of select="."/></p>
</xsl:for-each>
</xsl:for-each>
</td>
<xsl:if test="$weekday > 1 and $day < $end">
<xsl:call-template name="doday">
<xsl:with-param name="end" select="$end"/>
<xsl:with-param name="day" select="$day+1"/>
<xsl:with-param name="weekday" select="$weekday - 1"/>
</xsl:call-template>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:template></xsl:stylesheet> T:\lander>call xsl test.xml test.xsl test.htm T:\lander>dir test.htm Volume in drive T has no label Volume Serial Number is 3550-B22A Directory of T:\lander TEST HTM 2 554 99-09-01 12:49 test.htm
1 file(s) 2 554 bytes
0 dir(s) 196 673 536 bytes freeT:\lander> -- G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (Fax:-0995) Website: XSL/XML/DSSSL/SGML services, training, libraries, products. Practical Transformation Using XSLT and XPath ISBN 1-894049-01-2 Next instructor-led training: MT'99 1999-12-05/06 XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








