View stylesheet

XML schemas http://air-climate.eionet.europa.eu/schemas/AirQualityQuestionnaire/AirQualityQuestionnaire-form6.xsd
Output type HTML
Description HTML
XSL file form6.xslt (Last modified: 15 Apr 2009 16:37 )
<?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:key name="substance_name" match="/form6/form6-row/substances/substance" use="name" />
	<xsl:variable name="labels" select="$labels_xml/tmx/body" />
<xsl:template match="form6">
	<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-form6']/tuv[@xml:lang=$lang]" />
				- <xsl:value-of select="$labels/tu[@tuid='lbl-form6-title']/tuv[@xml:lang=$lang]" />
			</h1>
			<table>
				<thead>
					<tr>
						<th>
						<xsl:value-of select="$labels/tu[@tuid='lbl-station-code']/tuv[@xml:lang=$lang]" /></th>
						<xsl:for-each select="form6-row">
							<th><xsl:value-of select="eoi-station-code" /></th>
						</xsl:for-each>
					</tr>
					<tr>
						<th><xsl:value-of select="$labels/tu[@tuid='lbl-station-code-local']/tuv[@xml:lang=$lang]" /></th>
						<xsl:for-each select="form6-row">
							<th><xsl:value-of select="local-station-code" /></th>
						</xsl:for-each>
					</tr>
					<tr>
						<th><xsl:value-of select="$labels/tu[@tuid='lbl-ozone-zone-code']/tuv[@xml:lang=$lang]" /></th>
						<xsl:for-each select="form6-row">
							<th><xsl:value-of select="ozone-zone-code" /></th>
						</xsl:for-each>
					</tr>
					<tr>
						<th><xsl:value-of select="$labels/tu[@tuid='lbl-substance']/tuv[@xml:lang=$lang]" /></th>
						<xsl:for-each select="form6-row">
							<th></th>
						</xsl:for-each>
					</tr>
				</thead>
				<tbody>
					<xsl:for-each select="/form6/form6-row/substances/substance[count(. | key('substance_name', name)[1]) = 1]">
						<xsl:variable name="subst_name" select="./name" />
						<tr>
							<td><xsl:value-of select="name" /></td>
							<xsl:for-each select="/form6/form6-row">
								<xsl:variable name="station_code" select="eoi-station-code" />
								<td>
									<xsl:call-template name="find-substance">
										<xsl:with-param name="substanceName" select="$subst_name" />
										<xsl:with-param name="stationCode" select="$station_code" />
									</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-substance">
	<xsl:param name="stationCode" />
	<xsl:param name="substanceName" />
	<xsl:for-each select="/form6/form6-row">
		<xsl:variable name="i" select="." />
		<xsl:variable name="sc" select="eoi-station-code" />
		<xsl:if test="$stationCode = $sc">
			<xsl:for-each select="$i/substances/substance">
				<xsl:variable name="sn" select="name" />
				<xsl:if test="$substanceName = $sn">
					<xsl:value-of select="measurement-method" />
				</xsl:if>
			</xsl:for-each>
		</xsl:if>
	</xsl:for-each>
</xsl:template>

</xsl:stylesheet>