<?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:output method="xml" indent="yes" encoding="utf-8" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"/>
	<xsl:template match="/">
		<html xmlns="http://www.w3.org/1999/xhtml">
			<head>
        <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8"/>
        <title> Tilavaraukset </title>
			</head>
			
			<body>
				<div id="viikot">
					<xsl:variable name="viikko" select="/tilavaraukset/varaukset/varaus/ajankohta/viikot/viikko"/>
					<xsl:apply-templates select="$viikko[not(.=following::viikko)]" />
				</div>
				
			</body>
		</html>	
	</xsl:template>
	<xsl:template match="viikko">
		<xsl:variable name="viik" select="." />
		<h2>Viikko <xsl:value-of select="."/></h2>
		<xsl:variable name="tila" select="//varaus/tila" />
		<xsl:apply-templates select="$tila[not(.=following::tila) and ../ajankohta/viikot/viikko=$viik]" />
	</xsl:template>
	<xsl:template match="varaus/tila">
		<p>
			<xsl:variable name="tila" select="."/>
			Tila: <xsl:value-of select="."/><br />
			Yksikkö:
			<xsl:apply-templates select="../kayttotarkoitus/yksikko[../../tila=$tila]" /> <br/>
		</p>

	</xsl:template>
	<xsl:template match="tila">
		<xsl:value-of select="."/>
	</xsl:template>
	
<!--
	<xsl:template match="tilat/tila">
			Nimi: <xsl:value-of select="nimi"/><br/>
			Koko: <xsl:value-of select="koko"/><br/>
			Tietokoneet: <xsl:value-of select="varustelu/tietokoneet"/><br/>
	                Videotykki: <xsl:value-of select="varustelu/videotykki"/><br/>
	                Muuta: <xsl:value-of select="varustelu/muuta"/>
	</xsl:template> -->
</xsl:stylesheet>

