<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" encoding="ISO-8859-1" method="xml" version="1.0"/>
	<xsl:template match="/">
		<html>
			<head>
				<meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type"/>
				<title> Helian henkilöstö </title>
				<style type="text/css"> &lt;!-- h2 {text-align: center; } .harmaa
                    {background-color: silver; } --&gt; </style>
			</head>
			<body>
				<h2> Henkilöstö </h2>
				<table border="1" cellpadding="5" cellspacing="0" width="90%">
					<tr class="harmaa">
						<th>Nimi</th>
						<th>Email</th>
						<th>Työhuone</th>
						<th>Puhelin</th>
					</tr>
					<xsl:apply-templates select="henkilosto/henkilo">
						<xsl:sort select="nimi/sukunimi"/>
						<xsl:sort select="nimi/etunimi"/>
					</xsl:apply-templates>
				</table>
			</body>
		</html>
	</xsl:template>
	<xsl:template match="henkilo">
		<tr>
			<td>
				<b>
					<xsl:value-of select="nimi/sukunimi"/> &#160;<xsl:value-of select="nimi/etunimi"/>
				</b>
			</td>
			<td>
				<xsl:value-of select="email"/>
			</td>
			<td>
				<xsl:choose>
					<xsl:when test="not (tyohuone)">&#160;</xsl:when>
					<xsl:otherwise>
						<xsl:value-of select="tyohuone"/> (<xsl:value-of select="tyohuone/@sijainti"/>)
					</xsl:otherwise>
				</xsl:choose>
			</td>
			<td>
				<xsl:apply-templates select="puhelin"/>
			</td>
		</tr>
	</xsl:template>
	<xsl:template match="puhelin">
		<xsl:value-of select="."/> (<xsl:value-of select="@type"/>)<xsl:if test="position() &lt; last()">, <br/>
		</xsl:if>
	</xsl:template>
</xsl:stylesheet>
