<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/SERVICES">
  <html>
  <body bgcolor="#F5DF91">
    <title>Displaying dynamically generated XML using XSL</title>



    <xsl:variable name = "A" ><xsl:value-of select="ERROR"/></xsl:variable>
	
    <xsl:choose>
          
          <xsl:when test="starts-with($A,'Error')">
               <h4><xsl:value-of select="ERROR"/></h4> 
			   <form 
    			name="returnHome" 
    			action="default.html"
				method="POST"
				onSubmit="return true">
   
   				<INPUT type="submit" value="MAIN MENU" />	
   				</form>
          </xsl:when>

     <xsl:otherwise> 
	 
	 <!-- Store variables for form submission -->
	 <xsl:variable name = "PID" ><xsl:value-of select="ITEM/PS_ID"/></xsl:variable> 
	 <xsl:variable name = "CID" ><xsl:value-of select="ITEM/CLASS_ID"/></xsl:variable> 
 
      <h2>Here are the Module details ...</h2>
	  
    <!-- display first table headers -->
         <table border="5" cellpadding = "5" bgcolor="#F5DF91" align = "center" summary = "Results">
           <tr bgcolor="#9acd32">
            <th>Module Name</th>
            <th>Module Description</th>
			<th>Module Points</th>
            <th>Module Fee</th> 
			<th>Module Start Date</th>                   
           </tr>  
		   			  
    <!-- Start main loop here -->
    <xsl:for-each select="ITEM">
    
       <!-- display PRODUCT details in a table -->
        <tr>
          <td><xsl:value-of select="MO_NAME"/></td>
          <td><xsl:value-of select="MO_DESCRIPTION"/></td>	
		  <td><xsl:value-of select="MO_POINTS"/></td>
          <td><xsl:value-of select="MO_FEE"/></td>	
		  <td><xsl:value-of select="MO_START_DATE"/></td>
        </tr> 
        
   </xsl:for-each>
   
   <!-- Close table -->
   </table><br /><br /> 
    
   <!-- Book Enrolment form -->	 
   
   
   
   <form 
    name="confirmEnrol" 
    action="student_enrol.php"
	method="POST"
	onSubmit="return true">	
	
	<p>
      <input type = "hidden" name = "Personid"
             value = "$PID" />
      <input type = "hidden" name = "Classid" 
             value = "$CID" />
   </p> 
   
   <INPUT type="submit" value="Confirm Request to Enrol" /><br />
   </form>	
   
   <p><a href="default.html">Return to Home Page</a></p>
 
</xsl:otherwise>
</xsl:choose>

</body>
</html>
  
</xsl:template>
</xsl:stylesheet>
