<?xml version="1.0"?>
<xsl:stylesheet version="1.0" 
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns="http://www.w3.org/1999/xhtml">

<xsl:template match="/">
	<html>
		<head>
			<title><xsl:value-of select="paper/title"/></title>
			<link>
				<xsl:attribute name="rel">
					<xsl:text>stylesheet</xsl:text>
				</xsl:attribute>
				<xsl:attribute name="type">
					<xsl:text>text/css</xsl:text>
				</xsl:attribute>
				<xsl:attribute name="href">
					<xsl:text>http://www.johndavis.ca/styles/slaw_201307.css</xsl:text>
				</xsl:attribute>
				<xsl:attribute name="title">
					<xsl:text>outline</xsl:text>
				</xsl:attribute>
			</link>
		</head>
		<body>
			<xsl:apply-templates/>
		</body>
	</html>
</xsl:template>

<xsl:template match="title">
	<h1><xsl:apply-templates/></h1>
</xsl:template>

<xsl:template match="em">
	<em><xsl:apply-templates/></em>
</xsl:template>

<xsl:template match="updated">
	<p class="updated"><xsl:apply-templates/></p>
</xsl:template>

<xsl:template match="paragraph">
	<p>[<xsl:number count="paragraph" level="any" format="1"/>]
		<xsl:apply-templates mode="inline"/>
	</p>
	<xsl:if test="count(footnote) != 0">
		<table class="footnote">
			<xsl:apply-templates select="footnote" mode="body"/>
		</table>
	</xsl:if>
</xsl:template>

<xsl:template match="footnote" mode="inline">
	<span class="footnote"><xsl:number count="footnote" level="any" format="1"/></span>
</xsl:template>

<xsl:template match="footnote" mode="body">
	<tr>
		<td class="footnote" valign="top"><xsl:text>Note </xsl:text></td>
		<td class="footnote" valign="top"><xsl:number count="footnote" level="any" format="1: "/></td>
		<td class="footnote"><xsl:text>  </xsl:text></td>
		<td class="footnote" valign="top"><xsl:apply-templates/></td>
	</tr>
</xsl:template>

<xsl:template match="pararef" mode="inline">
	<xsl:for-each select="id(@pidref)">
		<xsl:number count="paragraph" level="any" format="1"/>
	</xsl:for-each>
</xsl:template>

<xsl:template match="pararef">
	<xsl:for-each select="id(@pidref)">
		<xsl:number count="paragraph" level="any" format="1"/>
	</xsl:for-each>
</xsl:template>

<xsl:template match="footref" mode="inline">
	<xsl:for-each select="id(@fidref)">
		<xsl:number count="footnote" level="any" format="1"/>
	</xsl:for-each>
</xsl:template>

<xsl:template match="footref">
	<xsl:for-each select="id(@fidref)">
		<xsl:number count="footnote" level="any" format="1"/>
	</xsl:for-each>
</xsl:template>


</xsl:stylesheet>
