Hi,
I'd like to ask for help in modyfing my XSL code. Here is it:
Code:
<?xml version="1.0" encoding="windows-1250"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html><body scroll="no" bgcolor="lightgreen"><font size="1pt"><center>
<br></br><br></br>
<p><b><u><font size="2">TIMETABLE</font></u></b></p>
<p>Studies: <b>full-time</b></p>
<p>Academic year: <b>2008/2009</b></p>
<p>Semester: <b>summer</b></p>
<br></br>
<table border="2" width="60%" height="25%" bgcolor="lightgrey">
<tr>
<th><font size="1pt"><center>Monday</center></font></th>
<th><font size="1pt"><center>Subject</center></font></th>
<th><font size="1pt"><center>Form</center></font></th>
<th><font size="1pt"><center>Room</center></font></th>
</tr>
<xsl:for-each select="semester/day_1">
<tr>
<xsl:choose>
<xsl:when test="@subject='Gymnastics'">
<xsl:attribute name="style">background-color:lightyellow;
</xsl:attribute>
</xsl:when>
<xsl:when test="@subject='Object programming'">
<xsl:attribute name="style">background-color:lightblue;
</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="style">background-color:lightgreen;
</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="@form='lecture'">
<xsl:attribute name="style">font-weight:bold;
</xsl:attribute>
</xsl:when>
<xsl:when test="@form='lab'">
<xsl:attribute name="style">font-style:italic;
</xsl:attribute>
</xsl:when>
<xsl:when test="@form ='classes'">
<xsl:attribute name="style">text-decoration:underline;
</xsl:attribute>
</xsl:when>
</xsl:choose>
<td width="20%"><font size="1pt"><center><xsl:value-of select="hour"/></center></font></td>
<td width="35%"><font size="1pt"><xsl:value-of select="@subject"/></font></td>
<td width="15%"><font size="1pt"><center><xsl:value-of select="@form"/></center></font></td>
<td width="15%"><font size="1pt"><center><xsl:value-of select="room"/></center></font></td>
</tr>
</xsl:for-each>
</table>
<br></br>
<br></br>
<table border="2" width="60%" height="25%" bgcolor="lightgrey">
<tr>
<th><font size="1pt"><center>Tuesday</center></font></th>
<th><font size="1pt"><center>Subject</center></font></th>
<th><font size="1pt"><center>Form</center></font></th>
<th><font size="1pt"><center>Room</center></font></th>
</tr>
<xsl:for-each select="semester/day_2">
<tr>
<td width="20%"><font size="1pt"><center><xsl:value-of select="hour"/></center></font></td>
<td width="35%"><font size="1pt"><xsl:value-of select="subject"/></font></td>
<td width="15%"><font size="1pt"><center><xsl:value-of select="form"/></center></font></td>
<td width="15%"><font size="1pt"><center><xsl:value-of select="room"/></center></font></td>
</tr>
</xsl:for-each>
</table>
</center>
</font>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
My XML:
Code:
<?xml version="1.0" encoding ="windows-1250"?>
<?xml-stylesheet type="text/xsl" href="details.xsl"?>
<!DOCTYPE semester SYSTEM "semester.dtd">
<semester>
<day_1 form="lecture" subject ="Gymnastics">
<hour>8.00 - 9.30</hour>
<room>145C</room>
</day_1>
<day_1 form="lab" subject="Object programming">
<hour>9.45 - 11.15</hour>
<room>427</room>
</day_1>
<day_1 form="classes" subject="Team sports">
<hour>11.45 - 13.15</hour>
<room>court</room>
</day_1>
<day_2>
<hour>8.00 - 9.30</hour>
<subject>Databases</subject>
<form>lecture</form>
<room>458D</room>
</day_2>
<day_2>
<hour>10.00 - 11.30</hour>
<subject>Team sports</subject>
<form>classes</form>
<room>court</room>
</day_2>
<day_2>
<hour>11.45 - 13.15</hour>
<subject>Object programming</subject>
<form>classes</form>
<room>78C</room>
</day_2>
</semester>
and finally DTD:
Code:
<?xml version="1.0" encoding="ISO-8859-2"?>
<!ELEMENT semester (day_1,day_2)>
<!ELEMENT day_1 (hour, room)>
<!ELEMENT day_2 (hour, room)>
<!ATTLIST day_1
form (lecture | lab |classes) #REQUIRED
subject (Gymnastics|Object_programming|Team_sports) #REQUIRED
>
<!ELEMENT hour (#PCDATA)>
<!ELEMENT room (#PCDATA)>
I am particularly interested in the fragment of XSL code where two instruction of xsl:choose are placed. I assume the way I put them is incorrect as only the second is working.
Here is what I want to achieve:
I have a few subjects and they may be lecture, classes or lab. These forms are formatted:
lecture-bold, lab-italic and classes-underline. And it works.
However I'd like simultaneously format the names of subjects in the following way:
Gymnastics-lightyellow, Object programming-lightblue and Team sports -lightgreen.
Could anybody help me in joining these two kind of formatting?
I would be very grateful for any help.