[Previous slide] [Next slide] Moving to XML

Beginning XSL-T (i) The 'stylesheet'

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

<!-- Basic XSL stylesheet for day view of events diary.  -->

  <xsl:output indent="yes" method="html" 
          doctype-public="-//W3C//DTD HTML 4.0 Transitional//EN"/>

  <xsl:template match="eventsdiary">
    <html>
      <head>
    <title>
      Diary for <xsl:value-of select="@date" />
    </title>
    <link rel="StyleSheet" href="/styles/jacquard.css" type="text/css" 
      media="screen"/>
      </head>
      <body>
    <h1>
      Diary for <xsl:value-of select="@date" />
    </h1>
    <table>
      <tr>
        <th rowspan="2">
        Who
        </th>
        <th rowspan="2">
        Where
        </th>
        <th colspan="2">
        When
        </th>
        <th rowspan="2">
        What
        </th>
        <th rowspan="2">
        Details
        </th>
        <th rowspan="2">
        <a href="event">Add</a>
        </th>
      </tr>
      <tr>
        <th>
          Starts
        </th>
        <th>
          Ends
        </th>
      </tr>
      <xsl:apply-templates select="event" />
    </table>
      </body>
   </html>
  </xsl:template>

  <xsl:template match="event">
    <tr>
      <td>
    <xsl:value-of select="@actor"/>
      </td>
      <td>
    <xsl:value-of select="@location"/>
      </td>
      <td>
    <xsl:value-of select="@starttime"/>
      </td>
      <td>
    <xsl:value-of select="@endtime"/>
      </td>
      <td>
    <xsl:value-of select="@type"/>
      </td>
      <td>
    <xsl:value-of select="description"/>
      </td>
      <td>
    <a>
      <xsl:attribute name="href">event?event=<xsl:value-of 
        select="@event"/>
      </xsl:attribute>
      Edit
    </a>
      </td>
    </tr>
  </xsl:template>

</xsl:stylesheet>

 


An older version of this course is available here