<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE xsl:stylesheet [<!ENTITY nbsp "&#160;">]>
<xsl:stylesheet version='1.0' xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="/">
    <!-- Table of contents -->
    <table>
      <tr>
	<th>Name</th>
	<th>Platform</th>
	<th>Language</th>
	<th>Status</th>
      </tr>
      <!-- Put in the MUDs -->
      <xsl:apply-templates select="newmud-list/codebase" mode="toc">
	<xsl:sort select="name" order="ascending"/>
      </xsl:apply-templates>
    </table>

    <!-- Now put them in again, this time as body text with full details-->
    <xsl:apply-templates select="newmud-list/codebase" mode="body">
      <xsl:sort select="name" order="ascending"/>
    </xsl:apply-templates>

  </xsl:template>

  <!-- Generic stuff that translates into HTML -->
  <xsl:template match="link">
    <a href="{@href}">
      <xsl:apply-templates/>
    </a>
  </xsl:template>

  <xsl:template match="break">
    <br><xsl:text>&nbsp;</xsl:text>
    </br> <!-- For netscape -->
  </xsl:template>
	
  <xsl:template match="url">
   <a href="{.}"><xsl:value-of select="."/></a>
  </xsl:template>

  
  <!-- An entry rendered in the table of contents -->
  <xsl:template match="codebase" mode="toc">
    <tr>
      <xsl:if test="position() mod 2 = 0">
	<xsl:attribute name="bgcolor">#dcdcdc</xsl:attribute>
      </xsl:if>
      <td>
        <xsl:if test="count(@dead)">
          <xsl:attribute name="style">
            text-decoration: line-through;
          </xsl:attribute>
          <xsl:attribute name="title">Defunct? Web site no longer reachable</xsl:attribute>
        </xsl:if>
	<a href="#{name/@tag}">
	  <xsl:value-of select="name"/>
	  <xsl:if test="count(@new)">
	    <img border="0" src="/images/new.gif"/>
	  </xsl:if>
	</a>
      </td>

      <td>
        <xsl:attribute name="title">Technology:<xsl:value-of select="technology"/></xsl:attribute>
	<xsl:value-of select="platforms"/>
      </td>

      <td>
	<xsl:value-of select="language"/>
      </td>

      <td>
	<xsl:value-of select="status"/>
      </td>
    </tr>
  </xsl:template>

  <!-- An entry rendered in the body -->
  <xsl:template match="codebase" mode="body">
    <h2>
      <a name="{name/@tag}">
	<xsl:value-of select="name"/>
        <xsl:if test="@dead">
          <span style='font-size: smaller'> (down as of <xsl:value-of select="@dead"/>)</span>
        </xsl:if>
	</a>
      -
      <a href="{url}">
        <xsl:if test="count(@dead)">
          <xsl:attribute name="style">
            text-decoration: line-through;
          </xsl:attribute>
          <xsl:attribute name="rel">nofollow</xsl:attribute>            
        </xsl:if>
        <xsl:value-of select="url"/>
      </a>
      <xsl:if test="count(@new)">
	<img src="/images/new.gif"/>
      </xsl:if>
    </h2>

    <table>
      <tr>
	<th align="left">Principal Authors:</th>
	<td>
	  <xsl:for-each select="authors/author">

	    <xsl:choose>
	      <xsl:when test="count(email)">
		<a href="mailto:{email}">
		  <xsl:value-of select="name"/>
		</a>
	      </xsl:when>
	      <xsl:otherwise>
		<xsl:value-of select="name"/>
	      </xsl:otherwise>
	    </xsl:choose>
	      

	    <xsl:choose>
	      <xsl:when test="position() = last()-1"> and </xsl:when>
	      <xsl:when test="position() != last()"> , </xsl:when>
	    </xsl:choose>

	  </xsl:for-each>.
	</td>
      </tr>

      <tr>
	<th align="left">Status:</th>
	<td><xsl:apply-templates select="status"/></td>
      </tr>

      <tr>
	<th align="left">Timeline:</th>
	<td><xsl:apply-templates select="timeline"/></td>
      </tr>
      
      <tr>
	<th align="left">License:</th>
	<td><xsl:apply-templates select="license"/></td>
      </tr>
      
      <tr>
	<th align="left">Technology:</th>
	<td>
	  <xsl:apply-templates select="language"/>
	  <xsl:if test="count(technology)">
	    . 
	    <xsl:apply-templates select="technology"/>
	  </xsl:if>
	</td>
      </tr>

      <tr>
	<th align="left">Platforms:</th>
	<td><xsl:apply-templates select="platforms"/></td>
      </tr>
      
    </table>
    

    <p>
      <xsl:apply-templates select="description"/>
    </p>
  </xsl:template>
  
</xsl:stylesheet>
