[Previous slide] [Next slide] Moving to XML

Beginning XSL-T (v) declaring a template

  <xsl:template match="eventsdiary">

This template matches every instance of the element eventsdiary which is found in the document being processed. As eventsdiary is the root element of the document type we're interested in, there will only be one.

    <html>
      <head>
        <title>

As you can see, what is in the template is just the HTML markup that will be output (if we were outputting XML, it would be XML, of course)...

      Diary for <xsl:value-of select="@date" />

with scattered among it special xsl tags which cause things to be spliced into the output. This one says 'use the value of the data attribute of the current element'

        </title>
      </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" />

This is the important one. It says "apply the templates in this stylesheet to all the instances of event elements which are children of the current node".

        </table>
      </body>
   </html>
  </xsl:template>

 


An older version of this course is available here