<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                version="1.0">

  <!-- PenguinBlog XSLT stylesheet
       Copyright 2003, 2004 by Silmaril Consultants
       Available for public use under the terms of the GNU GPL -->

  <xsl:output method="html" encoding="iso-8859-1" indent="yes" 
    doctype-public="-//W3C//DTD HTML 4.0 Strict//EN"
    doctype-system="/dtds/html4s.dtd"/>

  <xsl:strip-space elements="*"/>

  <!-- Date at last call (file storedate) is in the format
       <date>
       <now rfc822="Fri, 9 Apr 2004 00:00:00 +0100" weekday="Friday" 
         wday="6" day="09" month="April" mon="04" year="2004" 
         hour="00" minute="00" second="00">2004-04-09T00:00:00+0100</now>
       ...
       </date>
       in file /var/www/html/cc/datetime.xml 

       External users please note this is not supplied with the 
       PenguinBlog. You have to set this up on your server with
       a script to run hourly from cron.
       -->
       <xsl:variable name="datefile" 
        select="document('/var/www/html/cc/datetime.xml')"/>
       <xsl:variable name="isodate" 
        select="substring($datefile/date/now,1,10)"/>
  <xsl:variable name="thisyear" select="$datefile/date/now/@year"/>
  <xsl:variable name="thisqtr" 
    select="(($datefile/date/now/@mon - 1) div 3) + 1"/>
  <xsl:variable name="newblog" 
    select="document('newblog.xml')/blog/entries/entry[1]"/>
  <xsl:variable name="entrydates" select="//entries"/>
  <xsl:variable name="older" select="document('blog.older.xml')"/>
  <xsl:param name="articles"/>

  <xsl:template match="/">
    <html>
      <xsl:comment>
        <xsl:text>
Basic layout adapted from the OpenZaurus site at www.openzaurus.org 
which was designed by Adam Hooper (adamh@densi.com). Thanks, Adam.

I just modified it for Cocoon. Peter Flynn (peter@silmaril.ie) January 2004.
        </xsl:text>
      </xsl:comment>
      <head>
        <title>
          <xsl:value-of select="document('id.xml')/identity/name"/>
          <xsl:text>'s WebLog</xsl:text>
        </title>
        <link rel="stylesheet" 
          href="http://www.silmaril.ie/penguinblog/xblog.css" 
          type="text/css"/>
        <link rel="alternate" 
          title="Peter's Blog" 
          href="http://www.silmaril.ie/cgi-bin/rss" 
          type="application/rss+xml"/>
        <link rel="shortcut icon" 
          href="http://silmaril.ie/favicon.ico" 
          type="image/png"/>
        <meta http-equiv="Refresh" 
          content="6000; url='http://www.silmaril.ie/'"/>
        <script type="text/javascript">
          <xsl:text disable-output-escaping="yes">&lt;!--</xsl:text>
var hasIE_phone_home = 1;
// This function does the actual browser detection
function hasIE_hasIE() {
  var ua = navigator.userAgent.toLowerCase();
  return ((ua.indexOf('msie') != -1) &amp;&amp; 
          (ua.indexOf('opera') == -1) &amp;&amp; 
          (ua.indexOf('webtv') == -1) &amp;&amp;
          (location.href.indexOf('seenIEPage') == -1));
}

function hasIE_showOnlyLayer(whichLayer)
{
  if (document.getElementById)
    {
      var style2 = document.getElementById(whichLayer);
    }
  else if (document.all)
    {
      var style2 = document.all[whichLayer];
    }
  else if (document.layers)
    {
      var style2 = document.layers[whichLayer];
    }
  var body = document.getElementsByTagName('body');
  body[0].innerHTML = style2.innerHTML;
}

function hasIE_showLayer(whichLayer)
{
  if (document.getElementById)
    {
      var style2 = document.getElementById(whichLayer).style;
      style2.display = "block";
    }
  else if (document.all)
    {
      var style2 = document.all[whichLayer].style;
      style2.display = "block";
    }
  else if (document.layers)
    {
      var style2 = document.layers[whichLayer].style;
      style2.display = "block";
    }
}

function hasIE_moveAd(adid) {
  if (document.getElementById)
    {
      var ad = document.getElementById('hasIE_ad');
      var adloc = document.getElementById(adid);
    }
  else if (document.all)
    {
      var ad = document.all['hasIE_ad'];
      var adloc = document.all[adid];
    }
  else if (document.layers)
    {
      var ad = document.layers['hasIE_ad'];
      var adloc = document.layers[adid];
    }
  adloc.innerHTML = ad.innerHTML;
}

              // Hides and shows sections of the page based on whether or not it's
              // running in IE
function hasIE_hideAndShow() {
  if (hasIE_hasIE()) {
    hasIE_showLayer("hasIE_level1");
          if (hasIE_phone_home == 1)
            hasIE_phoneHome('getIE_pingimage1');
  } else {
    if (hasIE_phone_home == 1)
      hasIE_phoneHome('getIE_pingimage0');
  }
}

function hasIE_phoneHome(image) {
  if (document.getElementById)
    {
      var img = document.getElementById(image);
    }
  else if (document.all)
    {
      var img = document.all[image];
    }
  else if (document.layers)
    {
      var img = document.layers[image];
    }
      img.setAttribute('src','http://getunder50.com/ping.php?host='+location.host);
}

function hasIE_ContinueWithoutFF() {
    if (location.href.indexOf('?') != -1)
        location.href += '&amp;seenIEPage=1';
    else
        location.href += '?seenIEPage=1';
}
          //<xsl:text>--></xsl:text>
        </script>
      </head>
      <!-- from here to matching ** is DestroyExplorer -->
      <body onload="javascript:hasIE_hideAndShow();"><a name="top"></a>
        <span style="position:absolute; width: 0px; height:0px; left:-1000px; top: -1000px">
          <img id="getIE_pingimage0"/>
        </span>
        <!-- LEVEL 1: SWITCH BAR ON TOP OF PAGE --> 
        <div id="hasIE_level1" style="display: none;">
          <span style="position:absolute; width: 0px; height:0px; left:-1000px; top: -1000px">
            <img id="getIE_pingimage1"/>
          </span>
          <div style="padding: 20px; background-color: #ffffbb; font-family: arial; font-size: 15px; font-weight: normal; color: #111111; line-height: 17px;">
            <div style="width: 650px; margin: 0 auto 0 auto;">
              <div style="padding-left: 8px; padding-top: 0px; float: right;">
                <!-- REPLACE THIS BLOCK OF SCRIPT WITH YOUR OWN 
                     FIREFOX REFERRAL BUTTON SCRIPT -->
                <script type="text/javascript">
                <xsl:text disable-output-escaping="yes">&lt;!--</xsl:text>
google_ad_client = "pub-5345054326899149";
google_ad_width = 125;
google_ad_height = 125;
google_ad_format = "125x125_as_rimg";
google_cpa_choice = "CAAQo-aZzgEaCM3CU97Siy5UKK2293M";
                      //<xsl:text>--></xsl:text>
                  </script>
                  <script type="text/javascript" 
                    src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
                  </script>
                </div>
                <p style="font-weight:bold;">I see you're using Internet Explorer.
                You may want to try Firefox, I think you'll like it better.</p>
                <ul>
                  <li>Firefox can block unwanted pop-up windows.</li>
                  <li>It can stop viruses and spyware.</li>
                  <li>It keeps Microsoft from controlling the future of the
                  internet.</li>
                  <li>It's more conformant to the prevailing standards (XHTML, CSS, etc)</li>
                </ul>
                <p>Click the button on the right to download and install Firefox. 
                It's free.</p>
              </div>
            </div>
          </div>
          <!-- ** CLOSES LEVEL 1 -->
          <xsl:apply-templates/>
      </body>
    </html>
  </xsl:template>

  <xsl:template match="blog">
    <table class="banner">
      <tbody>
        <tr>
          <td class="banner">
            <div class="banner">
              <table class="inner">
                <tr>
                  <td class="heading">
                    <div class="heading">
                      <h2>
                        <xsl:variable name="topic"
                          select="string(entries/entry[1]/topic/para)"/>
                        <xsl:apply-templates select="entries/entry[1]/topic/para"/>
                        <xsl:variable name="recurrence"
                          select="count(entries/entry/topic/para[.=$topic])"/>
                        <xsl:if test="$recurrence &gt; 1">
                          <xsl:text> (</xsl:text>
                          <xsl:value-of select="$recurrence"/>
                          <xsl:text>)</xsl:text>
                        </xsl:if>
                      </h2>
                      <h1>
                        <xsl:value-of 
                          select="document('id.xml')/identity/name"/>
                      </h1>
                      <xsl:if 
                        test="$newblog/@id != entries/entry[1]/@id">
                        <p>
                          <xsl:text>New article coming soon: </xsl:text>
                          <i>
                            <xsl:value-of select="$newblog/topic/para"/>
                          </i>
                        </p>
                      </xsl:if>
                    </div>
                  </td>
                  <td class="directory">
                    <div class="directory">
                      <xsl:for-each select="entries/entry">
                        <xsl:apply-templates select="." mode="titles"/>
                      </xsl:for-each>
                      <xsl:if test="$articles='current' and
                                    count(entries/entry)&lt;5">
                        <xsl:apply-templates 
                          select="$older/blog/entries/entry
                                  [count(preceding-sibling::entry)&lt;=5]"
                          mode="titles"/>
                      </xsl:if>
                      <xsl:choose>
                        <!-- if this is the default blog ("current") and
                             there are some older articles around, link them -->
                        <xsl:when test="$articles='current' and
                                        $older/blog/entries/entry">
                          <a href="/cgi-bin/blog?older">
                            <xsl:text>Earlier articles:</xsl:text>
                          </a>
                        </xsl:when>
                        <xsl:when test="$articles='older'">
                          <a href="/cgi-bin/blog">
                            <xsl:text>Newer articles:</xsl:text>
                          </a>
                        </xsl:when>
                        <xsl:otherwise>
                          <xsl:text>Unknown argument </xsl:text>
                          <xsl:value-of select="$articles"/>
                        </xsl:otherwise>
                      </xsl:choose>
                    </div>
                    <!-- calendar -->
                    <div class="calendar">
                      <xsl:apply-templates select="$datefile/date/cal"/>
                      <a href="http://www-2.cs.cmu.edu/~tilt/principia/body.html#applecorps">
                        <xsl:value-of select="$datefile/date/then"/>
                      </a>
                    </div>
                  </td>
                  <td class="logo">
                    <div class="logo">
                      <h5><a href="http://www.silmaril.ie/penguinblog/" 
                      title="How does this blog work?" 
                      class="penguinlink">PenguinBlog</a></h5>
                      <img src="http://www.silmaril.ie/images/winter_theme_cutdown_icon.jpg" height="113" width="163"
                        alt="Skating penguins from the KDE Winter theme"/>
                      <p class="logoindex">
                        <xsl:for-each
                          select="document('links.xml')//links/title">
                          <a href="#{../@id}">
                            <xsl:value-of select="."/>
                          </a>
                          <xsl:if test="position() != last()">
                            <xsl:text> | </xsl:text>
                          </xsl:if>
                        </xsl:for-each>
                      </p>
                    </div>
                  </td>
                </tr>
              </table>
            </div>
          </td>
        </tr>
      </tbody>
    </table>
    <table class="body">
      <tbody>
        <tr>
          <td class="links">
            <xsl:apply-templates select="document('links.xml')//links"/>
          </td>
          <td class="main">
            <div class="main">
              <!--
<a href="http://demo.ffii.org/">
  <img src="http://www.silmaril.ie/images/patent_overload.gif" border="0" alt="NO to software patents - come to Brussels on 14 April" height="60" width="468" />
  </a><hr/>
-->
              <xsl:apply-templates/>
            </div>
            <div class="legal">
              <xsl:text>
Copyright &#x00A9; 2003, 2004 by Peter Flynn and Silmaril Consultants
              </xsl:text>
            </div>
          </td>
          <td class="ads" valign="top" align="right">
            <div class="ads">
              <h4>Publicidad</h4>
              <script type="text/javascript">
                <xsl:text disable-output-escaping="yes">&lt;!--</xsl:text>
google_ad_client = "pub-5345054326899149";
google_ad_width = 160;
google_ad_height = 600;
google_ad_format = "160x600_as";
google_ad_type = "text_image";
google_ad_channel ="";
google_color_border = "CC99CC";
google_color_bg = "E7C6E8";
google_color_link = "000000";
google_color_url = "00008B";
google_color_text = "663366";
//
                <xsl:text>--></xsl:text>
              </script>
              <script type="text/javascript"
                src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
              </script>
              <script type="text/javascript">
                <xsl:text disable-output-escaping="yes">&lt;!--</xsl:text>
google_ad_client = "pub-5345054326899149";
google_ad_width = 125;
google_ad_height = 125;
google_ad_format = "125x125_as_rimg";
google_cpa_choice = "CAAQh7yazgEaCCMiotM2K7TZKJ_D93M";
//
                <xsl:text>--></xsl:text>
              </script>
              <script type="text/javascript" 
                src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
              </script>
            </div>
          </td>
        </tr>
      </tbody>
    </table>
  </xsl:template>

  <xsl:template match="entry" mode="titles">
    <xsl:if test="descendant::para[@type='addition']">
      <xsl:text>*</xsl:text>
    </xsl:if>
    <xsl:if test="descendant::*[@status='revised']">
      <xsl:text>&#x2020;</xsl:text>
    </xsl:if>
    <a title="{normalize-space(summary)}">
      <xsl:attribute name="href">
        <xsl:text>#</xsl:text>
        <xsl:choose>
          <xsl:when test="@id">
            <xsl:value-of select="@id"/>
          </xsl:when>
          <xsl:otherwise>
            <xsl:text>E</xsl:text>
            <xsl:number/>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:attribute>
      <xsl:apply-templates select="topic/para"/>
    </a>
    <xsl:variable name="topic" 
      select="string(topic/para)"/>
    <xsl:variable name="recurrence"
      select="count(/blog/entries/entry/
              topic/para[string(.)=$topic])"/>
    <xsl:if test="$recurrence &gt; 1">
      <xsl:text> (</xsl:text>
      <xsl:value-of 
        select="count(following-sibling::entry/
                topic/para[string(.)=$topic])+1"/>
      <xsl:text>)</xsl:text>
    </xsl:if>
    <xsl:if test="count(preceding-sibling::entry)>=0">
      <xsl:text>&#x00A0;| </xsl:text>
    </xsl:if>
  </xsl:template>
  
  <!-- calendar elements from $datefile -->

  <xsl:template match="cal">
    <table class="cal">
      <tr>
        <td>
          <!-- output year [range] -->
          <xsl:if test="month[1]/@year != month[3]/@year">
            <xsl:value-of select="month[1]/@year"/>
            <xsl:text>&#x2013;</xsl:text>
          </xsl:if>
          <xsl:value-of select="month[3]/@year"/>
          <!-- then the names of days of the week -->
        </td>
        <th class="day">S</th>
        <th class="day">M</th>
        <th class="day">T</th>
        <th class="day">W</th>
        <th class="day">T</th>
        <th class="day">F</th>
        <th class="day">S</th>
        <th class="day">S</th>
        <th class="day">M</th>
        <th class="day">T</th>
        <th class="day">W</th>
        <th class="day">T</th>
        <th class="day">F</th>
        <th class="day">S</th>
        <th class="day">S</th>
        <th class="day">M</th>
        <th class="day">T</th>
        <th class="day">W</th>
        <th class="day">T</th>
        <th class="day">F</th>
        <th class="day">S</th>
        <th class="day">S</th>
        <th class="day">M</th>
        <th class="day">T</th>
        <th class="day">W</th>
        <th class="day">T</th>
        <th class="day">F</th>
        <th class="day">S</th>
        <th class="day">S</th>
        <th class="day">M</th>
        <th class="day">T</th>
        <th class="day">W</th>
        <th class="day">T</th>
        <th class="day">F</th>
        <th class="day">S</th>
        <th class="day">S</th>
        <th class="day">M</th>
      </tr>
      <xsl:apply-templates/>
    </table>
  </xsl:template>

  <xsl:template match="ref"/>

  <!-- output three months, as supplied by cal -->

  <xsl:template match="month">
    <tr class="month">
      <th>
        <xsl:value-of select="@name"/>
      </th>
      <!-- if the month does not begin on a sunday, 
           pad the start of the month -->
      <xsl:if test="day[1]/@name != 'Su'">
        <xsl:variable name="dayname">
          <xsl:value-of select="day[1]/@name"/>
        </xsl:variable>
        <xsl:for-each select="../../ref/day">
          <xsl:if test="@n&lt;following-sibling::day[@name=$dayname]/@n">
            <td class="day"></td>
          </xsl:if>
        </xsl:for-each>
      </xsl:if>
      <!-- Now the rest of the month -->
      <xsl:apply-templates/>
    </tr>
  </xsl:template>

  <xsl:template match="day">
    <!-- get an ISO 8601 value for the day -->
    <xsl:variable name="isoday">
      <xsl:value-of select="parent::month/@year"/>
      <xsl:text>-</xsl:text>
      <xsl:if test="parent::month/@num &lt; 10">
        <xsl:text>0</xsl:text>
      </xsl:if>
      <xsl:value-of select="parent::month/@num"/>
      <xsl:text>-</xsl:text>
      <xsl:if test="@n &lt; 10">
        <xsl:text>0</xsl:text>
      </xsl:if>
      <xsl:value-of select="@n"/>
    </xsl:variable>
    <td>
      <!-- four values for the class for formatting: 
           weekendtoday: today is a sat or sun
           weekend:      any other weekend day
           weekdaytoday: today is a weekday
           weekday:      any other weekday -->
      <xsl:attribute name="class">
        <xsl:choose>
          <xsl:when test="@name='Su' or @name='Sa'">
            <xsl:choose>
              <xsl:when test="$isoday=$isodate">
                <xsl:text>weekendtoday</xsl:text>
              </xsl:when>
              <xsl:otherwise>
                <xsl:text>weekend</xsl:text>
              </xsl:otherwise>
            </xsl:choose>
          </xsl:when>
          <xsl:otherwise>
            <xsl:choose>
              <xsl:when test="$isoday=$isodate">
                <xsl:text>weekdaytoday</xsl:text>
              </xsl:when>
              <xsl:otherwise>
                <xsl:text>weekday</xsl:text>
              </xsl:otherwise>
            </xsl:choose>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:attribute>
      <!-- be picky about what gets what -->
      <xsl:choose>
        <!-- first check dates of blog entries to link them -->
        <xsl:when test="$entrydates/entry/@YYYY-MM-DD = $isoday">
          <xsl:variable name="article" 
            select="$entrydates/entry[@YYYY-MM-DD=$isoday][1]"/>
          <a class="article" title="{normalize-space($article/topic)}">
            <xsl:attribute name="href">
              <xsl:text>#</xsl:text>
              <xsl:choose>
                <xsl:when test="$entrydates/entry[@YYYY-MM-DD=$isoday]/@id">
                  <xsl:value-of 
                    select="$entrydates/entry[@YYYY-MM-DD=$isoday]/@id"/>
                </xsl:when>
                <xsl:otherwise>
                  <xsl:text>E</xsl:text>
                  <xsl:value-of 
                    select="count($entrydates/entry[@YYYY-MM-DD=$isoday]/
                           preceding-sibling::entry) + 1"/>
                </xsl:otherwise>
              </xsl:choose>
            </xsl:attribute>
            <xsl:value-of select="@n"/>
          </a>
        </xsl:when>
        <!-- careful with date compares: XSLT1 doesn't do string less/greater,
             so allow the values to be converted to numbers by removing 
             the hyphens. The test is true when the current day falls between
             the start-date and the end-date -->
        <xsl:otherwise>
          <xsl:variable name="event" 
            select="document('links.xml')//link
                    [translate($isoday,'-','')>=translate(@start-date,'-','')]
                    [translate($isoday,'-','')&lt;=translate(@end-date,'-','')]"/>
          <xsl:comment>
            <xsl:value-of select="$isoday"/>
            <xsl:text>|</xsl:text>
            <xsl:value-of select="$event"/>
          </xsl:comment>
          <xsl:choose>
            <xsl:when test="count($event) &gt; 0">
              <a href="{$event/@uri}"
                class="event" target="_new">
                <xsl:attribute name="title">
                  <xsl:for-each select="$event">
                    <xsl:apply-templates select="." mode="inlink"/>
                    <xsl:if test="position()!=last()">
                      <xsl:text> | </xsl:text>
                    </xsl:if>
                  </xsl:for-each>
                </xsl:attribute>
                <xsl:value-of select="@n"/>
              </a>
            </xsl:when>
            <xsl:otherwise>
              <xsl:value-of select="@n"/>
            </xsl:otherwise>
          </xsl:choose>
        </xsl:otherwise>
      </xsl:choose>
    </td>
  </xsl:template>

  <!-- entries -->

  <xsl:template match="entries">
    <xsl:choose>
      <!-- if there are fewer than 5 entries, add the first 5 from
           the older articles -->
      <xsl:when test="count(entry)&lt;5 and $articles='current'">
        <xsl:apply-templates/>
        <xsl:apply-templates 
          select="$older/blog/entries/entry
                  [count(preceding-sibling::entry)&lt;=5]"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:apply-templates/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <!-- summaries are for RSS and the index -->
  <xsl:template match="summary"/>

  <xsl:template match="entry">
    <div class="entry">
      <xsl:choose>
        <xsl:when test="@status='pending'">
          <h4>A new entry is being edited, out soon!</h4>
        </xsl:when>
        <xsl:otherwise>
          <xsl:apply-templates/>
        </xsl:otherwise>
      </xsl:choose>
      <xsl:if test="descendant::note">
        <hr/>
        <ol class="notes">
          <xsl:for-each select="descendant::note">
            <li>
              <a name="{@id}">
                <xsl:apply-templates/>
              </a>
            </li>
          </xsl:for-each>
        </ol>
      </xsl:if>
      <p class="datestamp">
        <xsl:value-of select="@day"/>
        <xsl:text> </xsl:text>
        <xsl:value-of select="@YYYY-MM-DD"/>
        <xsl:text> </xsl:text>
        <xsl:value-of select="@HH-MM-SS"/>
        <xsl:text> </xsl:text>
        <a href="#top">
          <img border="0" src="http://www.silmaril.ie/images/up.png" 
            align="middle" alt="Up"/>
        </a>
      </p>
    </div>
  </xsl:template>

  <xsl:template match="entry/topic">
    <table class="headline">
      <tr>
        <td class="headline">
          <h3>
            <xsl:variable name="topic" select="string(para)"/>
            <a>
              <xsl:attribute name="name">
                <xsl:choose>
                  <xsl:when test="../@id">
                    <xsl:value-of select="../@id"/>
                  </xsl:when>
                  <xsl:otherwise>
                    <xsl:text>E</xsl:text>
                    <xsl:number count="entry"/>
                  </xsl:otherwise>
                </xsl:choose>
              </xsl:attribute>
              <xsl:apply-templates/>
            </a>
            <xsl:variable name="recurrence"
              select="count(/blog/entries/entry/topic/para[string(.)=$topic])"/>
            <xsl:if test="$recurrence &gt; 1">
              <xsl:text> (</xsl:text>
              <xsl:value-of 
                select="count(parent::entry/following-sibling::entry/
                        topic/para[string(.)=$topic])+1"/>
              <xsl:text>)</xsl:text>
            </xsl:if>
          </h3>
        </td>
        <td class="summary">
          <xsl:value-of select="../summary"/>
        </td>
      </tr>
    </table>
  </xsl:template>

  <xsl:template match="entry/topic/para">
    <xsl:apply-templates/>
  </xsl:template>

  <!-- element content -->

  <xsl:template match="para">
    <p>
      <!-- if the only content is a single link, centre this para -->
      <xsl:if test="link[@image] and count(child::*)=1">
        <xsl:attribute name="align">
          <xsl:text>center</xsl:text>
        </xsl:attribute>
      </xsl:if>
      <!-- Set the style according to type and status -->
      <xsl:choose>
        <!-- use the type as class if not normal -->
        <xsl:when test="@type != 'normal'">
          <xsl:attribute name="class">
            <xsl:value-of select="@type"/>
          </xsl:attribute>
        </xsl:when>
        <xsl:when test="@status != 'complete'">
          <xsl:attribute name="class">
            <xsl:value-of select="@status"/>
          </xsl:attribute>
        </xsl:when>
        <!-- otherwise if this is the last para of an entry, use the
             class to say so (it gets less space because of the date -->
        <xsl:otherwise>
          <xsl:if test="count(following-sibling::*)=0">
            <xsl:attribute name="class">
              <xsl:text>endpar</xsl:text>
            </xsl:attribute>
          </xsl:if>
        </xsl:otherwise>
      </xsl:choose>
      <xsl:if test="@id">
        <a name="{@id}" title="Link target '{@id}'"><img src="http://www.silmaril.ie/images/idea.png"
        alt="Thought"/></a>
        <xsl:text>&#x00A0;</xsl:text>
      </xsl:if>
      <xsl:choose>
        <xsl:when test="@type='addition'">
          <a href="#codes" title="What's this?">
            <img border="0" alt="Addition"
              src="http://www.silmaril.ie/images/caret.png"/>
          </a>
          <xsl:text>&#x00A0;</xsl:text>
        </xsl:when>
        <xsl:when test="@status='revised'">
          <a href="#codes" title="What's this?">
            <img border="0" alt="Revised"
              src="http://www.silmaril.ie/images/configure.png"/>
          </a>
          <xsl:text>&#x00A0;</xsl:text>
        </xsl:when>
      </xsl:choose>
      <xsl:apply-templates/>
    </p>
  </xsl:template>

  <xsl:template match="note">
    <sup>
      <a href="#{@id}">
        <xsl:number/>
      </a>
    </sup>
  </xsl:template>

  <xsl:template match="verse">
    <blockquote class="verse">
      <p>
        <xsl:apply-templates/>
      </p>
    </blockquote>
  </xsl:template>

  <xsl:template match="line">
    <xsl:apply-templates/>
    <xsl:if test="position() != last()">
      <br/>
    </xsl:if>
  </xsl:template>

  <xsl:template match="code[not(ancestor::para)]">
    <blockquote>
      <pre>
        <xsl:apply-templates/>
      </pre>
    </blockquote>
  </xsl:template>

  <xsl:template match="cell/code">
    <pre>
      <xsl:apply-templates/>
    </pre>
  </xsl:template>

  <!-- tables -->

  <xsl:template match="table">
    <div class="listtable">
      <table>
        <xsl:apply-templates/>
      </table>
    </div>
  </xsl:template>

  <xsl:template match="spec">
    <xsl:apply-templates/>
  </xsl:template>

  <xsl:template match="col">
    <xsl:apply-templates/>
  </xsl:template>

  <xsl:template match="header | row">
    <tr>
      <xsl:apply-templates/>
    </tr>
  </xsl:template>

  <xsl:template match="header/cell">
    <th valign="bottom" align="left">
      <xsl:apply-templates/>
    </th>
  </xsl:template>

  <xsl:template match="cell">
    <td class="listtable" valign="top">
      <xsl:if test="ancestor::table/spec/col[current()[position()]]/@width">
        <xsl:attribute name="width">
          <xsl:value-of 
            select="ancestor::table/spec/col[current()[position()]]/@width"/>
          <xsl:choose>
            <xsl:when 
              test="ancestor::table/spec/col[current()[position()]]/@units='pct'">
              <xsl:text>%</xsl:text>
            </xsl:when>
            <xsl:otherwise>
              <xsl:value-of 
                select="ancestor::table/spec/col[current()[position()]]/@units"/>
            </xsl:otherwise>
          </xsl:choose>
        </xsl:attribute>
      </xsl:if>
      <xsl:apply-templates/>
    </td>
  </xsl:template>

  <!-- lists -->

  <xsl:template match="sequence">
    <ol>
      <xsl:if test="ancestor::sequence">
        <xsl:attribute name="type">
          <xsl:text>a</xsl:text>
        </xsl:attribute>
      </xsl:if>
      <xsl:apply-templates/>
    </ol>
  </xsl:template>

  <xsl:template match="list">
    <xsl:choose>
      <!-- if there's a topic, it's a discussion list -->
      <xsl:when test="item/topic">
        <dl>
          <xsl:if test="@status != 'complete'">
            <xsl:attribute name="class">
              <xsl:value-of select="@status"/>
            </xsl:attribute>
          </xsl:if>
          <xsl:apply-templates/>
        </dl>
      </xsl:when>
      <!-- if there's a reference, it's numbered -->
      <xsl:when test="@reference != 'none'">
        <ol>
          <xsl:attribute name="type">
            <xsl:choose>
              <xsl:when test="@reference='alpha'">
                <xsl:number format="a"/>
              </xsl:when>
              <xsl:when test="@reference='ALPHA'">
                <xsl:number format="A"/>
              </xsl:when>
              <xsl:when test="@reference='roman'">
                <xsl:number format="i"/>
              </xsl:when>
              <xsl:when test="@reference='ROMAN'">
                <xsl:number format="I"/>
              </xsl:when>
              <xsl:otherwise>
                <!-- ie 'number' -->
                <xsl:number format="1"/>
              </xsl:otherwise>
            </xsl:choose>
          </xsl:attribute>
          <xsl:if test="@status != 'complete'">
            <xsl:attribute name="class">
              <xsl:value-of select="@status"/>
            </xsl:attribute>
          </xsl:if>
          <xsl:apply-templates/>
        </ol>
      </xsl:when>
      <!-- otherwise it's bulleted -->
      <xsl:otherwise>
        <ul>
          <xsl:if test="@status != 'complete'">
            <xsl:attribute name="class">
              <xsl:value-of select="@status"/>
            </xsl:attribute>
          </xsl:if>
          <xsl:apply-templates/>
        </ul>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template match="item[not(topic)][not(ancestor::para)]">
    <li>
      <xsl:apply-templates/>
    </li>
  </xsl:template>

  <xsl:template match="para/list | para/sequence">
    <xsl:apply-templates/>
  </xsl:template>

  <xsl:template match="para/list/item">
    <xsl:choose>
      <xsl:when test="position() != last() and
                      position() &gt; 1">
        <xsl:text>; </xsl:text>
      </xsl:when>
      <xsl:when test="position()=last()">
        <xsl:text>; or </xsl:text>
      </xsl:when>
      <xsl:otherwise>
        <xsl:text></xsl:text>
      </xsl:otherwise>
    </xsl:choose>
    <i>
      <xsl:number format="a"/>
    </i>
    <xsl:text>)&#x00A0;</xsl:text>
    <xsl:apply-templates/>
  </xsl:template>

  <xsl:template match="para/sequence/item">
    <xsl:choose>
      <xsl:when test="position() != last() and
                      position() &gt; 1">
        <xsl:text>; </xsl:text>
      </xsl:when>
      <xsl:when test="position()=last()">
        <xsl:text>; and </xsl:text>
      </xsl:when>
      <xsl:otherwise>
        <xsl:text></xsl:text>
      </xsl:otherwise>
    </xsl:choose>
    <i>
      <xsl:number format="a"/>
    </i>
    <xsl:text>)&#x00A0;</xsl:text>
    <xsl:apply-templates/>
  </xsl:template>

  <xsl:template match="para/list/item/para | para/sequence/item/para">
    <xsl:apply-templates/>
  </xsl:template>

  <!-- labels are handled in the template for para -->

  <xsl:template match="label/para" mode="outofline">
    <xsl:apply-templates/>
  </xsl:template>

  <xsl:template match="label"/>

  <xsl:template match="item/para">
        <p>
      <xsl:attribute name="class">
        <xsl:choose>
          <xsl:when test="@type != 'normal'">
            <xsl:value-of select="@type"/>
          </xsl:when>
          <xsl:when test="@status != 'complete'">
            <xsl:value-of select="@status"/>
          </xsl:when>
          <xsl:otherwise>
            <xsl:text>normal</xsl:text>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:attribute>
      <xsl:choose>
        <xsl:when test="@type='addition'">
          <a href="#codes" title="What's this?">
            <img border="0" alt="Addition"
              src="http://www.silmaril.ie/images/caret.gif"/>
          </a>
          <xsl:text>&#x00A0;</xsl:text>
        </xsl:when>
        <xsl:when test="@status='revised'">
          <a href="#codes" title="What's this?">
            <img border="0" alt="Revised"
              src="http://www.silmaril.ie/images/configure.png"/>
          </a>
          <xsl:text>&#x00A0;</xsl:text>
        </xsl:when>
      </xsl:choose>
          <xsl:if test="name(preceding-sibling::*[1])='label'">
            <b>
              <xsl:apply-templates select="preceding-sibling::label/para" 
                mode="outofline"/>
            </b>
            <xsl:text>:&#x00A0;&#x00A0;</xsl:text>
          </xsl:if>
          <xsl:apply-templates/>
        </p>
  </xsl:template>

  <xsl:template match="item[topic]">
    <xsl:apply-templates/>
  </xsl:template>

  <xsl:template match="item/topic">
    <dt>
      <xsl:choose>
        <xsl:when test="ancestor::list[@reference]='alpha'">
          <xsl:number count="item" format="a."/>
          <xsl:text> </xsl:text>
        </xsl:when>
        <xsl:when test="ancestor::list[@reference]='ALPHA'">
          <xsl:number count="item" format="A."/>
          <xsl:text> </xsl:text>
        </xsl:when>
        <xsl:when test="ancestor::list[@reference]='number'">
          <xsl:number count="item" format="1."/>
          <xsl:text> </xsl:text>
        </xsl:when>
        <xsl:when test="ancestor::list[@reference]='roman'">
          <xsl:number count="item" format="i."/>
          <xsl:text> </xsl:text>
        </xsl:when>
        <xsl:when test="ancestor::list[@reference]='ROMAN'">
          <xsl:number count="item" format="I."/>
          <xsl:text> </xsl:text>
        </xsl:when>
        <xsl:otherwise>
          <xsl:text></xsl:text>
        </xsl:otherwise>
      </xsl:choose>
      <xsl:apply-templates/>
    </dt>
  </xsl:template>

  <xsl:template match="item[topic]/text">
    <dd>
      <xsl:apply-templates/>
    </dd>
  </xsl:template>

  <!-- mixed content -->

  <xsl:template match="q">
    <xsl:text>&#x2018;</xsl:text>
    <xsl:apply-templates/>
    <xsl:text>&#x2019;</xsl:text>
  </xsl:template>

  <xsl:template match="link">
    <xsl:choose>
      <!-- if the URI is non-blank, it's a link, dammit! -->
      <xsl:when test="@uri != ''">
        <a>
          <xsl:attribute name="href">
            <xsl:if test="contains(@uri,'@')">
              <xsl:text>mailto:</xsl:text>
            </xsl:if>
            <xsl:value-of select="@uri"/>
          </xsl:attribute>
          <xsl:if test="@start-date">
            <xsl:attribute name="title">
              <xsl:call-template name="shortdate">
                <xsl:with-param name="isodate" select="@start-date"/>
              </xsl:call-template>
              <xsl:if test="@end-date">
                <xsl:text>-</xsl:text>
                <xsl:call-template name="shortdate">
                  <xsl:with-param name="isodate" select="@end-date"/>
                </xsl:call-template>
              </xsl:if>
            </xsl:attribute>
          </xsl:if>
          <!-- image only makes sense when there's a URI or text, surely? -->
          <xsl:choose>
            <xsl:when test="@image">
              <xsl:attribute name="target">
                <xsl:text>_new</xsl:text>
              </xsl:attribute>
              <xsl:if test=".!=''">
                <xsl:attribute name="title">
                  <xsl:value-of select="normalize-space(.)"/>
                </xsl:attribute>
              </xsl:if>
              <img src="{@image}" alt="{normalize-space(.)}" border="0"/>
            </xsl:when>
            <xsl:when test=".=''">
              <xsl:choose>
                <xsl:when test="LaTeX">
                  <xsl:apply-templates/>
                </xsl:when>
                <xsl:when test="substring(@uri,1,5)='mail:' or
                                substring(@uri,1,5)='news:'">
                  <tt>
                    <xsl:value-of select="substring-after(@uri,':')"/>
                  </tt>
                </xsl:when>
                <xsl:otherwise>
                  <tt>
                    <xsl:value-of select="@uri"/>
                  </tt>
                </xsl:otherwise>
              </xsl:choose>
            </xsl:when>
            <xsl:otherwise>
              <xsl:choose>
                <xsl:when test="LaTeX">
                  <xsl:apply-templates select="LaTeX"/>
                </xsl:when>
                <xsl:otherwise>
                  <xsl:apply-templates/>
                </xsl:otherwise>
              </xsl:choose>
            </xsl:otherwise>
          </xsl:choose>
        </a>
      </xsl:when>
      <!-- if the URI is empty, but there's an IDREF, use that instead -->
      <xsl:when test="@uri='' and @to != ''">
        <xsl:variable name="thisid" select="@to"/>
        <xsl:if test=".=''">
          <xsl:text>&#x2018;</xsl:text>
        </xsl:if>
        <a href="#{@to}">
          <xsl:choose>
            <!-- if there's an image, use it -->
            <xsl:when test="@image">
              <xsl:attribute name="target">
                <xsl:text>_new</xsl:text>
              </xsl:attribute>
              <img border="0" src="{@image}">
                <xsl:attribute name="alt">
                  <xsl:choose>
                    <xsl:when test=".=''">
                      <xsl:value-of select="normalize-space(
                                        //entry[@id=$thisid]/topic/para)"/>
                    </xsl:when>
                    <xsl:otherwise>
                      <xsl:value-of select="normalize-space(.)"/>
                    </xsl:otherwise>
                  </xsl:choose>
                </xsl:attribute>
              </img>
            </xsl:when>
            <!-- if the content is null, use the heading of the target -->
            <xsl:when test=".=''">
              <xsl:apply-templates select="//entry[@id=$thisid]/topic/para"/>
            </xsl:when>
            <xsl:otherwise>
              <xsl:apply-templates mode="inlink"/>
            </xsl:otherwise>
          </xsl:choose>
        </a>
        <xsl:if test=".=''">
          <xsl:text>&#x2019;</xsl:text>
          <xsl:text> </xsl:text>
          <xsl:choose>
            <xsl:when 
              test="ancestor::entry/preceding-sibling::entry[@id=$thisid]">
              <xsl:text>above</xsl:text>
            </xsl:when>
            <xsl:when 
              test="ancestor::entry/following-sibling::entry[@id=$thisid]">
              <xsl:text>below</xsl:text>
            </xsl:when>
            <xsl:otherwise>
              <xsl:text>elsewhere in this entry</xsl:text>
            </xsl:otherwise>
          </xsl:choose>
        </xsl:if>
      </xsl:when>
      <!-- if the URI is empty, but there's a CDATA "id" in elsewhere, 
        use that instead -->
      <xsl:when test="@uri='' and @elsewhere != ''">
        <xsl:variable name="thisid" select="@elsewhere"/>
        <xsl:if test=".=''">
          <xsl:text>&#x2018;</xsl:text>
        </xsl:if>
        <a href="#{@elsewhere}">
          <xsl:choose>
            <!-- if there's an image, use it -->
            <xsl:when test="@image">
              <xsl:attribute name="target">
                <xsl:text>_new</xsl:text>
              </xsl:attribute>
              <img border="0" src="{@image}">
                <xsl:attribute name="alt">
                  <xsl:choose>
                    <xsl:when test=".=''">
                      <xsl:value-of select="normalize-space(
                                        //entry[@id=$thisid]/topic/para)"/>
                    </xsl:when>
                    <xsl:otherwise>
                      <xsl:value-of select="normalize-space(.)"/>
                    </xsl:otherwise>
                  </xsl:choose>
                </xsl:attribute>
              </img>
            </xsl:when>
            <!-- if the content is null, use the heading of the target -->
            <xsl:when test=".=''">
              <xsl:apply-templates select="//entry[@id=$thisid]/topic/para"/>
            </xsl:when>
            <xsl:otherwise>
              <xsl:apply-templates mode="inlink"/>
            </xsl:otherwise>
          </xsl:choose>
        </a>
        <xsl:if test=".=''">
          <xsl:text>&#x2019;</xsl:text>
          <xsl:text> </xsl:text>
          <xsl:choose>
            <xsl:when 
              test="ancestor::entry/preceding-sibling::entry[@id=$thisid]">
              <xsl:text>above</xsl:text>
            </xsl:when>
            <xsl:when 
              test="ancestor::entry/following-sibling::entry[@id=$thisid]">
              <xsl:text>below</xsl:text>
            </xsl:when>
            <xsl:otherwise>
              <xsl:text>elsewhere in this entry</xsl:text>
            </xsl:otherwise>
          </xsl:choose>
        </xsl:if>
      </xsl:when>
      <xsl:otherwise>
        <xsl:apply-templates mode="inlink"/>
        <xsl:text> [unknown link]</xsl:text>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template match="TeX" mode="inlink">
    <xsl:text>TeX</xsl:text>
  </xsl:template>

  <xsl:template match="LaTeX" mode="inlink">
    <xsl:text>LaTeX</xsl:text>
  </xsl:template>

  <xsl:template match="document">
    <cite>
      <xsl:choose>
        <xsl:when test="@uri=''">
          <xsl:apply-templates/>
        </xsl:when>
        <xsl:otherwise>
          <a href="{@uri}">
            <xsl:choose>
              <xsl:when test="@title">
                <xsl:value-of select="@title"/>
              </xsl:when>
              <xsl:otherwise>
                <xsl:choose>
                  <xsl:when test=".=''">
                    <xsl:value-of select="document(@uri)//title[1]"/>
                  </xsl:when>
                  <xsl:otherwise>
                    <xsl:value-of select="normalize-space(.)"/>
                  </xsl:otherwise>
                </xsl:choose>
              </xsl:otherwise>
            </xsl:choose>
          </a>
        </xsl:otherwise>
      </xsl:choose>
    </cite>
  </xsl:template>

  <xsl:template match="code[ancestor::para]">
    <code>
      <xsl:apply-templates/>
    </code>
  </xsl:template>

  <xsl:template match="emph">
    <em>
      <xsl:apply-templates/>
    </em>
  </xsl:template>

  <!-- ===================== links ===================== -->

  <xsl:template match="links">
    <div class="links">
      <h4>
        <a name="{@id}">
          <xsl:value-of select="title"/>
        </a>
      </h4>
      <xsl:if test="@id='neat'">
        <script type="text/javascript" src="http://technorati.com/embed/9bqrd9jnn.js"> </script>
      </xsl:if>
      <xsl:choose>
        <xsl:when test="@id='meetings'">
          <!--h6>Been'n'gone</h6-->
          <xsl:for-each select="topic/para/link">
            <xsl:sort select="translate(@start-date,'-','')"/>
            <xsl:apply-templates select="parent::para"/>
          </xsl:for-each>
        </xsl:when>
        <xsl:otherwise>
          <xsl:apply-templates/>
        </xsl:otherwise>
      </xsl:choose>
    </div>
  </xsl:template>

  <xsl:template match="links/title"/>

  <xsl:template match="links/topic/para">
    <!-- check before the first event to get the heading right -->
    <xsl:if test="count(preceding-sibling::para)=0">
      <xsl:if test="link[@start-date][@end-date] and
                    name(child::*[1])='link'">
        <xsl:choose>
          <xsl:when test="translate($isodate,'-','') &gt; 
                          translate(link[1]/@end-date,'-','')">
            <h6>Been'n'gone</h6>
          </xsl:when>
          <xsl:otherwise>
            <h6>Upcoming</h6>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:if>
    </xsl:if>
    <!-- then check at each stage to see if the heading needs changing -->
    <xsl:if test="translate($isodate,'-','') &lt; 
                  translate(link[1]/@end-date,'-','') and
                  translate($isodate,'-','') &gt; 
                  translate(preceding-sibling::para[1]/link[1]/@end-date,'-','')">
      <h6>Upcoming</h6>
    </xsl:if>
    <p>
      <xsl:if test="@id">
        <xsl:attribute name="name">
          <xsl:value-of select="@id"/>
        </xsl:attribute>
      </xsl:if>
      <xsl:attribute name="class">
        <xsl:choose>
          <xsl:when test="@type != 'normal'">
            <xsl:value-of select="@type"/>
          </xsl:when>
          <xsl:when test="@status != 'complete'">
            <xsl:value-of select="@status"/>
          </xsl:when>
          <xsl:otherwise>
            <xsl:text>link</xsl:text>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:attribute>
      <xsl:choose>
        <xsl:when test="@type='addition'">
          <a href="#codes" title="What's this?">
            <img border="0" alt="Addition"
              src="http://www.silmaril.ie/images/caret.gif"/>
          </a>
          <xsl:text>&#x00A0;</xsl:text>
        </xsl:when>
        <xsl:when test="@status='revised'">
          <a href="#codes" title="What's this?">
            <img border="0" alt="Revised"
              src="http://www.silmaril.ie/images/configure.png"/>
          </a>
          <xsl:text>&#x00A0;</xsl:text>
        </xsl:when>
      </xsl:choose>
      <a name="{@id}">
        <xsl:apply-templates/>
      </a>
    </p>
  </xsl:template>

  <xsl:template name="shortdate">
    <xsl:param name="isodate"/>
    <xsl:variable name="month" select="number(substring($isodate,6,2))"/>
    <xsl:variable name="monthname">
      <xsl:text>JanFebMarAprMayJunJulAugSepOctNovDec</xsl:text>
    </xsl:variable>
    <xsl:value-of select="substring($monthname,($month - 1)*3+1,3)"/>
    <xsl:value-of select="substring($isodate,9,2)"/>
  </xsl:template>

  <xsl:template match="acro">
    <xsl:variable name="resource">
      <xsl:text>http://www.ucc.ie/cgi-bin/exact-acronym?</xsl:text>
      <xsl:value-of select="."/>
    </xsl:variable>
    <xsl:variable name="acro" select="document($resource)"/>
    <xsl:variable name="acros" select="count($acro//acronym)"/>
    <xsl:choose>
      <xsl:when test="$acros=0">
        <a href="{$resource}" title="Unknown acronym" target="_new">
          <xsl:apply-templates/>
        </a>
      </xsl:when>
      <xsl:otherwise>
        <a href="http://www.ucc.ie/cgi-bin/acronym?{.}" target="_new">
          <xsl:attribute name="title">
            <xsl:value-of select="$acro//acronym[1]/expansion"/>
            <xsl:if test="$acro//acronym[1]/comment!=''">
              <xsl:text> (</xsl:text>
              <xsl:value-of select="$acro//acronym[1]/comment"/>
              <xsl:text>)</xsl:text>
            </xsl:if>
            <xsl:if test="$acros>1">
              <xsl:text> [more...]</xsl:text>
            </xsl:if>
          </xsl:attribute>
          <xsl:value-of select="$acro//acronym[1]/@acro"/>
        </a>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template match="TeX">
    <dfn><span class="TEX">T<span class="E">E</span>X</span></dfn>
  </xsl:template>

  <xsl:template match="LaTeX">
    <dfn><span class="LATEX">L<span class="A">A</span><span class="TEX">T<span class="E">E</span>X</span></span></dfn>
  </xsl:template>

  <xsl:template match="ConTeXt">
    <dfn>Con<span class="TEX">T<span class="E">E</span>X</span>t</dfn>
  </xsl:template>

  <xsl:template match="BIBTeX">
    <dfn>BIB<span class="TEX">T<span class="E">E</span>X</span></dfn>
  </xsl:template>

  <xsl:template match="prod">
    <i>
      <xsl:apply-templates/>
    </i>
  </xsl:template>

  <xsl:template match="format">
    <span>
      <xsl:attribute name="style">
        <xsl:if test="@font">
          <xsl:text>font-family:</xsl:text>
          <xsl:value-of select="@font"/>
          <xsl:text>; </xsl:text>
        </xsl:if>
        <xsl:if test="@size">
          <xsl:text>font-size:</xsl:text>
          <xsl:value-of select="@size"/>
          <xsl:text>; </xsl:text>
        </xsl:if>
        <xsl:if test="@color">
          <xsl:text>color:</xsl:text>
          <xsl:value-of select="@color"/>
          <xsl:text>; </xsl:text>
        </xsl:if>
        <xsl:if test="@style">
          <xsl:if test="@style='bold'">
            <xsl:text>font-weight:bold; </xsl:text>
          </xsl:if>
          <xsl:if test="@style='italic'">
            <xsl:text>font-style:italic; </xsl:text>
          </xsl:if>
          <xsl:if test="@style='normal'">
            <xsl:text>font-weight:normal; </xsl:text>
          </xsl:if>
        </xsl:if>
      </xsl:attribute>
      <xsl:apply-templates/>
    </span>
  </xsl:template>

</xsl:stylesheet>

