View Single Post
  #6 (permalink)  
Old May 27th, 2007, 06:02 PM
mhkay's Avatar
mhkay mhkay is offline
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts

I'm no HTML expert so I have to guess what the HTML code for that looks like: presumably what you have to do is along the lines

for-each time-slot
     for-each day-of-the-week
          if there's a session starting at this time/day
          then <td rowspan="length of session">
               apply-templates select="session"
          else if there's a session continuing at this time./day
          then ()
          else <td/>

which seems to translate into code something like the following. Im going to assume for simplification that the start and end times are labelled by numbers 1,2,3 rather than strings s1,s2, e1, e2:

<xsl:for-each select="startTime/st">
  <xsl:variable name="st" select="."/>
    <td><xsl:value-of select="."/></td>
    <xsl:for-each select="week[1]/day">
      <xsl:when test="allocation/starts[@startTimeRef=$st]">
         <xsl:variable name="alloc" select="allocation/starts[@startTimeRef=$st]"/>
         <xsl:variable name="length" select="$alloc/ends/@endTimeRef - $alloc/starts/@startTimeRef + 1"/>
         <td rowspan="{$length}">
            <xsl:apply-templates select="$alloc"/>
       <xsl:when test="alllocation[starts/@startTimeRef lt $st and ends/@endTimeRef ge $st]"/>

Michael Kay
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote