Need help in transforming xml to xsl. I am trying to create a timetable and am trying to transform the xml data that i have into an xsl data.

<Timetable>
<Week>

<Day DayID = "Monday"></Day>

<Day DayID = "Tuesday">
<Session no = "1">
<Module type = "CMT111">
<ModuleName> CPM </ModuleName>
</Module>
<Time>9.00am-10.59am</Time>
<Room>222</Room>
</Session>

<Session no = "2">
<Module type = "CMT213">
<ModuleName> Software </ModuleName>
</Module>
<Time>2.00pm-3.59pm</Time>
<Room>316</Room>
</Session>

<Session no = "3">
<Module type = "CMT213">
<ModuleName> Software </ModuleName>
</Module>
<Time>4.30pm-5.29pm</Time>
<Room>67</Room>
</Session>
</Day>

<Day DayID = "Wednesday">
<Session no = "4">
<Module type = "ACC33">
<ModuleName> ACC </ModuleName>
</Module>
<Time>10.00am-11.59am</Time>
<Room>065</Room>
</Session>

<Session no = "5">
<Module type = "TP213">
<ModuleName> trial </ModuleName>
</Module>
<Time>1.00pm-1.59pm</Time>
<Room>316</Room>
</Session>
</Day>


<Day DayID = "Thursday">
<Session no = "6">
<Module type = "ACC382">
<ModuleName> ACCOUNTING </ModuleName>
</Module>
<Time>11.00am-12:59am</Time>
<Room>117</Room>
</Session>

<Day DayID = "Friday"></Day>

</Day>
<Day DayID = "Saturday"></Day>
<Day DayID = "Sunday"></Day>

</Week>
</Timetable>

If its hard to create a timetable with this xml then i dont mind if its changed to create it.

<?xml version="1.0"?>
<?xml-stylesheet href="timetable.xsl" type="text/xsl" ?><Timetable>
	<Week>
		<Day DayID="Monday">		
		</Day>
		<Day DayID="Tuesday">
			<Session no="1">
				<Module type="CMT111">
					<ModuleName>CPM</ModuleName>
				</Module>
				<Time>09.00am-10.59am</Time>
				<Room>222</Room>
			</Session>
			<Session no="2">
				<Module type="CMT213">
					<ModuleName>Software</ModuleName>
				</Module>
				<Time>02.00pm-03.59pm</Time>
				<Room>316</Room>
			</Session>
			<Session no="3">
				<Module type="CMT213">
					<ModuleName>Software</ModuleName>
				</Module>
				<Time>04.30pm-05.29pm</Time>
				<Room>67</Room>
			</Session>
			<Session no="6">
				<Module type="ACC382">
					<ModuleName>ACCOUNTING</ModuleName>
				</Module>
				<Time>11.00am-12:59am</Time>
				<Room>117</Room>
			</Session>
		</Day>
		<Day DayID="Wednesday">
			<Session no="4">
				<Module type="ACC33">
					<ModuleName>ACC</ModuleName>
				</Module>
				<Time>10.00am-11.59am</Time>
				<Room>065</Room>
			</Session>
			<Session no="5">
				<Module type="TP213">
					<ModuleName>trial</ModuleName>
				</Module>
				<Time>01.00pm-01.59pm</Time>
				<Room>316</Room>
			</Session>
		</Day>
		<Day DayID="Thursday">
			<Session no="6">
				<Module type="ACC382">
					<ModuleName>ACCOUNTING</ModuleName>
				</Module>
				<Time>11.00am-12:59am</Time>
				<Room>117</Room>
			</Session>
			<Day DayID="Friday"></Day>
		</Day>
		<Day DayID="Saturday"></Day>
		<Day DayID="Sunday"></Day>
	</Week>
</Timetable>
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output indent="yes" method="html"/>
	<xsl:key match="Day" name="only" use="position()"/>
	<xsl:template match="/">
		<xsl:apply-templates select="Timetable"/>
	</xsl:template>


	<xsl:template match="Timetable">
		<html>
			<style>
		table.out{
		border: 2px solid black;
		font-family: Courier New, monospace;
		}
		table.in{
		border: 0px solid blue;
		background-color:#efefef;
		width:450px;
		}
		th.out{
		border: 2px solid black;
        text-align:center;
		}
		
		td.out{
		border: 2px solid black;
		}
		td.outt2{
		border: 2px solid black;
		vertical-align:top;
		}
		th.modu{
		width:100px;
		}
		th.room{
		width:10px;		
		}
		th.time{
		width:30px;		
		}
        td.modu{
		width:100px;
		}
		td.room{
		/*width:10px;*/
		text-align:right;
		}
		td.time{
		/*width:20px;*/
		text-align:right;
		}
		#odd
		{
        //background-color:#ff0000;
		}
		#even
		{
        //background-color:#00ff00;
		}</style>
			<body>
				<table class="out">
					<xsl:apply-templates select="Week"/>
				</table>
			</body>
		</html>
	</xsl:template>

	<xsl:template match="Week">
		<!--
		<tr>
			<xsl:for-each select="Day">
				<td>
					<xsl:value-of select="@DayID"/>
				</td>

			</xsl:for-each>
		</tr>
		<tr>
<xsl:for-each select="Day">
				<td>
					<xsl:value-of select="count(Session)"/>
				</td>

			</xsl:for-each>
		</tr>
		-->
		<tr>
			<xsl:for-each select="//Day">
				<th class="out">
					<xsl:value-of select="./@DayID"/>
				</th>
			</xsl:for-each>
		</tr>
		<tr>
			<xsl:for-each select="//Day">
				<td class="outt2">
					<table class="in">
						<tr>
							<th class="time">Time</th>
							<th class="modu">Modul</th>
							<th class="room">Room</th>
						</tr>
						<xsl:for-each select="./Session">
							<tr>
								<td class="time">
									<xsl:value-of select="normalize-space(Time)"/>
								</td>
								<td class="modu">
									<xsl:value-of select="Module/ModuleName"/>
								</td>
								<td class="room">
									<xsl:value-of select="Room"/>
								</td>
							</tr>
						</xsl:for-each>
					</table>
				</td>
			</xsl:for-each>
		</tr>
	</xsl:template>
</xsl:stylesheet>
<html>
  <style>
		table.out{
		border: 2px solid black;
		font-family: Courier New, monospace;
		}
		table.in{
		border: 0px solid blue;
		background-color:#efefef;
		width:450px;
		}
		th.out{
		border: 2px solid black;
        text-align:center;
		}
		
		td.out{
		border: 2px solid black;
		}
		td.outt2{
		border: 2px solid black;
		vertical-align:top;
		}
		th.modu{
		width:100px;
		}
		th.room{
		width:10px;		
		}
		th.time{
		width:30px;		
		}
        td.modu{
		width:100px;
		}
		td.room{
		/*width:10px;*/
		text-align:right;
		}
		td.time{
		/*width:20px;*/
		text-align:right;
		}
		#odd
		{
        //background-color:#ff0000;
		}
		#even
		{
        //background-color:#00ff00;
		}
  </style>
  <body>
    <table class="out">
      <tr>
        <th class="out">Monday</th>
        <th class="out">Tuesday</th>
        <th class="out">Wednesday</th>
        <th class="out">Thursday</th>
        <th class="out">Friday</th>
        <th class="out">Saturday</th>
        <th class="out">Sunday</th>
      </tr>
      <tr>
        <td class="outt2">
          <table class="in">
            <tr>
              <th class="time">Time</th>
              <th class="modu">Modul</th>
              <th class="room">Room</th>
            </tr>
          </table>
        </td>
        <td class="outt2">
          <table class="in">
            <tr>
              <th class="time">Time</th>
              <th class="modu">Modul</th>
              <th class="room">Room</th>
            </tr>
            <tr>
              <td class="time">09.00am-10.59am</td>
              <td class="modu">CPM</td>
              <td class="room">222</td>
            </tr>
            <tr>
              <td class="time">02.00pm-03.59pm</td>
              <td class="modu">Software</td>
              <td class="room">316</td>
            </tr>
            <tr>
              <td class="time">04.30pm-05.29pm</td>
              <td class="modu">Software</td>
              <td class="room">67</td>
            </tr>
            <tr>
              <td class="time">11.00am-12:59am</td>
              <td class="modu">ACCOUNTING</td>
              <td class="room">117</td>
            </tr>
          </table>
        </td>
        <td class="outt2">
          <table class="in">
            <tr>
              <th class="time">Time</th>
              <th class="modu">Modul</th>
              <th class="room">Room</th>
            </tr>
            <tr>
              <td class="time">10.00am-11.59am</td>
              <td class="modu">ACC</td>
              <td class="room">065</td>
            </tr>
            <tr>
              <td class="time">01.00pm-01.59pm</td>
              <td class="modu">trial</td>
              <td class="room">316</td>
            </tr>
          </table>
        </td>
        <td class="outt2">
          <table class="in">
            <tr>
              <th class="time">Time</th>
              <th class="modu">Modul</th>
              <th class="room">Room</th>
            </tr>
            <tr>
              <td class="time">11.00am-12:59am</td>
              <td class="modu">ACCOUNTING</td>
              <td class="room">117</td>
            </tr>
          </table>
        </td>
        <td class="outt2">
          <table class="in">
            <tr>
              <th class="time">Time</th>
              <th class="modu">Modul</th>
              <th class="room">Room</th>
            </tr>
          </table>
        </td>
        <td class="outt2">
          <table class="in">
            <tr>
              <th class="time">Time</th>
              <th class="modu">Modul</th>
              <th class="room">Room</th>
            </tr>
          </table>
        </td>
        <td class="outt2">
          <table class="in">
            <tr>
              <th class="time">Time</th>
              <th class="modu">Modul</th>
              <th class="room">Room</th>
            </tr>
          </table>
        </td>
      </tr>
    </table>
  </body>
</html>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.