This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

How to create XSL for CALENDAR/MONTH layout?


I have a calendar that displays 12 months of a year.  Currently, all 12
months display across the page as one row.  Instead, I'd like to arrange
them a 3 rows with 4 months in each row.  Any ideas how to do this: <tr>4
MONTHS HERE</tr>?

The XML looks like this:

<CALENDAR>
 <YEAR>2000</YEAR>
 <MONTH>
  <MONTHNAME>January</MONTHNAME>
  <WEEK>
   <WEEKNUMBER>1</WEEKNUMBER>
   <DAY>1</DAY>
   <DAY>2</DAY>
   <DAY>3</DAY>
   <DAY>4</DAY>
   <DAY>5</DAY>
   <DAY>6</DAY>
   <DAY>7</DAY>
  </WEEK>
 </MONTH>
</CALENDAR>

The XSL looks like this:

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="html"/>

<xsl:template match="*|/"><xsl:apply-templates/></xsl:template>

<xsl:template match="text()|@*"><xsl:value-of select="."/></xsl:template>

<xsl:template match="/">
<HTML style="">
 <HEAD style="">
  <TITLE style="">Year View</TITLE>
  <LINK style="" href="calendar.css" rel="stylesheet"/>
 </HEAD>
 <BODY style="">
  <TABLE style="" cellSpacing="0" cellPadding="0" width="597" align="left"
border="0">
  <TBODY style="">
   <xsl:apply-templates/>
  </TBODY>
  </TABLE>
 </BODY>
</HTML>
</xsl:template>

<xsl:template match="CALENDAR">
<tr>
 <xsl:apply-templates select="MONTH"/>
</tr>
</xsl:template>

<xsl:template match="MONTH">
 <td>
  <table cellspacing="0" cellpadding="0" width="162" border="0">
  <tbody>
   <tr>
    <td><img src="c:\spacer_white.gif" width="2"></img></td>
    <td align="middle" bgcolor="#000066">
     <table cellspacing="0" cellpadding="0" width="158"
background="c:\stripes.gif" border="0">
     <tbody>
      <tr falign="middle" background="c:\stripes.gif">
       <td class="calTextWhite" height="22" width="100%" align="center">
        <xsl:value-of select="MONTHNAME"/>
       </td>
      </tr>
     </tbody>
     </table>
    </td>
   </tr>
   <tr>
    <td><img src="c:\spacer_white.gif" width="2"></img></td>
    <td>
     <table cellspacing="0" cellpadding="0" width="158" bgcolor="#ffffff"
border="0">
     <tbody>
      <tr>
       <td class="calTextBlack" align="middle">M</td>
       <td class="calTextBlack" align="middle">Tu</td>
       <td class="calTextBlack" align="middle">W</td>
       <td class="calTextBlack" align="middle">Th</td>
       <td class="calTextBlack" align="middle">F</td>
       <td class="calTextBlack" align="middle">Sa</td>
       <td class="calTextBlack" align="middle">Su</td>
      </tr>
      <xsl:apply-templates select="WEEK"/>
     </tbody>
     </table>
    </td>
   </tr>
  </tbody>
  </table>
 </td>
</xsl:template>

<xsl:template match="WEEK">
 <tr>
  <xsl:apply-templates select="DAY"/>
 </tr>
</xsl:template>

<xsl:template match="DAY">
 <td class="calText" align="middle">
  <xsl:value-of select="DAYNUMBER"/>
 </td>
</xsl:template>

</xsl:stylesheet>

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]