<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output method="xml" indent="yes" omit-xml-declaration="no" encoding="ISO-8859-1" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"/>
	
	<!--Plantilla de terminologia oberta-->
	<xsl:template match="terminologiaoberta">
		<html xml:lang="ca-ES">
			<head>
				<title>TERMCAT, de XML a XHTML</title>
				<link rel="stylesheet" href="to.css" type="text/css" />
			</head>
			<body>
				<h1>TERMCAT, de XML a XHTML</h1>
				<p>Aquesta és una adaptació al XHTML del document <a href="http://www.termcat.net/productes/toberta/TO%20Internet%20i%20Societat%20de%20la%20Informaci%F3.xml"><xsl:value-of select="titol"/></a>.</p>
				<p>L'adaptació s'ha realitzat mitjançant XSL. <a href="to.xsl">Veure el full d'estils XSL emprat</a>.</p>
				<div id="llegenda">
					<h2>Llegenda</h2>
					<ul>
						<li>
							<strong>Tipus: principal</strong>
						</li>
						<li>
							<em>Tipus: pemissió</em>
						</li>
						<li>
							<span class="sigla">Jerarquia: sigla</span>
						</li>
					</ul>
				</div>
				<h2><xsl:value-of select="titol"/></h2>
				<p>Autor: <xsl:value-of select="autor"/></p>
				<table>
					<tr>
						<th>Catalŕ</th>
						<th>Castellano</th>
						<th>English</th>
					</tr>
					<xsl:apply-templates select="fitxes/fitxa"/>
				</table>
			</body>
		</html>
	</xsl:template>	
	
	<!--Plantilla de fitxa-->
	<xsl:template match="fitxa">
		<tr>
			<xsl:attribute name="id">fitxa-<xsl:value-of select="@num"/></xsl:attribute>
			<xsl:call-template name="cella" >
            	<xsl:with-param name="llengua" >ca</xsl:with-param>
            </xsl:call-template>
			<xsl:call-template name="cella" >
            	<xsl:with-param name="llengua" >es</xsl:with-param>
            </xsl:call-template>
			<xsl:call-template name="cella" >
            	<xsl:with-param name="llengua" >en</xsl:with-param>
            </xsl:call-template>
		</tr>
	</xsl:template>
	
	<!--Plantilla per a les celˇles de la taula-->
	<xsl:template name="cella">
		<xsl:param name="llengua" />
		<td class="{$llengua}">
			<xsl:if test="count(denominacio[@llengua=$llengua]) > 0">
				<ul>
					<xsl:apply-templates select="denominacio[@llengua=$llengua]"/>
				</ul>
			</xsl:if>
		</td>
	</xsl:template>
	
	<!--Plantilla de denominacio-->
	<xsl:template match="denominacio">
			<li>
				<xsl:if test="@jerarquia='sigla'">
					<xsl:attribute name="class">
						<xsl:value-of select="@jerarquia"/>
					</xsl:attribute>
				</xsl:if>
				<xsl:if test="@categoria!=''">
					<xsl:attribute name="title">
						<xsl:value-of select="@categoria"/>
					</xsl:attribute>
				</xsl:if>
				<xsl:if test="@tipus='principal'">
					<strong><xsl:value-of select="." /></strong>
				</xsl:if>
				<xsl:if test="@tipus='remissio'">
					<em><xsl:value-of select="." /></em>
				</xsl:if>
				<xsl:if test="@tipus='equivalent'">
					<xsl:value-of select="." />
				</xsl:if>
			</li>
	</xsl:template>

</xsl:stylesheet>