View Single Post
  #4 (permalink)  
Old May 27th, 2007, 04:13 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

ISO representation of dates is in the form YYYY-MM-DD, and times are HH:MM:SS. It's useful to use this format partly because it's an international standard, and partly because it's directly supported by the XSLT 2.0/XPath 2.0 function library when you need to compare, sort, format, or do computations on dates and times.

I'm afraid that "i have to show a single week of timetable from monday to sunday and the corresponding lessons for each day" doesn't give me enough to work with. A timetable for a course? For a student? For a room? What are the rows, what are the columns, and what goes in the cells?

Your input format uses time spans like:

       <starts startTimeRef="s3"/>
       <ends endTimeRef="e5"/>

One way to tackle this is to ignore the actual times that this represents and just translate it into a block that covers period 3, 4, and 5. In XSLT 2.0 that's

<xsl:variable name="periods" select="xs:integer(substring(starts/@startTimeRef,2,1)) to xs:integer(substring(ends/@endTimeRef,2,1))"/>

When you're writing the cell for period $N on a Monday, you can then enter a particular allocation $a in the cell if $a/../@dayOfWeek = 'Monday' and $a/(xs:integer(substring(starts/@startTimeRef,2,1)) to xs:integer(substring(ends/@endTimeRef,2,1))) = $N. (Remember that "=" tests for membership of a set).

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