<?xml version="1.0" encoding="UTF-8"?>
<!-- Check Output: "Also read Kernighan's Tutorial" -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"
doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"
doctype-public="-//W3C//DTD XHTML 1.1//EN"/>

<xsl:template match="links">
	<html><head><title>Links</title>
	<style type="text/css">
	ul { margin-left: 0px; padding-left: 0px;}
	dt.htop { font-size: x-large; font-weight: bold;
		 padding-bottom: .5ex;}
	dt.hsub { font-size: large; font-weight: bold;
		 padding-bottom: .5ex; padding-top: .5ex;} 
	p.small { font-size: small; }
	//dl.dl2 {margin-left: 3em; }
	span.warn { color: #FF0000; }
	h1 {text-align: center; }
	a.anchor { font-size: xx-small; vertical-align: top;}
	<xsl:apply-templates select="notices" />
	</style>
	</head>
	<body>
	<h1>Links</h1>
	<p class="small">These links were last maintained: <span class="date"><xsl:value-of select="date"/></span></p>
	<p>If one of them is broken or moved, <strong>I don't know about it</strong>.
		<a href="mailto:dturover@student.santarosa.edu">e-mail me</a>.
	</p>
	<xsl:apply-templates select="list">
		<xsl:with-param name="dtclass" select="'htop'"/>
	</xsl:apply-templates>
	<hr/>
	<p class="small">If any of these links are broken, <a href="mailto:dturover@student.santarosa.edu">email me!</a></p>
	</body></html>
</xsl:template>

<xsl:template match="list">
	<xsl:param name="dtclass" select="'hsub'"/>
	<dl class="dl2">
	<dt>
		<xsl:attribute name="class"><xsl:value-of select="$dtclass"/></xsl:attribute>
		<xsl:attribute name="id">
			<xsl:value-of select="@id" />
		</xsl:attribute>
		<xsl:value-of select="title" />
		<a class="anchor"><xsl:attribute name="href">#<xsl:value-of select="@id"/></xsl:attribute>*</a>
	</dt>
	<dd>
	<xsl:if test="li">
	<ul>
		<xsl:apply-templates select="li" />
	</ul>
	</xsl:if>
		<xsl:for-each select="list">
			<xsl:apply-templates select="."/>
		</xsl:for-each>
	</dd></dl>
</xsl:template>

<xsl:template match="li">
	<xsl:copy>
		<xsl:apply-templates select="site" />
		<span class="ltxt"><xsl:copy-of select="html/node()" /></span>
		<xsl:apply-templates select="warn" />
		<xsl:apply-templates select="status" />
	</xsl:copy>
</xsl:template>

<xsl:template match="site">
		<a>
			<xsl:attribute name="href">
				<xsl:value-of select="@href"/>
			</xsl:attribute>
			<xsl:copy-of select="node()"/>
		</a><xsl:text> - </xsl:text>
</xsl:template>

<xsl:template match="warn">
	<xsl:text> </xsl:text>
	<span class="warn">
		<xsl:choose>
		<!-- Don't display GIF warnings yet -->
		<xsl:when test=".='GIF'" />
		<xsl:otherwise>
			<xsl:value-of select="." />
		</xsl:otherwise>
		</xsl:choose>
	</span>
</xsl:template>

<xsl:template match="status">
	<xsl:text> </xsl:text> <!-- Add whitespace before the notice -->
	<xsl:choose>
		<xsl:when test=".='Mirror'">
			<span style="color: #009900;">
				<xsl:value-of select="." />
			</span>
		</xsl:when>
		<xsl:otherwise>
		<span class="warn">
			<xsl:value-of select="." />
		</span>
		</xsl:otherwise>
	</xsl:choose>
</xsl:template>

<xsl:template match="notices" mode="setstyles">
	<xsl:for-each select="noticeclass">
		<xsl:if test="@defaultcolor">
		span.<xsl:value-of select="@tag"/> { color: #<xsl:value-of select="@defaultcolor" />}
		</xsl:if>
	</xsl:for-each>
</xsl:template>

<xsl:template match="notice" />
<!-- If I don't have this blank template here, then all notice text
     is displayed even though there is no command which says to
     display it. With this tag, there is a newline where each notice
     tag's text would have been.
-->

</xsl:stylesheet>
