View stylesheet

XML schemas http://rod.eionet.europa.eu/obligations/137?V200807
Output type XML
Depends on aqq_content.xslt
Description Generates Form 16
XSL file aqq_form16.xslt (Last modified: 28 Oct 2009 11:37 )
<?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="/">
		<form16 xsi:noNamespaceSchemaLocation="http://air-climate.eionet.europa.eu/schemas/AirQualityQuestionnaire/AirQualityQuestionnaire-form16.xsd"
					xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xml:lang="en">
			<form16a>
				<xsl:call-template name="TransposeA">
					<xsl:with-param name="Columns" select="count(//table:table[@table:name='16a']/table:table-row[4]/table:table-cell)"/>
					<xsl:with-param name="Total" select="count(//table:table[@table:name='16a']/table:table-row[4]/table:table-cell) + 2"/>
					<xsl:with-param name="TableName" select="'16a'"/>
				</xsl:call-template>
			</form16a>
			<form16b>
				<xsl:call-template name="TransposeB">
					<xsl:with-param name="Columns" select="count(//table:table[@table:name='16b']/table:table-row[4]/table:table-cell)"/>
					<xsl:with-param name="Total" select="count(//table:table[@table:name='16b']/table:table-row[4]/table:table-cell) + 2"/>
					<xsl:with-param name="TableName" select="'16b'"/>
				</xsl:call-template>
			</form16b>
			<form16c>
				<xsl:call-template name="TransposeC">
					<xsl:with-param name="Columns" select="count(//table:table[@table:name='16c']/table:table-row[4]/table:table-cell)"/>
					<xsl:with-param name="Total" select="count(//table:table[@table:name='16c']/table:table-row[4]/table:table-cell) + 2"/>
					<xsl:with-param name="TableName" select="'16c'"/>
				</xsl:call-template>
			</form16c>
			<form16d>
				<xsl:call-template name="TransposeD">
					<xsl:with-param name="Columns" select="count(//table:table[@table:name='16d']/table:table-row[4]/table:table-cell)"/>
					<xsl:with-param name="Total" select="count(//table:table[@table:name='16d']/table:table-row[4]/table:table-cell) + 2"/>
					<xsl:with-param name="TableName" select="'16d'"/>
				</xsl:call-template>
			</form16d>
			<form-comments/>
		</form16>
	</xsl:template>
	
<!--The template simulates a for from 2 to the total number of rows-->	
<!--	<xsl:template name="ForRows">
		<xsl:param name="Column" select="1"/>
		<xsl:param name="Rows" select="1"/>
		<xsl:param name="TotalRows" select="1"/>
		<xsl:param name="TableName" select="1"/>
		<xsl:if test="$Rows &gt; 0">
			<xsl:if test="//table:table[@table:name=$TableName]/table:table-row[$TotalRows - $Rows]/table:table-cell[$Column]/text:p">
				<compound>
					<name><xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[$TotalRows - $Rows]/table:table-cell[1]"/></name>
					<quantity><xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[$TotalRows - $Rows]/table:table-cell[$Column]"/></quantity>
				</compound>
			</xsl:if>
			<xsl:call-template name="ForRows">
				<xsl:with-param name="Column" select="$Column"/>
				<xsl:with-param name="Rows" select="$Rows - 1"/>
				<xsl:with-param name="TotalRows" select="count(//table:table[@table:name=$TableName]/table:table-row) + 2"/>
				<xsl:with-param name="TableName" select="$TableName"/>
			</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="TransposeA">
		<xsl:param name="Columns">1</xsl:param>
		<xsl:param name="Total">1</xsl:param>
		<xsl:param name="TableName">"16a"</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 ($Total - $Columns=2)">
				<form16a-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>
					<ethane>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[5]/table:table-cell[$Total - $Columns]/text:p"/>
					</ethane>
					<ethylene>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[6]/table:table-cell[$Total - $Columns]/text:p"/>
					</ethylene>
					<acetylene>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[7]/table:table-cell[$Total - $Columns]/text:p"/>
					</acetylene>
					<propane>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[8]/table:table-cell[$Total - $Columns]/text:p"/>
					</propane>
					<propene>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[9]/table:table-cell[$Total - $Columns]/text:p"/>
					</propene>
					<n-butane>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[10]/table:table-cell[$Total - $Columns]/text:p"/>
					</n-butane>
					<i-butane>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[11]/table:table-cell[$Total - $Columns]/text:p"/>
					</i-butane>
					<butene-1>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[12]/table:table-cell[$Total - $Columns]/text:p"/>
					</butene-1>
					<trans-2butene>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[13]/table:table-cell[$Total - $Columns]/text:p"/>
					</trans-2butene>
					<cis-2butene>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[14]/table:table-cell[$Total - $Columns]/text:p"/>
					</cis-2butene>
					<butadiene13>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[15]/table:table-cell[$Total - $Columns]/text:p"/>
					</butadiene13>
					<n-pentane>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[16]/table:table-cell[$Total - $Columns]/text:p"/>
					</n-pentane>
					<i-pentane>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[17]/table:table-cell[$Total - $Columns]/text:p"/>
					</i-pentane>
					<pentene-1>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[18]/table:table-cell[$Total - $Columns]/text:p"/>
					</pentene-1>
					<pentene-2>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[19]/table:table-cell[$Total - $Columns]/text:p"/>
					</pentene-2>
					<isoprene>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[20]/table:table-cell[$Total - $Columns]/text:p"/>
					</isoprene>
					<n-hexane>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[21]/table:table-cell[$Total - $Columns]/text:p"/>
					</n-hexane>
					<i-hexane>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[22]/table:table-cell[$Total - $Columns]/text:p"/>
					</i-hexane>
					<n-heptane>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[23]/table:table-cell[$Total - $Columns]/text:p"/>
					</n-heptane>
					<n-octane>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[24]/table:table-cell[$Total - $Columns]/text:p"/>
					</n-octane>
					<i-octane>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[25]/table:table-cell[$Total - $Columns]/text:p"/>
					</i-octane>
					<benzene>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[26]/table:table-cell[$Total - $Columns]/text:p"/>
					</benzene>
						<toluene>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[27]/table:table-cell[$Total - $Columns]/text:p"/>
					</toluene>
					<ethyl-benzene>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[28]/table:table-cell[$Total - $Columns]/text:p"/>
					</ethyl-benzene>
					<mp-xylene>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[29]/table:table-cell[$Total - $Columns]/text:p"/>
					</mp-xylene>
					<o-xylene>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[30]/table:table-cell[$Total - $Columns]/text:p"/>
					</o-xylene>
					<trimeth-benzene-124>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[31]/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[32]/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[33]/table:table-cell[$Total - $Columns]/text:p"/>
					</trimeth-benzene-135>
					<formaldehyde>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[34]/table:table-cell[$Total - $Columns]/text:p"/>
					</formaldehyde>
					<total-non-methane-hydrocarbons>
						<xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[35]/table:table-cell[$Total - $Columns]/text:p"/>
					</total-non-methane-hydrocarbons>
				</form16a-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='16a']/table:table-row[4]/table:table-cell) + 2"/>
				<xsl:with-param name="TableName" select="'16a'"/>
			</xsl:call-template>
		</xsl:if>
	</xsl:template>

<!--The template simulates a for from 1 to the total number of columns and the another one from 1 to the number of rows and fetches the values on the corresponding cells-->
	<xsl:template name="TransposeB">
		<xsl:param name="Columns">1</xsl:param>
		<xsl:param name="Total">1</xsl:param>
		<xsl:param name="TableName">"16b"</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 ($Total - $Columns=2)">
				<form16b-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>
					<xsl:for-each select="//table:table[@table:name=$TableName]/table:table-row[position() = 5 or (position()&gt; 5 and ./table:table-cell[$Total - $Columns]/text:p)]">
						<compound>
							<name><xsl:value-of select="table:table-cell[1]/text:p"/></name>
							<quantity><xsl:value-of select="table:table-cell[$Total - $Columns]/text:p"/></quantity>
						</compound>
					</xsl:for-each>
<!--					<xsl:call-template name="ForRows">
						<xsl:with-param name="Column" select="$Total - $Columns"/>
						<xsl:with-param name="Rows" select="count(//table:table[@table:name=$TableName]/table:table-row) - 3"/>
						<xsl:with-param name="TotalRows" select="count(//table:table[@table:name=$TableName]/table:table-row) + 2"/>
						<xsl:with-param name="TableName" select="$TableName"/>
					</xsl:call-template>-->
				</form16b-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=$TableName]/table:table-row[4]/table:table-cell) + 2"/>
				<xsl:with-param name="TableName" select="$TableName"/>
			</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/cells-->
	<xsl:template name="TransposeC">
		<xsl:param name="Columns">1</xsl:param>
		<xsl:param name="Total">1</xsl:param>
		<xsl:param name="TableName">"16c"</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 ($Total - $Columns=2)">
				<form16c-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>
					<compound>
						<name>benzo(a)anthracene</name>
						<quantity><xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[5]/table:table-cell[$Total - $Columns]/text:p"/></quantity>
					</compound>
					<compound>
						<name>benzo(b)fluoranthene</name>
						<quantity><xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[6]/table:table-cell[$Total - $Columns]/text:p"/></quantity>
					</compound>
					<compound>
						<name>benzo(j)fluoranthene</name>
						<quantity><xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[7]/table:table-cell[$Total - $Columns]/text:p"/></quantity>
					</compound>
					<compound>
						<name>benzo(k)fluoranthene</name>
						<quantity><xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[8]/table:table-cell[$Total - $Columns]/text:p"/></quantity>
					</compound>
					<compound>
						<name>indeno(1,2,3-cd)pyrene</name>
						<quantity><xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[9]/table:table-cell[$Total - $Columns]/text:p"/></quantity>
					</compound>
					<compound>
						<name>dibenz(a,h)anthracene</name>
						<quantity><xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[10]/table:table-cell[$Total - $Columns]/text:p"/></quantity>
					</compound>
					<compound>
						<name>total (gaseous) Mercury</name>
						<quantity><xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[11]/table:table-cell[$Total - $Columns]/text:p"/></quantity>
					</compound>
					<compound>
						<name>particulate divalent mercury</name>
						<quantity><xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[12]/table:table-cell[$Total - $Columns]/text:p"/></quantity>
					</compound>
					<compound>
						<name>gaseous divalent mercury</name>
						<quantity><xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[13]/table:table-cell[$Total - $Columns]/text:p"/></quantity>
					</compound>
					<xsl:for-each select="//table:table[@table:name=$TableName]/table:table-row[position()=14 or (position() &gt; 14 and ./table:table-cell[$Total - $Columns]/text:p)]">
						<compound>
							<name><xsl:value-of select="table:table-cell[1]"/></name>
							<quantity><xsl:value-of select="table:table-cell[$Total - $Columns]"/></quantity>
						</compound>
					</xsl:for-each>
<!--					<xsl:call-template name="ForRows">
						<xsl:with-param name="Column" select="$Total - $Columns"/>
						<xsl:with-param name="Rows" select="count(//table:table[@table:name=$TableName]/table:table-row) - 12"/>
						<xsl:with-param name="TotalRows" select="count(//table:table[@table:name=$TableName]/table:table-row) + 2"/>
						<xsl:with-param name="TableName" select="$TableName"/>
					</xsl:call-template>-->
				</form16c-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=$TableName]/table:table-row[4]/table:table-cell) + 2"/>
				<xsl:with-param name="TableName" select="$TableName"/>
			</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/cells-->
	<xsl:template name="TransposeD">
		<xsl:param name="Columns">1</xsl:param>
		<xsl:param name="Total">1</xsl:param>
		<xsl:param name="TableName">"16d"</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 ($Total - $Columns=2)">
				<form16d-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>
					<compound>
						<name>benzo(a)pyrene</name>
						<quantity><xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[5]/table:table-cell[$Total - $Columns]/text:p"/></quantity>
					</compound>
					<compound>
						<name>benzo(a)anthracene</name>
						<quantity><xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[6]/table:table-cell[$Total - $Columns]/text:p"/></quantity>
					</compound>
					<compound>
						<name>benzo(b)fluoranthene</name>
						<quantity><xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[7]/table:table-cell[$Total - $Columns]/text:p"/></quantity>
					</compound>
					<compound>
						<name>benzo(j)fluoranthene</name>
						<quantity><xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[8]/table:table-cell[$Total - $Columns]/text:p"/></quantity>
					</compound>
					<compound>
						<name>benzo(k)fluoranthene</name>
						<quantity><xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[9]/table:table-cell[$Total - $Columns]/text:p"/></quantity>
					</compound>
					<compound>
						<name>indeno(1,2,3-cd)pyrene</name>
						<quantity><xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[10]/table:table-cell[$Total - $Columns]/text:p"/></quantity>
					</compound>
					<compound>
						<name>dibenz(a,h)anthracene</name>
						<quantity><xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[11]/table:table-cell[$Total - $Columns]/text:p"/></quantity>
					</compound>
					<compound>
						<name>arsenic</name>
						<quantity><xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[12]/table:table-cell[$Total - $Columns]/text:p"/></quantity>
					</compound>
					<compound>
						<name>cadmium</name>
						<quantity><xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[13]/table:table-cell[$Total - $Columns]/text:p"/></quantity>
					</compound>
					<compound>
						<name>nickel</name>
						<quantity><xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[14]/table:table-cell[$Total - $Columns]/text:p"/></quantity>
					</compound>
					<compound>
						<name>mercury</name>
						<quantity><xsl:value-of select="//table:table[@table:name=$TableName]/table:table-row[15]/table:table-cell[$Total - $Columns]/text:p"/></quantity>
					</compound>
					<xsl:for-each select="//table:table[@table:name=$TableName]/table:table-row[position()=16 or (position() &gt; 16 and ./table:table-cell[$Total - $Columns]/text:p)]">
						<compound>
							<name><xsl:value-of select="table:table-cell[1]"/></name>
							<quantity><xsl:value-of select="table:table-cell[$Total - $Columns]"/></quantity>
						</compound>
					</xsl:for-each>
<!--					<xsl:call-template name="ForRows">
						<xsl:with-param name="Column" select="$Total - $Columns"/>
						<xsl:with-param name="Rows" select="count(//table:table[@table:name=$TableName]/table:table-row) - 10"/>
						<xsl:with-param name="TotalRows" select="count(//table:table[@table:name=$TableName]/table:table-row) + 2"/>
						<xsl:with-param name="TableName" select="$TableName"/>
					</xsl:call-template>-->
				</form16d-row>
			</xsl:if>
			<xsl:call-template name="TransposeD">
				<xsl:with-param name="Columns" select="$Columns - 1"/>
				<xsl:with-param name="Total" select="count(//table:table[@table:name=$TableName]/table:table-row[4]/table:table-cell) + 2"/>
				<xsl:with-param name="TableName" select="$TableName"/>
			</xsl:call-template>
		</xsl:if>
	</xsl:template>

</xsl:stylesheet>