I am trying to create a calendar display of one month. I am having trouble starting and ending a row based on a condition (using xsl:if). My condition works but it doesn't seem to like not having a starting and ending tag between EACH condition. For example:
<xsl:for-each select="root/cal">
<xsl:choose>
<xsl:when test="@dayofweek='1'"> first day of the week
<tr> start new row with a date in the first element
<td><xsl:value-of select="@daynumber"/></td>
</xsl:when>
<xsltherwise>
<tr> start new row with blank first element
<td></td>
</xsltherwise>
</xsl:choose>
repeat for @daynumber is 2 through 6 without the
starting table row tag
<xsl:choose>
<xsl:when test="@dayofweek='7'"> last day of the week
<td><xsl:value-of select="@daynumber"/></td>
</tr> end the row
</xsl:when>
<xsltherwise>
<td></td>
</tr> end the row
</xsltherwise>
</xsl:choose>
</xsl:for-each>
If I add a matching tag between each condition it works but of course does not look like a calendar!
My XML data looks like this:
<root>
<cal dayofweek="6" daylabel="1" fulldate="11/1/2002"/>
<cal dayofweek="7" daylabel="2" fulldate="11/2/2002"/>
<cal dayofweek="1" daylabel="3" fulldate="11/3/2002"/>
<cal ........ etc..... />
</root>
<xsl:for-each select="root/cal">
<xsl:choose>
<xsl:when test="@dayofweek='1'"> first day of the week
<tr> start new row with a date in the first element
<td><xsl:value-of select="@daynumber"/></td>
</xsl:when>
<xsltherwise>
<tr> start new row with blank first element
<td></td>
</xsltherwise>
</xsl:choose>
repeat for @daynumber is 2 through 6 without the
starting table row tag
<xsl:choose>
<xsl:when test="@dayofweek='7'"> last day of the week
<td><xsl:value-of select="@daynumber"/></td>
</tr> end the row
</xsl:when>
<xsltherwise>
<td></td>
</tr> end the row
</xsltherwise>
</xsl:choose>
</xsl:for-each>
If I add a matching tag between each condition it works but of course does not look like a calendar!
My XML data looks like this:
<root>
<cal dayofweek="6" daylabel="1" fulldate="11/1/2002"/>
<cal dayofweek="7" daylabel="2" fulldate="11/2/2002"/>
<cal dayofweek="1" daylabel="3" fulldate="11/3/2002"/>
<cal ........ etc..... />
</root>