View stylesheet

XML schemas http://air-climate.eionet.europa.eu/schemas/AirQualityQuestionnaire/AirQualityQuestionnaire-form16.xsd
Output type HTML
Description HTML
XSL file form16.xslt (Last modified: 15 Apr 2009 16:34 )
<?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"
		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:variable name="lang">en</xsl:variable>

	<!-- Uncommment the lines below for production use
	-->
	<xsl:variable name="labels_xml" select="document(concat($xml_folder_uri,'aqq-labels.xml'))" />

	<!-- Uncomment the lines below for development use
	<xsl:variable name="labels_xml" select="document('../xml/aqq-labels.xml')" />
    -->

	<xsl:variable name="labels" select="$labels_xml/tmx/body" />
	<xsl:key name="dc16b" match="form16b/form16b-row/compound" use="name" />
	<xsl:key name="dc16c" match="form16c/form16c-row/compound" use="name" />
	<xsl:key name="dc16d" match="form16d/form16d-row/compound" use="name" />

	<xsl:template match="form16">
	<html>
		<head>
			<style type="text/css">
				table {
					border: 1px solid black;
					border-collapse: collapse;
					width: 100%;
				}
				table th {
					border: 1px solid black;
				}
				table td {
					border: 1px solid black;
				}
			</style>
		</head>
		<body>
			<h1>
				<xsl:value-of select="$labels/tu[@tuid='lbl-form16']/tuv[@xml:lang=$lang]" />
				- <xsl:value-of select="$labels/tu[@tuid='lbl-form16-title']/tuv[@xml:lang=$lang]" />
			</h1>
			<h2>
				<xsl:value-of select="$labels/tu[@tuid='lbl-form16a']/tuv[@xml:lang=$lang]" />
				- <xsl:value-of select="$labels/tu[@tuid='lbl-form16a-title']/tuv[@xml:lang=$lang]" />
			</h2>
			<table width="100%">
				<thead>
					<tr>
						<th width="1%">Station code</th>
						<xsl:for-each select="form16a/form16a-row">
							<th><xsl:value-of select="eoi-station-code"/></th>
						</xsl:for-each>
					</tr>
				</thead>
				<tbody>
					<tr>
						<td width="1%"><xsl:value-of select="$labels/tu[@tuid='lbl-ethane']/tuv[@xml:lang=$lang]" /></td>
						<xsl:for-each select="form16a/form16a-row"><td><xsl:value-of select="ethane"/></td></xsl:for-each>
					</tr>
					<tr>
						<td width="1%"><xsl:value-of select="$labels/tu[@tuid='lbl-ethylene']/tuv[@xml:lang=$lang]" /></td>
						<xsl:for-each select="form16a/form16a-row"><td><xsl:value-of select="ethylene"/></td></xsl:for-each>
					</tr>
					<tr>
						<td width="1%"><xsl:value-of select="$labels/tu[@tuid='lbl-acetylene']/tuv[@xml:lang=$lang]" /></td>
						<xsl:for-each select="form16a/form16a-row"><td><xsl:value-of select="acetylene"/></td></xsl:for-each>
					</tr>
					<tr>
						<td width="1%"><xsl:value-of select="$labels/tu[@tuid='lbl-propane']/tuv[@xml:lang=$lang]" /></td>
						<xsl:for-each select="form16a/form16a-row"><td><xsl:value-of select="propane"/></td></xsl:for-each>
					</tr>
					<tr>
						<td width="1%"><xsl:value-of select="$labels/tu[@tuid='lbl-propene']/tuv[@xml:lang=$lang]" /></td>
						<xsl:for-each select="form16a/form16a-row"><td><xsl:value-of select="propene"/></td></xsl:for-each>
					</tr>
					<tr>
						<td width="1%"><xsl:value-of select="$labels/tu[@tuid='lbl-nbutane']/tuv[@xml:lang=$lang]" /></td>
						<xsl:for-each select="form16a/form16a-row"><td><xsl:value-of select="n-butane"/></td></xsl:for-each>
					</tr>
					<tr>
						<td width="1%"><xsl:value-of select="$labels/tu[@tuid='lbl-ibutane']/tuv[@xml:lang=$lang]" /></td>
						<xsl:for-each select="form16a/form16a-row"><td><xsl:value-of select="i-butane"/></td></xsl:for-each>
					</tr>
					<tr>
						<td width="1%"><xsl:value-of select="$labels/tu[@tuid='lbl-butene1']/tuv[@xml:lang=$lang]" /></td>
						<xsl:for-each select="form16a/form16a-row"><td><xsl:value-of select="butene-1"/></td></xsl:for-each>
					</tr>
					<tr>
						<td width="1%"><xsl:value-of select="$labels/tu[@tuid='lbl-trans-2butene']/tuv[@xml:lang=$lang]" /></td>
						<xsl:for-each select="form16a/form16a-row"><td><xsl:value-of select="trans-2butene"/></td></xsl:for-each>
					</tr>
					<tr>
						<td width="1%"><xsl:value-of select="$labels/tu[@tuid='lbl-cis-2butene']/tuv[@xml:lang=$lang]" /></td>
						<xsl:for-each select="form16a/form16a-row"><td><xsl:value-of select="cis-2butene"/></td></xsl:for-each>
					</tr>
					<tr>
						<td width="1%"><xsl:value-of select="$labels/tu[@tuid='lbl-13butadiene']/tuv[@xml:lang=$lang]" /></td>
						<xsl:for-each select="form16a/form16a-row"><td><xsl:value-of select="butadiene13"/></td></xsl:for-each>
					</tr>
					<tr>
						<td width="1%"><xsl:value-of select="$labels/tu[@tuid='lbl-npentane']/tuv[@xml:lang=$lang]" /></td>
						<xsl:for-each select="form16a/form16a-row"><td><xsl:value-of select="n-pentane"/></td></xsl:for-each>
					</tr>
					<tr>
						<td width="1%"><xsl:value-of select="$labels/tu[@tuid='lbl-ipentane']/tuv[@xml:lang=$lang]" /></td>
						<xsl:for-each select="form16a/form16a-row"><td><xsl:value-of select="i-pentane"/></td></xsl:for-each>
					</tr>
					<tr>
						<td width="1%"><xsl:value-of select="$labels/tu[@tuid='lbl-pentene1']/tuv[@xml:lang=$lang]" /></td>
						<xsl:for-each select="form16a/form16a-row"><td><xsl:value-of select="pentene-1"/></td></xsl:for-each>
					</tr>
					<tr>
						<td width="1%"><xsl:value-of select="$labels/tu[@tuid='lbl-pentene2']/tuv[@xml:lang=$lang]" /></td>
						<xsl:for-each select="form16a/form16a-row"><td><xsl:value-of select="pentene-2"/></td></xsl:for-each>
					</tr>
					<tr>
						<td width="1%"><xsl:value-of select="$labels/tu[@tuid='lbl-isoprene']/tuv[@xml:lang=$lang]" /></td>
						<xsl:for-each select="form16a/form16a-row"><td><xsl:value-of select="isoprene"/></td></xsl:for-each>
					</tr>
					<tr>
						<td width="1%"><xsl:value-of select="$labels/tu[@tuid='lbl-nhexane']/tuv[@xml:lang=$lang]" /></td>
						<xsl:for-each select="form16a/form16a-row"><td><xsl:value-of select="n-hexane"/></td></xsl:for-each>
					</tr>
					<tr>
						<td width="1%"><xsl:value-of select="$labels/tu[@tuid='lbl-ihexane']/tuv[@xml:lang=$lang]" /></td>
						<xsl:for-each select="form16a/form16a-row"><td><xsl:value-of select="i-hexane"/></td></xsl:for-each>
					</tr>
					<tr>
						<td width="1%"><xsl:value-of select="$labels/tu[@tuid='lbl-nheptane']/tuv[@xml:lang=$lang]" /></td>
						<xsl:for-each select="form16a/form16a-row"><td><xsl:value-of select="n-heptane"/></td></xsl:for-each>
					</tr>
					<tr>
						<td width="1%"><xsl:value-of select="$labels/tu[@tuid='lbl-noctane']/tuv[@xml:lang=$lang]" /></td>
						<xsl:for-each select="form16a/form16a-row"><td><xsl:value-of select="n-octane"/></td></xsl:for-each>
					</tr>
					<tr>
						<td width="1%"><xsl:value-of select="$labels/tu[@tuid='lbl-ioctane']/tuv[@xml:lang=$lang]" /></td>
						<xsl:for-each select="form16a/form16a-row"><td><xsl:value-of select="i-octane"/></td></xsl:for-each>
					</tr>
					<tr>
						<td width="1%"><xsl:value-of select="$labels/tu[@tuid='lbl-benzene']/tuv[@xml:lang=$lang]" /></td>
						<xsl:for-each select="form16a/form16a-row"><td><xsl:value-of select="benzene"/></td></xsl:for-each>
					</tr>
					<tr>
						<td width="1%"><xsl:value-of select="$labels/tu[@tuid='lbl-toluene']/tuv[@xml:lang=$lang]" /></td>
						<xsl:for-each select="form16a/form16a-row"><td><xsl:value-of select="toluene"/></td></xsl:for-each>
					</tr>
					<tr>
						<td width="1%"><xsl:value-of select="$labels/tu[@tuid='lbl-ethyl-benzene']/tuv[@xml:lang=$lang]" /></td>
						<xsl:for-each select="form16a/form16a-row"><td><xsl:value-of select="ethyl-benzene"/></td></xsl:for-each>
					</tr>
					<tr>
						<td width="1%"><xsl:value-of select="$labels/tu[@tuid='lbl-mpxylene']/tuv[@xml:lang=$lang]" /></td>
						<xsl:for-each select="form16a/form16a-row"><td><xsl:value-of select="mp-xylene"/></td></xsl:for-each>
					</tr>
					<tr>
						<td width="1%"><xsl:value-of select="$labels/tu[@tuid='lbl-oxylene']/tuv[@xml:lang=$lang]" /></td>
						<xsl:for-each select="form16a/form16a-row"><td><xsl:value-of select="o-xylene"/></td></xsl:for-each>
					</tr>
					<tr>
						<td width="1%"><xsl:value-of select="$labels/tu[@tuid='lbl-124trimeth']/tuv[@xml:lang=$lang]" /></td>
						<xsl:for-each select="form16a/form16a-row"><td><xsl:value-of select="trimeth-benzene-124"/></td></xsl:for-each>
					</tr>
					<tr>
						<td width="1%"><xsl:value-of select="$labels/tu[@tuid='lbl-123trimeth']/tuv[@xml:lang=$lang]" /></td>
						<xsl:for-each select="form16a/form16a-row"><td><xsl:value-of select="trimeth-benzene-123"/></td></xsl:for-each>
					</tr>
					<tr>
						<td width="1%"><xsl:value-of select="$labels/tu[@tuid='lbl-135trimeth']/tuv[@xml:lang=$lang]" /></td>
						<xsl:for-each select="form16a/form16a-row"><td><xsl:value-of select="trimeth-benzene-135"/></td></xsl:for-each>
					</tr>
					<tr>
						<td width="1%"><xsl:value-of select="$labels/tu[@tuid='lbl-formaldehyde']/tuv[@xml:lang=$lang]" /></td>
						<xsl:for-each select="form16a/form16a-row"><td><xsl:value-of select="formaldehyde"/></td></xsl:for-each>
					</tr>
					<tr>
						<td width="1%"><xsl:value-of select="$labels/tu[@tuid='lbl-total-non-methane']/tuv[@xml:lang=$lang]" /></td>
						<xsl:for-each select="form16a/form16a-row"><td><xsl:value-of select="total-non-methane-hydrocarbons"/></td></xsl:for-each>
					</tr>
				</tbody>
			</table>

			<h2>
				<xsl:value-of select="$labels/tu[@tuid='lbl-form16b']/tuv[@xml:lang=$lang]" />
				- <xsl:value-of select="$labels/tu[@tuid='lbl-form16b-title']/tuv[@xml:lang=$lang]" />
			</h2>
			<table>
				<thead>
					<tr>
						<th><xsl:value-of select="$labels/tu[@tuid='lbl-station-code']/tuv[@xml:lang=$lang]" /></th>
						<xsl:for-each select="form16b/form16b-row">
							<th><xsl:value-of select="eoi-station-code" /></th>
						</xsl:for-each>
					</tr>
				</thead>
				<tbody>
					<xsl:for-each select="form16b/form16b-row/compound[count(. | key('dc16b', name)[1]) = 1]">
						<xsl:variable name="compound_name" select="./name" />
						<tr>
							<td><xsl:value-of select="name" /></td>
							<xsl:for-each select="/form16/form16b/form16b-row">
								<xsl:variable name="station_code" select="eoi-station-code" />
								<td>
									<xsl:call-template name="find-quantity">
										<xsl:with-param name="compoundName" select="$compound_name" />
										<xsl:with-param name="stationCode" select="$station_code" />
										<xsl:with-param name="path" select="/form16/form16b/form16b-row" />
									</xsl:call-template>
								</td>
							</xsl:for-each>
						</tr>
					</xsl:for-each>
				</tbody>
			</table>

			<h2>
				<xsl:value-of select="$labels/tu[@tuid='lbl-form16c']/tuv[@xml:lang=$lang]" />
				- <xsl:value-of select="$labels/tu[@tuid='lbl-form16c-title']/tuv[@xml:lang=$lang]" />
			</h2>
			<table>
				<thead>
					<tr>
						<th><xsl:value-of select="$labels/tu[@tuid='lbl-station-code']/tuv[@xml:lang=$lang]" /></th>
						<xsl:for-each select="form16c/form16c-row">
							<th><xsl:value-of select="eoi-station-code" /></th>
						</xsl:for-each>
					</tr>
				</thead>
				<tbody>
					<xsl:for-each select="form16c/form16c-row/compound[count(. | key('dc16c', name)[1]) = 1]">
						<xsl:variable name="compound_name" select="./name" />
						<tr>
							<td><xsl:value-of select="name" /></td>
							<xsl:for-each select="/form16/form16c/form16c-row">
								<xsl:variable name="station_code" select="eoi-station-code" />
								<td>
									<xsl:call-template name="find-quantity">
										<xsl:with-param name="compoundName" select="$compound_name" />
										<xsl:with-param name="stationCode" select="$station_code" />
										<xsl:with-param name="path" select="/form16/form16c/form16c-row" />
									</xsl:call-template>
								</td>
							</xsl:for-each>
						</tr>
					</xsl:for-each>
				</tbody>
			</table>

			<h2>
				<xsl:value-of select="$labels/tu[@tuid='lbl-form16d']/tuv[@xml:lang=$lang]" />
				- <xsl:value-of select="$labels/tu[@tuid='lbl-form16d-title']/tuv[@xml:lang=$lang]" />
			</h2>
			<table>
				<thead>
					<tr>
						<th><xsl:value-of select="$labels/tu[@tuid='lbl-station-code']/tuv[@xml:lang=$lang]" /></th>
						<xsl:for-each select="form16d/form16d-row">
							<th><xsl:value-of select="eoi-station-code" /></th>
						</xsl:for-each>
					</tr>
				</thead>
				<tbody>
					<xsl:for-each select="form16d/form16d-row/compound[count(. | key('dc16d', name)[1]) = 1]">
						<xsl:variable name="compound_name" select="./name" />
						<tr>
							<td><xsl:value-of select="name" /></td>
							<xsl:for-each select="/form16/form16d/form16d-row">
								<xsl:variable name="station_code" select="eoi-station-code" />
								<td>
									<xsl:call-template name="find-quantity">
										<xsl:with-param name="compoundName" select="$compound_name" />
										<xsl:with-param name="stationCode" select="$station_code" />
										<xsl:with-param name="path" select="/form16/form16d/form16d-row" />
									</xsl:call-template>
								</td>
							</xsl:for-each>
						</tr>
					</xsl:for-each>
				</tbody>
			</table>

			<h2><xsl:value-of select="$labels/tu[@tuid='lbl-form-comments']/tuv[@xml:lang=$lang]" /></h2>
			<p><xsl:value-of select="form-comments"/></p>
		</body>
	</html>
</xsl:template>

<xsl:template name="find-quantity">
	<xsl:param name="stationCode" />
	<xsl:param name="compoundName" />
	<xsl:param name="path" />
	<xsl:for-each select="$path">
		<xsl:variable name="i" select="." />
		<xsl:variable name="sc" select="eoi-station-code" />
		<xsl:if test="$stationCode = $sc">
			<xsl:for-each select="$i/compound">
				<xsl:variable name="cn" select="name" />
				<xsl:if test="$compoundName = $cn">
					<xsl:value-of select="./quantity" />
				</xsl:if>
			</xsl:for-each>
		</xsl:if>
	</xsl:for-each>
</xsl:template>


</xsl:stylesheet>