View stylesheet

XML schemas http://rod.eionet.europa.eu/obligations/137?V200807
Output type XML
Depends on aqq_content.xslt
Description Generates Form 5
XSL file aqq_form05.xslt (Last modified: 28 Oct 2009 11:38 )
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0">
	<xsl:output method="xml" indent="yes"/>
	<xsl:template match="/">
		<form5 xsi:noNamespaceSchemaLocation="http://air-climate.eionet.europa.eu/schemas/AirQualityQuestionnaire/AirQualityQuestionnaire-form5.xsd"
					xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xml:lang="en">
			<form5a>
				<xsl:call-template name="TransposeA">
					<xsl:with-param name="Columns" select="count(//table:table[@table:name='5a']/table:table-row[3]/table:table-cell)"/>
					<xsl:with-param name="Total" select="count(//table:table[@table:name='5a']/table:table-row[3]/table:table-cell) + 2"/>
					<xsl:with-param name="TableName" select="'5a'"/>
				</xsl:call-template>
			</form5a>
			<form5b>
				<xsl:call-template name="TransposeB">
					<xsl:with-param name="Columns" select="count(//table:table[@table:name='5b']/table:table-row[4]/table:table-cell)"/>
					<xsl:with-param name="Total" select="count(//table:table[@table:name='5b']/table:table-row[4]/table:table-cell) + 2"/>
					<xsl:with-param name="TableName" select="'5b'"/>
				</xsl:call-template>
			</form5b>
			<form5c>
				<xsl:call-template name="TransposeC">
					<xsl:with-param name="Columns" select="count(//table:table[@table:name='5c']/table:table-row[4]/table:table-cell)"/>
					<xsl:with-param name="Total" select="count(//table:table[@table:name='5c']/table:table-row[4]/table:table-cell) + 2"/>
					<xsl:with-param name="TableName" select="'5c'"/>
				</xsl:call-template>
			</form5c>
			<form-comments/>
		</form5>
	</xsl:template>

	<!--The template simulates a for from 1 to the total number of columns and fetches the values on the corresponding columns-->
	<xsl:template name="TransposeA">
		<xsl:param name="Columns">1</xsl:param>
		<xsl:param name="Total">1</xsl:param>
		<xsl:param name="TableName">"'5a'"</xsl:param>
		<xsl:if test="$Columns &gt; 0">
			<xsl:if test="//table:table[@table:name=$TableName]/table:table-row[position() &gt; 2]/table:table-cell[$Total - $Columns]/text:p or ($Total - $Columns = 2)">
				<form5a-row>
					<eoi-station-code>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[3]/table:table-cell[$Total - $Columns]/text:p"/>
					</eoi-station-code>
					<local-station-code>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[4]/table:table-cell[$Total - $Columns]/text:p"/>
					</local-station-code>
					<ozone-zone-code>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[5]/table:table-cell[$Total - $Columns]/text:p"/>
					</ozone-zone-code>
					<elements>
						<ethane>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[6]/table:table-cell[$Total - $Columns]/text:p"/>
						</ethane>
						<ethylene>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[7]/table:table-cell[$Total - $Columns]/text:p"/>
						</ethylene>
						<acetylene>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[8]/table:table-cell[$Total - $Columns]/text:p"/>
						</acetylene>
						<propane>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[9]/table:table-cell[$Total - $Columns]/text:p"/>
						</propane>
						<propene>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[10]/table:table-cell[$Total - $Columns]/text:p"/>
						</propene>
						<n-butane>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[11]/table:table-cell[$Total - $Columns]/text:p"/>
						</n-butane>
						<i-butane>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[12]/table:table-cell[$Total - $Columns]/text:p"/>
						</i-butane>
						<butene-1>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[13]/table:table-cell[$Total - $Columns]/text:p"/>
						</butene-1>
						<trans-2butene>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[14]/table:table-cell[$Total - $Columns]/text:p"/>
						</trans-2butene>
						<cis-2butene>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[15]/table:table-cell[$Total - $Columns]/text:p"/>
						</cis-2butene>
						<butadiene13>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[16]/table:table-cell[$Total - $Columns]/text:p"/>
						</butadiene13>
						<n-pentane>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[17]/table:table-cell[$Total - $Columns]/text:p"/>
						</n-pentane>
						<i-pentane>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[18]/table:table-cell[$Total - $Columns]/text:p"/>
						</i-pentane>
						<pentene-1>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[19]/table:table-cell[$Total - $Columns]/text:p"/>
						</pentene-1>
						<pentene-2>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[20]/table:table-cell[$Total - $Columns]/text:p"/>
						</pentene-2>
						<isoprene>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[21]/table:table-cell[$Total - $Columns]/text:p"/>
						</isoprene>
						<n-hexane>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[22]/table:table-cell[$Total - $Columns]/text:p"/>
						</n-hexane>
						<i-hexane>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[23]/table:table-cell[$Total - $Columns]/text:p"/>
						</i-hexane>
						<n-heptane>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[24]/table:table-cell[$Total - $Columns]/text:p"/>
						</n-heptane>
						<n-octane>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[25]/table:table-cell[$Total - $Columns]/text:p"/>
						</n-octane>
						<i-octane>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[26]/table:table-cell[$Total - $Columns]/text:p"/>
						</i-octane>
						<benzene>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[27]/table:table-cell[$Total - $Columns]/text:p"/>
						</benzene>
						<toluene>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[28]/table:table-cell[$Total - $Columns]/text:p"/>
						</toluene>
						<ethyl-benzene>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[29]/table:table-cell[$Total - $Columns]/text:p"/>
						</ethyl-benzene>
						<mp-xylene>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[30]/table:table-cell[$Total - $Columns]/text:p"/>
						</mp-xylene>
						<o-xylene>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[31]/table:table-cell[$Total - $Columns]/text:p"/>
						</o-xylene>
						<trimeth-benzene-124>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[32]/table:table-cell[$Total - $Columns]/text:p"/>
						</trimeth-benzene-124>
						<trimeth-benzene-123>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[33]/table:table-cell[$Total - $Columns]/text:p"/>
						</trimeth-benzene-123>
						<trimeth-benzene-135>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[34]/table:table-cell[$Total - $Columns]/text:p"/>
						</trimeth-benzene-135>
						<formaldehyde>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[35]/table:table-cell[$Total - $Columns]/text:p"/>
						</formaldehyde>
						<total-non-methane-hydrocarbons>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[36]/table:table-cell[$Total - $Columns]/text:p"/>
						</total-non-methane-hydrocarbons>
					</elements>
				</form5a-row>
			</xsl:if>
			<xsl:call-template name="TransposeA">
				<xsl:with-param name="Columns" select="$Columns - 1"/>
				<xsl:with-param name="Total" select="count(//table:table[@table:name='5a']/table:table-row[3]/table:table-cell) + 2"/>
				<xsl:with-param name="TableName" select="'5a'"/>
			</xsl:call-template>
		</xsl:if>
	</xsl:template>

	<!--The template simulates a for from 1 to the total number of columns and fetches the values on the corresponding columns-->
	<xsl:template name="TransposeB">
		<xsl:param name="Columns">1</xsl:param>
		<xsl:param name="Total">1</xsl:param>
		<xsl:param name="TableName">"'5b'"</xsl:param>
		<xsl:if test="$Columns &gt; 0">
			<xsl:if test="//table:table[@table:name=$TableName]/table:table-row[4]/table:table-cell[$Total - $Columns]/text:p or
								//table:table[@table:name=$TableName]/table:table-row[5]/table:table-cell[$Total - $Columns]/text:p or
								//table:table[@table:name=$TableName]/table:table-row[6]/table:table-cell[$Total - $Columns]/text:p or
								($Total - $Columns = 2)">
				<form5b-row>
					<eoi-station-code>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[4]/table:table-cell[$Total - $Columns]/text:p"/>
					</eoi-station-code>
					<local-station-code>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[5]/table:table-cell[$Total - $Columns]/text:p"/>
					</local-station-code>
					<zone-code>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[6]/table:table-cell[$Total - $Columns]/text:p"/>
					</zone-code>
					<pah-elements-form5>
						<element>
							<name>benzo(a)anthracene</name>
							<sampling>
								<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[7]/table:table-cell[($Total - $Columns -1)*2]/text:p"/>
							</sampling>
							<analysis>
								<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[7]/table:table-cell[($Total - $Columns -1)*2+1]/text:p"/>
							</analysis>
						</element>
						<element>
							<name>benzo(b)fluoranthene</name>
							<sampling>
								<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[8]/table:table-cell[($Total - $Columns -1)*2]/text:p"/>
							</sampling>
							<analysis>
								<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[8]/table:table-cell[($Total - $Columns -1)*2+1]/text:p"/>
							</analysis>
						</element>
						<element>
							<name>benzo(j)fluoranthene</name>
							<sampling>
								<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[9]/table:table-cell[($Total - $Columns -1)*2]/text:p"/>
							</sampling>
							<analysis>
								<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[9]/table:table-cell[($Total - $Columns -1)*2+1]/text:p"/>
							</analysis>
						</element>
						<element>
							<name>benzo(k)fluoranthene</name>
							<sampling>
								<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[10]/table:table-cell[($Total - $Columns -1)*2]/text:p"/>
							</sampling>
							<analysis>
								<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[10]/table:table-cell[($Total - $Columns -1)*2+1]/text:p"/>
							</analysis>
						</element>
						<element>
							<name>indeno(1,2,3-cd)pyrene</name>
							<sampling>
								<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[11]/table:table-cell[($Total - $Columns -1)*2]/text:p"/>
							</sampling>
							<analysis>
								<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[11]/table:table-cell[($Total - $Columns -1)*2+1]/text:p"/>
							</analysis>
						</element>
						<element>
							<name>dibenz(a,h)anthracene</name>
							<sampling>
								<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[12]/table:table-cell[($Total - $Columns -1)*2]/text:p"/>
							</sampling>
							<analysis>
								<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[12]/table:table-cell[($Total - $Columns -1)*2+1]/text:p"/>
							</analysis>
						</element>
						<xsl:for-each select="//table:table[@table:name=$TableName]/table:table-row[position() = 13 or (position() &gt; 13 and ./table:table-cell/text:p)]">
							<xsl:if test="table:table-cell[($Total - $Columns -1)*2]/text:p or
												table:table-cell[($Total - $Columns -1)*2+1]/text:p or
												($Total - $Columns = 2)">
								<element>
									<name><xsl:value-of select="table:table-cell[1]/text:p"/></name>
									<sampling>
										<xsl:value-of select="table:table-cell[($Total - $Columns -1)*2]/text:p"/>
									</sampling>
									<analysis>
										<xsl:value-of select="table:table-cell[($Total - $Columns -1)*2+1]/text:p"/>
									</analysis>
								</element>
							</xsl:if>
						</xsl:for-each>						
					</pah-elements-form5>
				</form5b-row>
			</xsl:if>
			<xsl:call-template name="TransposeB">
				<xsl:with-param name="Columns" select="$Columns - 1"/>
				<xsl:with-param name="Total" select="count(//table:table[@table:name='5b']/table:table-row[4]/table:table-cell) + 2"/>
				<xsl:with-param name="TableName" select="'5b'"/>
			</xsl:call-template>
		</xsl:if>
	</xsl:template>

	<!--The template simulates a for from 1 to the total number of columns and fetches the values on the corresponding columns-->
	<xsl:template name="TransposeC">
		<xsl:param name="Columns">1</xsl:param>
		<xsl:param name="Total">1</xsl:param>
		<xsl:param name="TableName">"'5c'"</xsl:param>
		<xsl:if test="$Columns &gt; 0">
			<xsl:if test="//table:table[@table:name=$TableName]/table:table-row[4]/table:table-cell[$Total - $Columns]/text:p or
								//table:table[@table:name=$TableName]/table:table-row[5]/table:table-cell[$Total - $Columns]/text:p or
								//table:table[@table:name=$TableName]/table:table-row[6]/table:table-cell[$Total - $Columns]/text:p or
								($Total - $Columns = 2)">
				<form5c-row>
					<eoi-station-code>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[4]/table:table-cell[$Total - $Columns]/text:p"/>
					</eoi-station-code>
					<local-station-code>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[5]/table:table-cell[$Total - $Columns]/text:p"/>
					</local-station-code>
					<zone-code>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[6]/table:table-cell[$Total - $Columns]/text:p"/>
					</zone-code>
					<monitoring-in-air-deposition>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[7]/table:table-cell[$Total - $Columns]/text:p"/>
					</monitoring-in-air-deposition>
					<pah-elements-form5>
						<element>
							<name>Arsenic</name>
							<sampling>
								<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[8]/table:table-cell[($Total - $Columns -1)*2]/text:p"/>
							</sampling>
							<analysis>
								<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[8]/table:table-cell[($Total - $Columns -1)*2+1]/text:p"/>
							</analysis>
						</element>
						<element>
							<name>Cadmium</name>
							<sampling>
								<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[9]/table:table-cell[($Total - $Columns -1)*2]/text:p"/>
							</sampling>
							<analysis>
								<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[9]/table:table-cell[($Total - $Columns -1)*2+1]/text:p"/>
							</analysis>
						</element>
						<element>
							<name>Nickel</name>
							<sampling>
								<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[10]/table:table-cell[($Total - $Columns -1)*2]/text:p"/>
							</sampling>
							<analysis>
								<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[10]/table:table-cell[($Total - $Columns -1)*2+1]/text:p"/>
							</analysis>
						</element>
						<element>
							<name>benzo(a)pyrene</name>
							<sampling>
								<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[11]/table:table-cell[($Total - $Columns -1)*2]/text:p"/>
							</sampling>
							<analysis>
								<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[11]/table:table-cell[($Total - $Columns -1)*2+1]/text:p"/>
							</analysis>
						</element>
						<element>
							<name>benzo(a)anthracene</name>
							<sampling>
								<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[12]/table:table-cell[($Total - $Columns -1)*2]/text:p"/>
							</sampling>
							<analysis>
								<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[12]/table:table-cell[($Total - $Columns -1)*2+1]/text:p"/>
							</analysis>
						</element>
						<element>
							<name>benzo(b)fluoranthene</name>
							<sampling>
								<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[13]/table:table-cell[($Total - $Columns -1)*2]/text:p"/>
							</sampling>
							<analysis>
								<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[13]/table:table-cell[($Total - $Columns -1)*2+1]/text:p"/>
							</analysis>
						</element>
						<element>
							<name>benzo(j)fluoranthene</name>
							<sampling>
								<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[14]/table:table-cell[($Total - $Columns -1)*2]/text:p"/>
							</sampling>
							<analysis>
								<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[14]/table:table-cell[($Total - $Columns -1)*2+1]/text:p"/>
							</analysis>
						</element>
						<element>
							<name>benzo(k)fluoranthene</name>
							<sampling>
								<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[15]/table:table-cell[($Total - $Columns -1)*2]/text:p"/>
							</sampling>
							<analysis>
								<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[15]/table:table-cell[($Total - $Columns -1)*2+1]/text:p"/>
							</analysis>
						</element>
						<element>
							<name>indeno(1,2,3-cd)pyrene</name>
							<sampling>
								<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[16]/table:table-cell[($Total - $Columns -1)*2]/text:p"/>
							</sampling>
							<analysis>
								<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[16]/table:table-cell[($Total - $Columns -1)*2+1]/text:p"/>
							</analysis>
						</element>
						<element>
							<name>dibenz(a,h)anthracene</name>
							<sampling>
								<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[17]/table:table-cell[($Total - $Columns -1)*2]/text:p"/>
							</sampling>
							<analysis>
								<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[17]/table:table-cell[($Total - $Columns -1)*2+1]/text:p"/>
							</analysis>
						</element>
						<element>
							<name>total (gaseous) Mercury</name>
							<sampling>
								<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[18]/table:table-cell[($Total - $Columns -1)*2]/text:p"/>
							</sampling>
							<analysis>
								<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[18]/table:table-cell[($Total - $Columns -1)*2+1]/text:p"/>
							</analysis>
						</element>
						<element>
							<name>particulate divalent mercury</name>
							<sampling>
								<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[19]/table:table-cell[($Total - $Columns -1)*2]/text:p"/>
							</sampling>
							<analysis>
								<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[19]/table:table-cell[($Total - $Columns -1)*2+1]/text:p"/>
							</analysis>
						</element>
						<element>
							<name>gaseous divalent mercury</name>
							<sampling>
								<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[20]/table:table-cell[($Total - $Columns -1)*2]/text:p"/>
							</sampling>
							<analysis>
								<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[20]/table:table-cell[($Total - $Columns -1)*2+1]/text:p"/>
							</analysis>
						</element>
					</pah-elements-form5>
				</form5c-row>
			</xsl:if>
			<xsl:call-template name="TransposeC">
				<xsl:with-param name="Columns" select="$Columns - 1"/>
				<xsl:with-param name="Total" select="count(//table:table[@table:name='5c']/table:table-row[4]/table:table-cell) + 2"/>
				<xsl:with-param name="TableName" select="'5c'"/>
			</xsl:call-template>
		</xsl:if>
	</xsl:template>

</xsl:stylesheet>