<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" >
<xsl:output method="html"/>

<xsl:template match="student">
  <html>
    <head>
     <title>Student Record</title>
    <style>
      body, p, td, th {font-family:arial,sans-serif}
      th { text-align:right;}
    </style>
    </head>
    <body>
      <h1 align="center">Student Record for 
          <xsl:value-of select="first"/> <xsl:text> </xsl:text>
          <xsl:value-of select="middle"/><xsl:text> </xsl:text> 
          <xsl:value-of select="last"/> 
      </h1>
      <hr/>

       <table cellspacing="2" bgcolor="wheat" border="0">	
       <tr>
         <th>Name: </th>
          <td> <xsl:value-of select="first"/> 
            <xsl:text> </xsl:text> 
            <xsl:value-of select="middle"/> <xsl:text> </xsl:text>
            <xsl:value-of select="last"/> 
          </td>
       </tr>
       <tr>
         <th>RPI ID#: </th>
         <td> <xsl:value-of select="rid"/></td>
       </tr>
       <tr>
         <th>Address:</th><td><xsl:value-of select="address"/></td>
       </tr>
       <tr>
         <th>Phone:</th> <td> <xsl:value-of select="phone"/></td>
       </tr>
       <tr>
         <th>Instant Messenger ID:</th><td> <xsl:value-of select="im"/></td>
       </tr>
       <tr>
         <th valign="top">Courses:</th>
         <td>
	    <xsl:apply-templates select="courses"/>
         </td>
       </tr>
       </table>
     </body> 
   </html>
</xsl:template>

<!-- Template that handles the display of a courses element -->
<xsl:template match="courses">
   <div style="border:solid 2pt black; padding:.1in;">
    <p>Courses for <xsl:value-of select="@semester"/>:</p>
   <xsl:for-each select="course">
     <div style="margin:.1in; pading:.1in;
                 border:solid 1pt black;
                 background-color:#ccddee">
     <table border="0">
      <tr><th>Name:</th><td> <xsl:value-of select="name"/></td></tr>
      <tr><th>CRN:</th><td>
          <xsl:for-each select="crn">
                <xsl:value-of select="."/>
                 <xsl:text>  </xsl:text>  <!-- adds whitespace -->
          </xsl:for-each>
      </td></tr>
      <tr><th>Course #:</th><td>  <xsl:value-of select="num"/></td></tr>
     </table>
     </div>
   </xsl:for-each>      
   </div>
</xsl:template>

</xsl:stylesheet>






