[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Building a calendar
Ken, Wow! You just saved me a lot of trouble. I changed the XSL a little to match my intentions a bit more. I'm going to change it further to make it work with my broader system. I'll probably make it emit my XML TABLE model or simply use the HTML namespace. Either way, it will work wonderfully. I've attached my slightly changed instance and the XSL. The calendar was the only part of my Profesional XML Authoring course that was hindering me from delivering it all in XML. The September offering should be all-XML. Sounds good to me! Thanks again (wow!), Richard. Richard Lander rlander at on-line-learning.com http://pdbeam.uwaterloo.ca/~rlander/ Professional XML Authoring http://www.on-line-learning.com/ <?xml version="1.0"?> <CALENDAR> <MONTH start="4" end="30"> <!-- start is the day of the week that the month starts. Wednesday in this case --> <TITLE>September 1999</TITLE> <EVENT date="4"> <PARA>Some event description</PARA> </EVENT> <EVENT date="24"> <PARA>another event description</PARA> </EVENT> <!--Lots of time for vacation this month! --> </MONTH> <MONTH start="6" end="31"> <TITLE>October 1999</TITLE> <EVENT date="5"> <PARA>Some event description</PARA> <PARA>Second para of description</PARA> </EVENT> <EVENT date="17"> <PARA>first event description</PARA> </EVENT> <EVENT date="17"> <PARA>second event description</PARA> </EVENT> </MONTH> <!--May be more MONTHs --> </CALENDAR> <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/XSL/Transform/1.0"> <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> <head> <!-- <link rel="stylesheet" type="text/css" href="e:\pxa\sheets\course.css"/> --> <style type="text/css"> .CALENDARTITLE {font-family:Arial,Helvetica;font-size:23pt;text-align:center;background:gray;color:black;} .CDATE {display:block;font-size:12pt;margin-left:0pt;} .CTEXT {display:block;font-size:10pt;margin-left:0pt;} .Weekday {font-family:Arial,Helvetica; font-size:12pt; font-weight:bold; color:black; text-align:center;background:lightgrey;} </style> </head> <xsl:for-each select="MONTH"> <xsl:apply-templates select="TITLE"/> <table border="1" valign="top" width="75%" align="center"> <colgroup> <col width="14%" span="7"/> </colgroup> <tr class="Weekday"> <td>Sunday</td><td>Monday</td><td>Tuesday</td><td>Wednesday</td> <td>Thursday</td><td>Friday</td><td>Saturday</td> </tr> <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 height="87"> <DIV class="CDATE"><xsl:value-of select="$day"/></DIV> <!-- <b><xsl:value-of select="substring('SFTWTMS', $weekday, 1)"/><xsl:text> </xsl:text> --> <xsl:for-each select=".//EVENT[@date=$day]"> <p class="CTEXT"><xsl:value-of select="position()"/>: <xsl:value-of select="PARA[1]"/></p> <xsl:for-each select="PARA[position()>1]"> <P class="CTEXT"><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:template match="TITLE"> <table width="75%" align="center"> <tr><td> <DIV class="CALENDARTITLE"> <xsl:apply-templates/> </DIV></td></tr> </table> </xsl:template> </xsl:stylesheet>
|
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
|