<?xml version="1.0" encoding="iso-8859-1"?>

<xsl:stylesheet    
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        version="1.0">
<xsl:output 
	method="xml" indent="yes"
	doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
	doctype-system="http://www.w3.org/TR/xhtml/DTD/xhtml-strict.dtd" 
	encoding="ASCII"/>

<xsl:strip-space elements="*"/>

<xsl:template match="forth">
<html xml:lang="en" lang="en">
    <head>
    <style type="text/css" xml:space="preserve">
	body {background: white; font-family: monospace;}
	h1 {color: black;background:silver;padding:1em;font-family: serif}
	a {text-decoration:none;}
	table {border:3px solid gray;margin-left:2em;}
	th {text-align: left; background:silver;}
    </style>
    <title>Cross reference for <xsl:value-of select="module"/></title>
    </head>
    <body>
	<xsl:apply-templates select="module" mode="header"/>
	<h2>Word reference count</h2>
	    <table summary="word usage counts">
		<thead>
		    <tr>
			<th>word</th>
			<th>count</th>
		    </tr>
		</thead>
		<tbody>
		    <xsl:apply-templates select="//a[@name]">
			<xsl:sort select="@name"/>
		    </xsl:apply-templates>
		</tbody>
	    </table>
    </body>
</html>
</xsl:template>

<xsl:template match="module" mode="header">
    <h1>Cross reference for <a href="{.}"><xsl:value-of select="."/></a></h1>
</xsl:template>

<xsl:template match="a">
    <xsl:variable name="myname" select="concat('#',@name)"/>
    <tr>
	<td>
	    <a href="{concat(substring-before(//module,'.'),'.htm',$myname)}">
	    <xsl:value-of select="tag"/></a>
	</td><td>
	    <xsl:value-of select="count(//a[@href=$myname])"/>
	</td>
    </tr>
</xsl:template>

</xsl:stylesheet>
