Jump to content

How To Read Values From An Element In An If Statement

Guest Nadine

Recommended Posts

Guest Nadine

Hey all,I am having a little problem. I have am xml doc. with a list of courses their times ,days of the wk and location . I have an xsl file wanting to display this information in a weekly timetable.Below is the xml file well a piece of it<?xml version="1.0" encoding="iso-8859-1"?><?xml-stylesheet type="text/xsl" href="XSLTFile.xsl"?><school xmlns="http://www.mydomain.com/project"'>http://www.mydomain.com/project" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mydomain.com/project XMLSchema2.xsd"> <courses> <course> <title>Discrete Mathematics</title> <code>COMP2300</code> <day>Monday</day> <time>9:00</time> <location>313</location> <lecturer>Mr.Arvind Mohais</lecturer> </course> <course> <title>Discrete Mathematics</title> <code>COMP2300</code> <day>Wednesday</day> <time>11:00</time> <location>313</location> <lecturer>Mr.Arvind Mohais</lecturer> </course> <course> <title>Discrete Mathematics</title> <code>COMP2300</code> <day>Friday</day> <time>11:00</time> <location>313</location>The xsl file <?xml version="1.0" encoding="iso-8859-1"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:mp="http://www.mydomain.com/project"'>http://www.mydomain.com/project"> <xsl:template match="mp:school/mp:courses"> <html> <body> <table> <tr style="background-color:#ccff00"> <th>Time</th> <th>Monday</th> <th>Tuesday</th> <th>Wednesday</th> <th>Thrusday</th> <th>Friday</th> </tr> <tr style="background-color:#ccccc"> <td>9:00</td> <xsl:for-each select="mp:course[mp:time=11:00]"> <xsl:if test="mp:day='Monday'"> <td> <xsl:value-of select="mp:title"/><xsl:element name="br"/> <xsl:value-of select="mp:location"/><xsl:element name="br"/> <xsl:value-of select="mp:lecturer"/> </td> </xsl:if> <xsl:if test="mp:day='Tuesday'"><td> <xsl:value-of select="mp:title"/><xsl:element name="br"/> <xsl:value-of select="mp:location"/> </td></xsl:if> <xsl:if test="mp:day='Wednesday'"><td> <xsl:value-of select="mp:title"/> <xsl:element name="br"/> <xsl:value-of select="mp:location"/> </td></xsl:if> <xsl:if test="mp:day='Thrusday'"><td> <xsl:value-of select="mp:title"/><xsl:element name="br"/> <xsl:value-of select="mp:location"/> </td></xsl:if> <xsl:if test="mp:day='Friday'"><td> <xsl:value-of select="mp:title"/><xsl:element name="br"/> <xsl:value-of select="mp:location"/> </td></xsl:if> </xsl:for-each> </tr> What is happening say for eg. The two courses that are starting at 11:00 on Wed and Friday is it populating in the 11:00 row however it is being filled in the Mon and Tues columns and not in Wednesday and Friday.The for loop is working cause it is finding the courses starting at 11:00 but it seems like the if statement not reading.Can anyone help?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...