View stylesheet

XML schemas http://www.eionet.europa.eu/schemas/eprtr/ImplementationReport.xsd
Output type HTML
Description HTML
XSL file e-prtr-questionnaire-html.xsl (Last modified: 21 Sep 2011 10:37 )
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output method="html" indent="yes" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" omit-xml-declaration="yes"/>
	<xsl:param name="xml_folder_uri"/>
	<xsl:param name="envelopeurl"/>

	<xsl:variable name="lang">en</xsl:variable>
	
	<xsl:variable name="labels" select="document(concat($xml_folder_uri,'e-prtr-questionnaire-labels.xml'))/labels" />
	<xsl:variable name="country" select="document(concat($envelopeurl,'/xml'))/envelope/countrycode"/>
	
	<xsl:variable name="type" select="/questionnaire/@type"/>
	
	<xsl:template match="questionnaire">
		<html>
			<head>
				<style type="text/css">
				.data-table {border: 1px solid black; border-collapse: collapse; width: 100%; }
				.data-table th {border: 1px solid black;	}
				.data-table td {border: 1px solid black;	}
				#metadata-table {border: 1px solid black; border-collapse: collapse;  }
				#metadata-table th {border: 1px solid black; text-align:right;padding:4px;	}
				#metadata-table td {border: 1px solid black;padding:4px;}
				label{font-weight:bold; }
				.answer{color:#0000ff; }
				.noanswer{color:#808080; font-style:italic; }
			</style>
			</head>
			<body>
				<h1><xsl:value-of select="$labels/itemset[@type=$type and @xml:lang='en']/item[@id='h1']"/></h1>
				<xsl:call-template name="metadata"/>				
				<h2><xsl:value-of select="$labels/itemset[@type='B' and @xml:lang='en']/item[@id='q-1-heading']"/></h2>
				<xsl:apply-templates select="q-1 | q-1-a[$type='A'] | q-1-b[$type='A']"/>
				<h2><xsl:value-of select="$labels/itemset[@type='B' and @xml:lang='en']/item[@id='q-2-heading']"/></h2>
				<xsl:apply-templates select="q-2 | q-2-a  | q-2-a-i[$type='A'] | q-2-a-ii[$type='A'] | q-2-b[$type='A'] | q-2-c[$type='A'] | q-2-d[$type='A'] | q-2-d-i[$type='A'] | q-2-e[$type='A'] | q-2-f[$type='A'] | q-2-g[$type='A']"/>
				<h2><xsl:value-of select="$labels/itemset[@type='B' and @xml:lang='en']/item[@id='q-3-heading']"/></h2>
				<xsl:apply-templates select="q-3 | q-3-a[$type='A'] | q-3-b[$type='A'] | q-3-c[$type='A'] | q-3-c[$type='A'] | q-3-d[$type='A'] | q-3-e[$type='A'] | q-3-f[$type='A'] | q-3-g[$type='A'] | q-3-h[$type='A'] | q-3-i | q-3-ii | q-3-ii-table | q-3-iii[$type='A']"/>
				<h2><xsl:value-of select="$labels/itemset[@type='B' and @xml:lang='en']/item[@id='q-4-heading']"/></h2>
				<xsl:apply-templates select="q-4 | q-4-a | q-4-b | q-4-c | q-4-d | q-4-a-i[$type='A'] | q-4-a-ii[$type='A']|q-4-a-ii-repeated[$type='A'] | q-4-b-i | q-4-b-ii | q-4-b-iii | q-4-b-iv | q-4-c-i" />
				<h2><xsl:value-of select="$labels/itemset[@type='B' and @xml:lang='en']/item[@id='q-5-heading']"/></h2>
				<xsl:apply-templates select="q-5 | q-5-a  | q-5-b | q-5-b-table[$type='A'] | q-5-c[$type='A']" />
				<h2><xsl:value-of select="$labels/itemset[@type='B' and @xml:lang='en']/item[@id='q-6-heading']"/></h2>
				<xsl:apply-templates select="q-6 | q-6-a[$type='A'] | q-6-b" />
				<h2><xsl:value-of select="$labels/itemset[@type='B' and @xml:lang='en']/item[@id='q-7-heading']"/></h2>
				<xsl:apply-templates select="q-7 | q-7-a | q-7-b | q-7-c | q-7-c-i " />
				<xsl:if test="$type='A'">
					<h2><xsl:value-of select="$labels/itemset[@type='A' and @xml:lang='en']/item[@id='q-8-heading']"/></h2>
					<xsl:apply-templates select="q-8 | q-8-a" />
					<h2><xsl:value-of select="$labels/itemset[@type='A' and @xml:lang='en']/item[@id='q-9-heading']"/></h2>
					<xsl:apply-templates select="q-9 | q-9-a" />
					<h2><xsl:value-of select="$labels/itemset[@type='A' and @xml:lang='en']/item[@id='q-10-heading']"/></h2>
					<xsl:apply-templates select="q-10 | q-10-a | q-10-b" />
					<h2><xsl:value-of select="$labels/itemset[@type='A' and @xml:lang='en']/item[@id='q-11-heading']"/></h2>
					<xsl:apply-templates select="q-11| q-11-a| q-11-b| q-11-c| q-11-d| q-11-e" />
					<h2><xsl:value-of select="$labels/itemset[@type='A' and @xml:lang='en']/item[@id='q-12-heading']"/></h2>
					<xsl:apply-templates select="q-12| q-12-a" />
				</xsl:if>
			</body>
		</html>
	</xsl:template>
	
	<xsl:template match="*">
		<xsl:variable  name="elem-name" select="local-name(.)"/>
		<label><xsl:attribute name="for"><xsl:value-of select="$elem-name"/></xsl:attribute><xsl:value-of select="$labels/itemset[@type='A' and @xml:lang='en']/item[@id= $elem-name ]"/></label>
		
		<xsl:if test="$elem-name='q-4-a'">
			<xsl:apply-templates select="../q-4-table"/>
		</xsl:if>
		<div>
			<xsl:attribute name="id"><xsl:value-of select="$elem-name"/></xsl:attribute>
			<xsl:call-template name="answer">
				<xsl:with-param name="answer"><xsl:value-of select="."/></xsl:with-param>
				<xsl:with-param name="yesno"><xsl:value-of select="$elem-name='q-4-b-i' or $elem-name='q-4-b-iii' or $elem-name='q-4-a-ii-repeated'"/></xsl:with-param>
			</xsl:call-template>
		</div>
	</xsl:template>
	<xsl:template match="q-3-ii-table">
		<table class="data-table">
			<thead>
				<tr>
					<th><xsl:value-of select="$labels/itemset[@type='A' and @xml:lang='en' and $type='A']/item[@id='q-3-ii-institution']"/></th>
					<xsl:if test="$type='A'">
						<th><xsl:value-of select="$labels/itemset[@type='A' and @xml:lang='en']/item[@id='q-3-ii-institution-name']"/></th>
						<th><xsl:value-of select="$labels/itemset[@type='A' and @xml:lang='en']/item[@id='q-3-ii-pathway']"/></th>
					</xsl:if>
					<th><xsl:value-of select="$labels/itemset[@type='A' and @xml:lang='en']/item[@id='q-3-ii-validation']"/></th>
					<xsl:if test="$type='A'">
						<th><xsl:value-of select="$labels/itemset[@type='A' and @xml:lang='en']/item[@id='q-3-ii-remarks']"/></th>
					</xsl:if>
				</tr>
			</thead>
			<tbody>
				<xsl:for-each select="q-3-ii-row">
				<tr>
					<td><xsl:value-of select="institution-type"/></td>
					<xsl:if test="$type='A'">
						<td><xsl:call-template name="answer"><xsl:with-param name="answer"><xsl:value-of select="institution-name"/></xsl:with-param></xsl:call-template></td>
						<td><xsl:call-template name="answer"><xsl:with-param name="answer"><xsl:value-of select="pathway"/></xsl:with-param></xsl:call-template></td>
					</xsl:if>
					<td><xsl:call-template name="answer"><xsl:with-param name="answer"><xsl:value-of select="validation"/></xsl:with-param></xsl:call-template></td>
					<xsl:if test="$type='A'">
						<td><xsl:call-template name="answer"><xsl:with-param name="answer"><xsl:value-of select="remarks"/></xsl:with-param></xsl:call-template></td>
					</xsl:if>
				</tr>
				</xsl:for-each>
			</tbody>
		</table>
	</xsl:template>
	<xsl:template match="q-4-table">
		<table class="data-table">
			<thead>
				<tr>
					<th><xsl:value-of select="$labels/itemset[@type='A' and @xml:lang='en' and $type='A']/item[@id='q-3-ii-institution']"/></th>
					<th><xsl:value-of select="$labels/itemset[@type='A' and @xml:lang='en']/item[@id='q-4-institution-name']"/></th>
					<th><xsl:value-of select="$labels/itemset[@type='A' and @xml:lang='en']/item[@id='q-4-deadline']"/></th>
					<th><xsl:value-of select="$labels/itemset[@type='A' and @xml:lang='en']/item[@id='q-4-year']"/></th>
				</tr>
			</thead>
			<tbody>
				<xsl:for-each select="q-4-row">
				<tr>
					<td><xsl:call-template name="answer"><xsl:with-param name="answer"><xsl:value-of select="institution-type"/></xsl:with-param></xsl:call-template></td>
					<td><xsl:call-template name="answer"><xsl:with-param name="answer"><xsl:value-of select="institution-name"/></xsl:with-param></xsl:call-template></td>
					<td><xsl:call-template name="answer"><xsl:with-param name="answer"><xsl:value-of select="deadline"/></xsl:with-param></xsl:call-template></td>
					<td><xsl:call-template name="answer"><xsl:with-param name="answer"><xsl:value-of select="year"/></xsl:with-param></xsl:call-template></td>
				</tr>
				</xsl:for-each>
			</tbody>
		</table>
	</xsl:template>
	<xsl:template match="q-5-b-table">
		<table class="data-table">
			<thead>
				<tr>
					<th><xsl:value-of select="$labels/itemset[@type='A' and @xml:lang='en']/item[@id='q-5-b-measure-type']"/></th>
					<th><xsl:value-of select="$labels/itemset[@type='A' and @xml:lang='en']/item[@id='q-5-b-reference']"/></th>
					<th><xsl:value-of select="$labels/itemset[@type='A' and @xml:lang='en']/item[@id='q-5-b-authority']"/></th>
					<th><xsl:value-of select="$labels/itemset[@type='A' and @xml:lang='en']/item[@id='q-5-b-data-quality-check']"/></th>
				</tr>
			</thead>
			<tbody>
				<xsl:for-each select="q-5-b-row">
				<tr>
					<td><xsl:call-template name="answer"><xsl:with-param name="answer"><xsl:value-of select="measure-type"/></xsl:with-param></xsl:call-template></td>
					<td><xsl:call-template name="answer"><xsl:with-param name="answer"><xsl:value-of select="reference"/></xsl:with-param></xsl:call-template></td>
					<td><xsl:call-template name="answer"><xsl:with-param name="answer"><xsl:value-of select="authority"/></xsl:with-param></xsl:call-template></td>
					<td><xsl:call-template name="answer"><xsl:with-param name="answer"><xsl:value-of select="data-quality-check"/></xsl:with-param></xsl:call-template></td>
				</tr>
				</xsl:for-each>
			</tbody>
		</table>
	</xsl:template>
	<xsl:template name="metadata">
		<table id="metadata-table">
			<tr>
				<th>Reporting country</th>
				<td><xsl:value-of select="$country"/></td>
			</tr>
			<tr>
				<th>Questionnaire type</th>
				<td>
					<xsl:if test="@type='A'">A - mandatory + voluntary questions</xsl:if>
					<xsl:if test="@type='B'">B - mandatory questions</xsl:if>
				</td>
			</tr>
			<tr>
				<th>Reporting language</th>
				<td><xsl:value-of select="@xml:lang"/></td>
			</tr>
			
		</table>
	</xsl:template>
	<xsl:template name="answer">
		<xsl:param name="answer" select="''"/>
		<xsl:param name="yesno" select="'false'"/>
		
		<xsl:choose>
			<xsl:when test="string-length($answer)=0">
				<xsl:attribute name="class">noanswer</xsl:attribute>	
				[Not answered]
			</xsl:when>
			<xsl:otherwise>
				<xsl:attribute name="class">answer</xsl:attribute>
				<xsl:variable name="text">
					<xsl:choose>
						<xsl:when test="$yesno = 'true'">
							<xsl:if test="$answer=1 or $answer='true'">yes</xsl:if>
							<xsl:if test="$answer=0 or $answer='false'">no</xsl:if>
						</xsl:when>
						<xsl:otherwise><xsl:value-of select="$answer"/></xsl:otherwise>
					</xsl:choose>
				</xsl:variable>
					
				<xsl:call-template name="break"><xsl:with-param name="text" select="$text"/></xsl:call-template>
			</xsl:otherwise>
		</xsl:choose>		
	</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;')"/>
				<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"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
</xsl:stylesheet>