<?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:param name="stdpath" select="'./AnsForth/dpans'" />

<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;font-family: serif}
	a {text-decoration:none;}
	span.unknown {color: gray;}
	span.commentary {color: green; font-style: italic;}
	span.numeric {color: orange;} 
	span.errors {color: red;}
	span.values {color: purple;}
	span.userwords {color: black;}
	span.userdefiner {color: teal;}
	span.variables {color: fuchsia;}
	span.core_ws {color: blue;}
	span.core_ext_ws {color: black;}
	span.block_ws {color: black;}
	span.double_ws {color: black;}
	span.exception_ws {color: black;}
	span.facilities_ws {color: black;}
	span.file_ws {color: black;}
	span.fp_ws {color: black;}
	span.local_ws {color: black;}
	span.malloc_ws {color: black;}
	span.progtools_ws {color: black;}
	span.searchord_ws {color: black;}
	span.string_ws {color: black;}
    </style>
    <title><xsl:value-of select="module"/></title>
    </head>
    <body>
	<xsl:apply-templates select="module" mode="header"/>
	<p>
	    <xsl:apply-templates />
	</p>
    </body>
</html>
</xsl:template>

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

<xsl:template match="module">
    <!-- don't emit anything unless it's the header -->
</xsl:template>

<xsl:template match="tag">
    <span class="{@type}">
	<xsl:apply-templates/> 
    </span>
</xsl:template>

<xsl:template match="z">
    <br />
    <xsl:value-of select="."/>
</xsl:template>

<xsl:template match="a">
    <xsl:choose>
	<xsl:when test="@file">
	    <a href="{substring-before(@file,'.xml')}.htm{@href}"><xsl:apply-templates/></a>
	</xsl:when>
	<xsl:when test="@href">
	    <a href="{@href}"><xsl:apply-templates/></a>
	</xsl:when>
	<xsl:when test="@name">
	    <a name="{@name}"><xsl:apply-templates/></a>
	</xsl:when>
	<xsl:when test="@std">
	    <a href="{$stdpath}{substring-before(substring-after(@std,'#'),'.')}.htm{@std}">
		<xsl:apply-templates/>
	    </a>
	</xsl:when>
	<xsl:otherwise>
	    <a><xsl:apply-templates/></a>
	</xsl:otherwise>
    </xsl:choose>
</xsl:template>

<xsl:template match="bl">
    <xsl:text>&#160;</xsl:text>
</xsl:template>

<xsl:template match="br">
    <xsl:copy-of select="."/>
</xsl:template>

</xsl:stylesheet>
