View stylesheet

XML schemas http://air-climate.eionet.europa.eu/schemas/dir199913ec/schema.xsd
Output type HTML
Description HTML factsheet
XSL file dir199913_html.xsl (Last modified: 04 Nov 2008 16:16 )
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml" version="1.0">
	<xsl:output method="xml" indent="no" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" omit-xml-declaration="no" encoding="UTF-8"/>

	<xsl:param name="xml_folder_uri"/>
	<xsl:param name="language" select="'en'"/>

	<!-- import labels xml file -->
	<xsl:variable name="labels_doc" select="document(concat($xml_folder_uri,'dir199913_labels.xml'))/labels"/>
	<xsl:variable name="labels" select="$labels_doc/itemset[@id='199913' and @xml:lang=$language]"/>
	<xsl:variable name="labels_yesno" select="$labels_doc/itemset[@id='yesno' and @xml:lang=$language]"/>

	<xsl:template match="Questionnaire">
		<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="{$language}">
			<head>
				<title>
					<xsl:copy-of select="$labels/item[@id='h1']/text()"/>
				</title>
				<style type="text/css">
.tbl{
	width:100%;
	padding: 0.3em 0em;
	margin-top:0.4em;
}
.tbl th{
	text-align:left;
	border:1px solid #d3d3d3;;
}
.tbl td{
	align:left;
	border:1px solid #d3d3d3;
}
					</style>
			</head>
			<body>
				<h1>
					<xsl:copy-of select="$labels/item[@id='h1']/text()"/>
				</h1>
				<xsl:apply-templates select="*"/>
			</body>
		</html>
	</xsl:template>
	<!-- ##################################          PAGE 1           ############################################-->
	<xsl:template match="Quest199913-q1-a">
		<xsl:call-template name="buildHeading">
			<xsl:with-param name="label_id" select="'q1-h2'"/>
		</xsl:call-template>
		<xsl:call-template name="buildQuestionAndAnswer"/>
	</xsl:template>
	<xsl:template match="Quest199913-q1-b">
		<xsl:call-template name="buildQuestionAndAnswer"/>
	</xsl:template>
	<!-- ##################################       q    2  table           ############################################-->
	<xsl:template match="Quest199913-q2-table">
		<xsl:call-template name="buildHeading">
			<xsl:with-param name="label_id" select="'q2-h2'"/>
		</xsl:call-template>
		<xsl:call-template name="buildQuestion"/>
		<table class="tbl">
			<tbody>
				<tr>
					<th/>
					<th>
						<xsl:copy-of select="$labels/item[@id='q2-col1']/text()"/>
					</th>
					<th>
						<xsl:copy-of select="$labels/item[@id='q2-col2']/text()"/>
					</th>
					<th>
						<xsl:copy-of select="$labels/item[@id='q2-col3']/text()"/>
					</th>
					<th>
						<xsl:copy-of select="$labels/item[@id='q2-col4']/text()"/>
					</th>
					<th>
						<xsl:copy-of select="$labels/item[@id='q2-col5']/text()"/>
					</th>
				</tr>
				<xsl:apply-templates select="Quest199913-q2-row"/>
			</tbody>
		</table>
	</xsl:template>
	<xsl:template match="Quest199913-q2-row">
		<tr>
			<td>
				<xsl:value-of select="Activity/@code"/>
			</td>
			<td>
				<xsl:value-of select="Activity"/>
			</td>
			<td>
				<xsl:value-of select="Existing-installations"/>
			</td>
			<td>
				<xsl:value-of select="Registered-installations"/>
			</td>
			<td>
				<xsl:value-of select="Registered-Art4-installations"/>
			</td>
			<td>
				<xsl:value-of select="IPPC-installations"/>
			</td>
		</tr>
	</xsl:template>
	<xsl:template match="Quest199913-q2-comments">
		<xsl:call-template name="buildAnswer"/>
	</xsl:template>
	<xsl:template match="Quest199913-q3">
		<xsl:call-template name="buildHeading"/>
		<xsl:call-template name="buildQuestionAndAnswer"/>
	</xsl:template>
	<xsl:template match="Quest199913-q4-a">
		<xsl:call-template name="buildHeading">
			<xsl:with-param name="label_id" select="'q4-h2'"/>
		</xsl:call-template>
		<xsl:call-template name="buildQuestion">
			<xsl:with-param name="label_id" select="'q4'"/>
		</xsl:call-template>
		<xsl:call-template name="buildQuestionAndAnswer">
			<xsl:with-param name="onerow" select="true()"/>
		</xsl:call-template>
	</xsl:template>
	<xsl:template match="Quest199913-q4-b">
		<xsl:call-template name="buildQuestionAndAnswer">
			<xsl:with-param name="onerow" select="true()"/>
		</xsl:call-template>
	</xsl:template>
	<xsl:template match="Quest199913-q5-1a">
		<xsl:call-template name="buildHeading">
			<xsl:with-param name="label_id" select="'q5-h2'"/>
		</xsl:call-template>
		<xsl:call-template name="buildQuestion">
			<xsl:with-param name="label_id" select="'q5-1'"/>
		</xsl:call-template>
		<xsl:call-template name="buildQuestionAndAnswer">
			<xsl:with-param name="yesno" select="true()"/>
		</xsl:call-template>
	</xsl:template>
	<xsl:template match="Quest199913-q5-1b">
		<xsl:call-template name="buildQuestionAndAnswer"/>
	</xsl:template>
	<xsl:template match="Quest199913-q5-1c">
		<xsl:call-template name="buildQuestionAndAnswer"/>
	</xsl:template>
	<xsl:template match="Quest199913-q5-2a">
		<xsl:call-template name="buildQuestion">
			<xsl:with-param name="label_id" select="'q5-2'"/>
		</xsl:call-template>
		<xsl:call-template name="buildQuestionAndAnswer"/>
	</xsl:template>
	<xsl:template match="Quest199913-q5-2b">
		<xsl:call-template name="buildQuestionAndAnswer"/>
	</xsl:template>
	<xsl:template match="Quest199913-q5-2c">
		<xsl:call-template name="buildQuestionAndAnswer"/>
	</xsl:template>
	<xsl:template match="Quest199913-q6-1">
		<xsl:call-template name="buildHeading">
			<xsl:with-param name="label_id" select="'q6-h2'"/>
		</xsl:call-template>
		<xsl:call-template name="buildQuestionAndAnswer">
			<xsl:with-param name="yesno" select="true()"/>
		</xsl:call-template>
	</xsl:template>
	<xsl:template match="Quest199913-q6-2a">
		<xsl:call-template name="buildQuestionAndAnswer"/>
	</xsl:template>
	<xsl:template match="Quest199913-q6-2b">
		<xsl:call-template name="buildQuestionAndAnswer"/>
	</xsl:template>
	<xsl:template match="Quest199913-q6-2c">
		<xsl:call-template name="buildQuestionAndAnswer"/>
	</xsl:template>
	<xsl:template match="Quest199913-q6-2d">
		<xsl:call-template name="buildQuestionAndAnswer"/>
	</xsl:template>
	<xsl:template match="Quest199913-q7">
		<xsl:call-template name="buildHeading"/>
		<xsl:call-template name="buildQuestionAndAnswer"/>
	</xsl:template>
	
	<xsl:template match="Quest199913-q8-1a">
		<xsl:call-template name="buildHeading">
			<xsl:with-param name="label_id" select="'q8-h2'"/>
		</xsl:call-template>
		<xsl:call-template name="buildQuestion">
			<xsl:with-param name="label_id" select="'q8-1'"/>
		</xsl:call-template>
		<xsl:call-template name="buildQuestionAndAnswer">
			<xsl:with-param name="onerow" select="true()"/>
		</xsl:call-template>
	</xsl:template>
	<xsl:template match="Quest199913-q8-1b">
		<xsl:call-template name="buildQuestionAndAnswer">
			<xsl:with-param name="onerow" select="true()"/>
		</xsl:call-template>
	</xsl:template>
	<xsl:template match="Quest199913-q8-1c">
		<xsl:call-template name="buildQuestionAndAnswer"/>
	</xsl:template>
	<xsl:template match="Quest199913-q8-2a">
		<xsl:call-template name="buildQuestion">
			<xsl:with-param name="label_id" select="'q8-2'"/>
		</xsl:call-template>
		<xsl:call-template name="buildQuestionAndAnswer">
			<xsl:with-param name="onerow" select="true()"/>
		</xsl:call-template>
	</xsl:template>
	<xsl:template match="Quest199913-q8-2b">
		<xsl:call-template name="buildQuestionAndAnswer">
			<xsl:with-param name="onerow" select="true()"/>
		</xsl:call-template>
	</xsl:template>
	<xsl:template match="Quest199913-q8-3">
		<xsl:call-template name="buildQuestionAndAnswer"/>
	</xsl:template>
	<xsl:template match="Quest199913-q9-a">
		<xsl:call-template name="buildHeading">
			<xsl:with-param name="label_id" select="'q9-h2'"/>
		</xsl:call-template>
		<xsl:call-template name="buildQuestion">
			<xsl:with-param name="label_id" select="'q9-text'"/>
		</xsl:call-template>
		<xsl:call-template name="buildQuestionAndAnswer"/>
	</xsl:template>
	<xsl:template match="Quest199913-q9-b">
		<xsl:call-template name="buildQuestionAndAnswer"/>
	</xsl:template>
	<xsl:template match="Quest199913-q9-c">
		<xsl:call-template name="buildQuestionAndAnswer"/>
	</xsl:template>
	<xsl:template match="Quest199913-q9-c-comments">
		<xsl:call-template name="buildQuestionAndAnswer"/>
	</xsl:template>
	<xsl:template match="Quest199913-q10-1">
		<xsl:call-template name="buildHeading">
			<xsl:with-param name="label_id" select="'q10-h2'"/>
		</xsl:call-template>
		<xsl:call-template name="buildQuestionAndAnswer"/>
	</xsl:template>
	<xsl:template match="Quest199913-q10-1a">
		<xsl:call-template name="buildQuestionAndAnswer"/>
	</xsl:template>
	<xsl:template match="Quest199913-q10-2">
		<xsl:call-template name="buildQuestionAndAnswer"/>
	</xsl:template>
	<xsl:template match="Quest199913-q10-2a">
		<xsl:call-template name="buildQuestionAndAnswer"/>
	</xsl:template>
	<xsl:template match="Quest199913-q11-1">
		<xsl:call-template name="buildHeading">
			<xsl:with-param name="label_id" select="'q11-h2'"/>
		</xsl:call-template>
		<xsl:call-template name="buildQuestionAndAnswer"/>
	</xsl:template>
	<xsl:template match="Quest199913-q11-1a">
		<xsl:call-template name="buildQuestionAndAnswer"/>
	</xsl:template>
	<xsl:template match="Quest199913-q11-2-1">
		<xsl:call-template name="buildQuestion">
			<xsl:with-param name="label_id" select="'q11-2'"/>
		</xsl:call-template>
		<xsl:call-template name="buildQuestionAndAnswer"/>
	</xsl:template>
	<xsl:template match="Quest199913-q11-2-2">
		<xsl:call-template name="buildQuestionAndAnswer"/>
	</xsl:template>
	<xsl:template match="Quest199913-q11-2-3">
		<xsl:call-template name="buildQuestionAndAnswer"/>
	</xsl:template>
	<xsl:template match="Quest199913-q12">
		<xsl:call-template name="buildHeading"/>
		<xsl:call-template name="buildQuestionAndAnswer"/>
	</xsl:template>
	<xsl:template match="Quest199913-q13">
		<xsl:call-template name="buildHeading"/>
		<xsl:call-template name="buildQuestionAndAnswer"/>
	</xsl:template>
	<xsl:template match="Quest199913-q14">
		<xsl:call-template name="buildHeading"/>
		<xsl:call-template name="buildQuestionAndAnswer"/>
	</xsl:template>


	<!-- TEMPLATES for building HTML elements -->

	<!-- buid html  for the first level heading -->
	<xsl:template name="buildHeading">
		<xsl:param name="label_id" select="concat(substring(local-name(.),13),'-h2')"/>
		<h2>
			<xsl:copy-of select="$labels/item[@id=$label_id]/text()"/>
		</h2>
	</xsl:template>
	
	<!-- buid html  for one question -->
	<xsl:template name="buildQuestionAndAnswer">
		<xsl:param name="label_id" select="substring(local-name(.),13)"/>
		<xsl:param name="yesno"/>
		<xsl:param name="onerow" select="false()"/>
		<p>
			<strong>
				<xsl:copy-of select="$labels/item[@id=$label_id]/text()"/>
			</strong>
			<xsl:choose>
				<xsl:when test="$onerow=false()"><br/></xsl:when>
				<xsl:otherwise>:&#160;</xsl:otherwise>
			</xsl:choose>
			<xsl:choose>
				<xsl:when test="$yesno=true()">
					<xsl:call-template name="YesNoUnknown">
						<xsl:with-param name="Param" select="."/>
					</xsl:call-template>
				</xsl:when>
				<xsl:otherwise>
					<xsl:call-template name="break">
						<xsl:with-param name="text" select="."/>
					</xsl:call-template>
				</xsl:otherwise>
			</xsl:choose>
		</p>
	</xsl:template>


	<xsl:template name="buildQuestion">
		<xsl:param name="label_id" select="substring(local-name(.),13)"/>
		<p>
			<strong>
				<xsl:copy-of select="$labels/item[@id=$label_id]/text()"/>
			</strong>
		</p>
	</xsl:template>


	<xsl:template name="buildAnswer">
		<xsl:param name="yesno"/>
		<p>
			<xsl:choose>
				<xsl:when test="$yesno=true()">
					<xsl:call-template name="YesNoUnknown">
						<xsl:with-param name="Param" select="."/>
					</xsl:call-template>
				</xsl:when>
				<xsl:otherwise>
					<xsl:call-template name="break">
						<xsl:with-param name="text" select="."/>
					</xsl:call-template>
				</xsl:otherwise>
			</xsl:choose>
		</p>
	</xsl:template>


	<!-- Replaces line breaks with <br/> tags -->
	<xsl:template name="break">
		<xsl:param name="text" select="."/>
		<xsl:choose>
			<xsl:when test="contains($text, '&#10;')">
				<xsl:value-of select="substring-before($text, '&#10;')"  disable-output-escaping="yes"/>
				<br/>
				<xsl:call-template name="break">
					<xsl:with-param name="text" select="substring-after($text, '&#10;')"/>
				</xsl:call-template>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="$text"  disable-output-escaping="yes"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>


	<!-- YesNoUnknown implementation -->
	<xsl:template name="YesNoUnknown">
		<xsl:param name="Param"/>
		<xsl:choose>
			<xsl:when test="$Param = '1' or $Param = 'true'">
				<xsl:copy-of select="$labels_yesno/item[@id='1']/text()"/>
			</xsl:when>
			<xsl:when test="$Param = '0' or $Param = 'false'">
				<xsl:copy-of select="$labels_yesno/item[@id='0']/text()"/>
			</xsl:when>
			<xsl:when test="$Param = ''">
				<xsl:copy-of select="$labels_yesno/item[@id='']/text()"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:call-template name="break">
					<xsl:with-param name="text" select="."/>
				</xsl:call-template>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	<xsl:template match="*"/>
</xsl:stylesheet>