View stylesheet

XML schemas http://rod.eionet.europa.eu/obligations/137?V200807
Output type XML
Depends on aqq_content.xslt
Description Generates Form 2
XSL file aqq_form02.xslt (Last modified: 22 Oct 2009 11:43 )
<?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="/">
		<form2 xsi:noNamespaceSchemaLocation="http://air-climate.eionet.europa.eu/schemas/AirQualityQuestionnaire/AirQualityQuestionnaire-form2.xsd"
			xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
			xml:lang="en">
			<xsl:for-each select="//table:table[@table:name=2]/table:table-row[3]">
				<xsl:for-each select="./table:table-cell[position() = 2 or (position()&gt; 2 and ./text:p)]">
					<form2-row>
						<full-zone-name>
							<xsl:value-of select="./text:p"/>
						</full-zone-name>
						<zone-code>
							<xsl:call-template name="getCellValue">
								<xsl:with-param name="sourceRow" select="../../table:table-row[4]"/>	
								<xsl:with-param name="sourceColumn" select="position()"/>
							</xsl:call-template>
						</zone-code>
						<pollutants>
							<groups>
								<a>
									<xsl:call-template name="getPollutantGroup">
										<xsl:with-param name="sourceRow" select="../../table:table-row[5]"/>	
										<xsl:with-param name="sourceColumn" select="position()"/>
										<xsl:with-param name="group" select="'A'"/>
									</xsl:call-template>
								</a>
								<m>
									<xsl:call-template name="getPollutantGroup">
										<xsl:with-param name="sourceRow" select="../../table:table-row[5]"/>	
										<xsl:with-param name="sourceColumn" select="position()"/>
										<xsl:with-param name="group" select="'M'"/>
									</xsl:call-template>
								</m>
								<s>
									<xsl:call-template name="getPollutantGroup">
										<xsl:with-param name="sourceRow" select="../../table:table-row[5]"/>	
										<xsl:with-param name="sourceColumn" select="position()"/>
										<xsl:with-param name="group" select="'S'"/>
									</xsl:call-template>
								</s>
								<n>
									<xsl:call-template name="getPollutantGroup">
										<xsl:with-param name="sourceRow" select="../../table:table-row[5]"/>	
										<xsl:with-param name="sourceColumn" select="position()"/>
										<xsl:with-param name="group" select="'N'"/>
									</xsl:call-template>
								</n>
							</groups>
							<types>
								<sh>
									<xsl:call-template name="getPollutantValue">
										<xsl:with-param name="sourceRow" select="../../table:table-row[5]"/>	
										<xsl:with-param name="sourceColumn" select="position()"/>
										<xsl:with-param name="pollutant" select="'SH'"/>
									</xsl:call-template>
								</sh>
								<se>
									<xsl:call-template name="getPollutantValue">
										<xsl:with-param name="sourceRow" select="../../table:table-row[5]"/>	
										<xsl:with-param name="sourceColumn" select="position()"/>
										<xsl:with-param name="pollutant" select="'SE'"/>
									</xsl:call-template>
								</se>
								<nh>
									<xsl:call-template name="getPollutantValue">
										<xsl:with-param name="sourceRow" select="../../table:table-row[5]"/>	
										<xsl:with-param name="sourceColumn" select="position()"/>
										<xsl:with-param name="pollutant" select="'NH'"/>
									</xsl:call-template>
								</nh>
								<nv>
									<xsl:call-template name="getPollutantValue">
										<xsl:with-param name="sourceRow" select="../../table:table-row[5]"/>	
										<xsl:with-param name="sourceColumn" select="position()"/>
										<xsl:with-param name="pollutant" select="'NV'"/>
									</xsl:call-template>
								</nv>
								<p>
									<xsl:call-template name="getPollutantValue">
										<xsl:with-param name="sourceRow" select="../../table:table-row[5]"/>	
										<xsl:with-param name="sourceColumn" select="position()"/>
										<xsl:with-param name="pollutant" select="'P'"/>
									</xsl:call-template>
								</p>
								<l>
									<xsl:call-template name="getPollutantValue">
										<xsl:with-param name="sourceRow" select="../../table:table-row[5]"/>	
										<xsl:with-param name="sourceColumn" select="position()"/>
										<xsl:with-param name="pollutant" select="'L'"/>
									</xsl:call-template>
								</l>
								<c>
									<xsl:call-template name="getPollutantValue">
										<xsl:with-param name="sourceRow" select="../../table:table-row[5]"/>	
										<xsl:with-param name="sourceColumn" select="position()"/>
										<xsl:with-param name="pollutant" select="'C'"/>
									</xsl:call-template>
								</c>
								<b>
									<xsl:call-template name="getPollutantValue">
										<xsl:with-param name="sourceRow" select="../../table:table-row[5]"/>	
										<xsl:with-param name="sourceColumn" select="position()"/>
										<xsl:with-param name="pollutant" select="'B'"/>
									</xsl:call-template>
								</b>
								<o>
									<xsl:call-template name="getPollutantValue">
										<xsl:with-param name="sourceRow" select="../../table:table-row[5]"/>	
										<xsl:with-param name="sourceColumn" select="position()"/>
										<xsl:with-param name="pollutant" select="'O'"/>
									</xsl:call-template>
								</o>
								<as>
									<xsl:call-template name="getPollutantValue">
										<xsl:with-param name="sourceRow" select="../../table:table-row[5]"/>	
										<xsl:with-param name="sourceColumn" select="position()"/>
										<xsl:with-param name="pollutant" select="'As'"/>
									</xsl:call-template>
								</as>
								<cd>
									<xsl:call-template name="getPollutantValue">
										<xsl:with-param name="sourceRow" select="../../table:table-row[5]"/>	
										<xsl:with-param name="sourceColumn" select="position()"/>
										<xsl:with-param name="pollutant" select="'Cd'"/>
									</xsl:call-template>
								</cd>
								<ni>
									<xsl:call-template name="getPollutantValue">
										<xsl:with-param name="sourceRow" select="../../table:table-row[5]"/>	
										<xsl:with-param name="sourceColumn" select="position()"/>
										<xsl:with-param name="pollutant" select="'Ni'"/>
									</xsl:call-template>
								</ni>
								<bap>
									<xsl:call-template name="getPollutantValue">
										<xsl:with-param name="sourceRow" select="../../table:table-row[5]"/>	
										<xsl:with-param name="sourceColumn" select="position()"/>
										<xsl:with-param name="pollutant" select="'BaP'"/>
									</xsl:call-template>
								</bap>
							</types>
						</pollutants>
						<type>
							<xsl:call-template name="getCellValue">
								<xsl:with-param name="sourceRow" select="../../table:table-row[6]"/>	
								<xsl:with-param name="sourceColumn" select="position()"/>
							</xsl:call-template>
						</type>
						<area>
							<xsl:call-template name="getCellValue">
								<xsl:with-param name="sourceRow" select="../../table:table-row[7]"/>	
								<xsl:with-param name="sourceColumn" select="position()"/>
							</xsl:call-template>
						</area>
						<population>
							<xsl:call-template name="getCellValue">
								<xsl:with-param name="sourceRow" select="../../table:table-row[8]"/>	
								<xsl:with-param name="sourceColumn" select="position()"/>
							</xsl:call-template>
						</population>
						<art22-application>
							<xsl:call-template name="getCellValue">
								<xsl:with-param name="sourceRow" select="../../table:table-row[9]"/>	
								<xsl:with-param name="sourceColumn" select="position()"/>
							</xsl:call-template>
						</art22-application>
						<source-type>
							<xsl:call-template name="getSourceTypeValue">
								<xsl:with-param name="sourceRow" select="../../."/>	
								<xsl:with-param name="sourceColumn" select="position()"/>
							</xsl:call-template>
						</source-type>
						<source-file>
							<xsl:call-template name="getCellValue">
								<xsl:with-param name="sourceRow" select="../../table:table-row[11]"/>	
								<xsl:with-param name="sourceColumn" select="position()"/>
							</xsl:call-template>
						</source-file>
						<source-codes>
							<xsl:call-template name="getCellValue">
								<xsl:with-param name="sourceRow" select="../../table:table-row[12]"/>	
								<xsl:with-param name="sourceColumn" select="position()"/>
							</xsl:call-template>
						</source-codes>
					</form2-row>
				</xsl:for-each>
			</xsl:for-each>
			<form-comments/>
		</form2>
		</xsl:template>
		<xsl:template name="getCellValue">
			<xsl:param name="sourceRow"/>
			<xsl:param name="sourceColumn"/>
				<xsl:value-of select="$sourceRow/table:table-cell[$sourceColumn+1]/text:p"/>
		</xsl:template>
		<xsl:template name="getSourceTypeValue">
			<xsl:param name="sourceRow"/>
			<xsl:param name="sourceColumn"/>
				<xsl:if test="$sourceRow/table:table-row[11]/table:table-cell[$sourceColumn+1]/text:p">file</xsl:if>
				<xsl:if test="$sourceRow/table:table-row[12]/table:table-cell[$sourceColumn+1]/text:p">codes</xsl:if>
		</xsl:template>
		<xsl:template name="getPollutantValue">
			<xsl:param name="sourceRow"/>
			<xsl:param name="sourceColumn"/>
			<xsl:param name="pollutant"/>
			<xsl:param name="selectedRow" select="$sourceRow/table:table-cell[$sourceColumn+1]/text:p"/>
            <xsl:variable name="pollutantCheck">
                <xsl:for-each select="$selectedRow">
                    <xsl:choose>
                        <xsl:when test=". = $pollutant">true</xsl:when>
                        <xsl:otherwise>false</xsl:otherwise>
                    </xsl:choose>
                </xsl:for-each>
            </xsl:variable>
            <xsl:if test="contains($pollutantCheck, 'true')">true</xsl:if>
            <xsl:if test="not(contains($pollutantCheck, 'true'))">false</xsl:if>
		</xsl:template>
		<xsl:template name="getPollutantGroup">
			<xsl:param name="sourceRow"/>
			<xsl:param name="sourceColumn"/>
			<xsl:param name="group"/>
			<xsl:param name="selectedRow" select="$sourceRow/table:table-cell[$sourceColumn+1]/text:p"/>
				<xsl:choose>
					<xsl:when test="$group = 'A'">
                        <xsl:variable name="goodCellContents">
                            <xsl:call-template name="getPollutantValue">
                                <xsl:with-param name="selectedRow" select="$selectedRow"/>
                                <xsl:with-param name="pollutant" select="'SH'"/>
                            </xsl:call-template>
                            <xsl:call-template name="getPollutantValue">
                                <xsl:with-param name="selectedRow" select="$selectedRow"/>
                                <xsl:with-param name="pollutant" select="'SE'"/>
                            </xsl:call-template>
                            <xsl:call-template name="getPollutantValue">
                                <xsl:with-param name="selectedRow" select="$selectedRow"/>
                                <xsl:with-param name="pollutant" select="'NH'"/>
                            </xsl:call-template>
                            <xsl:call-template name="getPollutantValue">
                                <xsl:with-param name="selectedRow" select="$selectedRow"/>
                                <xsl:with-param name="pollutant" select="'NV'"/>
                            </xsl:call-template>
                            <xsl:call-template name="getPollutantValue">
                                <xsl:with-param name="selectedRow" select="$selectedRow"/>
                                <xsl:with-param name="pollutant" select="'P'"/>
                            </xsl:call-template>
                            <xsl:call-template name="getPollutantValue">
                                <xsl:with-param name="selectedRow" select="$selectedRow"/>
                                <xsl:with-param name="pollutant" select="'L'"/>
                            </xsl:call-template>
                            <xsl:call-template name="getPollutantValue">
                                <xsl:with-param name="selectedRow" select="$selectedRow"/>
                                <xsl:with-param name="pollutant" select="'C'"/>
                            </xsl:call-template>
                            <xsl:call-template name="getPollutantValue">
                                <xsl:with-param name="selectedRow" select="$selectedRow"/>
                                <xsl:with-param name="pollutant" select="'B'"/>
                            </xsl:call-template>
                            <xsl:call-template name="getPollutantValue">
                                <xsl:with-param name="selectedRow" select="$selectedRow"/>
                                <xsl:with-param name="pollutant" select="'O'"/>
                            </xsl:call-template>
                        </xsl:variable>
						<xsl:variable name="statusPollutantA">
							<xsl:call-template name="getPollutantValue">
                                <xsl:with-param name="selectedRow" select="$selectedRow"/>
                                <xsl:with-param name="pollutant" select="'A'"/>
							</xsl:call-template>
						</xsl:variable>
                     <xsl:if test="contains($goodCellContents, 'false') and $statusPollutantA = 'false'">false</xsl:if>
                        <xsl:if test="not(contains($goodCellContents, 'false')) or $statusPollutantA = 'true'">true</xsl:if>
					</xsl:when>
					<xsl:when test="$group = 'M'">
                        <xsl:variable name="goodCellContents">
                            <xsl:call-template name="getPollutantValue">
                                <xsl:with-param name="selectedRow" select="$selectedRow"/>
                                <xsl:with-param name="pollutant" select="'As'"/>
                            </xsl:call-template>
                            <xsl:call-template name="getPollutantValue">
                                <xsl:with-param name="selectedRow" select="$selectedRow"/>
                                <xsl:with-param name="pollutant" select="'Cd'"/>
                            </xsl:call-template>
                            <xsl:call-template name="getPollutantValue">
                                <xsl:with-param name="selectedRow" select="$selectedRow"/>
                                <xsl:with-param name="pollutant" select="'Ni'"/>
                            </xsl:call-template>
                            <xsl:call-template name="getPollutantValue">
                                <xsl:with-param name="selectedRow" select="$selectedRow"/>
                                <xsl:with-param name="pollutant" select="'BaP'"/>
                            </xsl:call-template>
                        </xsl:variable>
						<xsl:variable name="statusPollutantM">
							<xsl:call-template name="getPollutantValue">
								<xsl:with-param name="selectedRow" select="$selectedRow"/>
								<xsl:with-param name="pollutant" select="'M'"/>
							</xsl:call-template>
						</xsl:variable>
                        <xsl:if test="contains($goodCellContents, 'false') and $statusPollutantM = 'false'">false</xsl:if>
                        <xsl:if test="not(contains($goodCellContents, 'false')) or $statusPollutantM = 'true'">true</xsl:if>
					</xsl:when>
					<xsl:when test="$group = 'S'">
                        <xsl:variable name="goodCellContents">
                            <xsl:call-template name="getPollutantValue">
                                <xsl:with-param name="selectedRow" select="$selectedRow"/>
                                <xsl:with-param name="pollutant" select="'SH'"/>
                            </xsl:call-template>
                            <xsl:call-template name="getPollutantValue">
                                <xsl:with-param name="selectedRow" select="$selectedRow"/>
                                <xsl:with-param name="pollutant" select="'SE'"/>
                            </xsl:call-template>
                        </xsl:variable>
						<xsl:variable name="statusPollutantS">
							<xsl:call-template name="getPollutantValue">
								<xsl:with-param name="selectedRow" select="$selectedRow"/>
								<xsl:with-param name="pollutant" select="'S'"/>
							</xsl:call-template>
						</xsl:variable>
                        <xsl:variable name="statusGroupA">
                            <xsl:call-template name="getPollutantGroup">
                                <xsl:with-param name="sourceRow" select="$sourceRow"/>
                                <xsl:with-param name="sourceColumn" select="$sourceColumn"/>
                                <xsl:with-param name="group" select="'A'"/>
                            </xsl:call-template>
                        </xsl:variable>
                        <xsl:variable name="statusGroupM">
                            <xsl:call-template name="getPollutantGroup">
                                <xsl:with-param name="sourceRow" select="$sourceRow"/>
                                <xsl:with-param name="sourceColumn" select="$sourceColumn"/>
                                <xsl:with-param name="group" select="'M'"/>
                            </xsl:call-template>
                        </xsl:variable>
                        <xsl:if test="contains($goodCellContents, 'false') or $statusGroupA = 'true' or $statusGroupM = 'true'">false</xsl:if>
                        <xsl:if test="(not(contains($goodCellContents, 'false')) and not($statusGroupA = 'true') and not($statusGroupM = 'true')) or $statusPollutantS = 'true'">true</xsl:if>
					</xsl:when>
					<xsl:when test="$group = 'N'">
                        <xsl:variable name="goodCellContents">
                            <xsl:call-template name="getPollutantValue">
                                <xsl:with-param name="selectedRow" select="$selectedRow"/>
                                <xsl:with-param name="pollutant" select="'NH'"/>
                            </xsl:call-template>
                            <xsl:call-template name="getPollutantValue">
                                <xsl:with-param name="selectedRow" select="$selectedRow"/>
                                <xsl:with-param name="pollutant" select="'NV'"/>
                            </xsl:call-template>
                        </xsl:variable>
						<xsl:variable name="statusPollutantN">
							<xsl:call-template name="getPollutantValue">
								<xsl:with-param name="selectedRow" select="$selectedRow"/>
								<xsl:with-param name="pollutant" select="'N'"/>
							</xsl:call-template>
						</xsl:variable>
                        <xsl:variable name="statusGroupA">
                            <xsl:call-template name="getPollutantGroup">
                                <xsl:with-param name="sourceRow" select="$sourceRow"/>
                                <xsl:with-param name="sourceColumn" select="$sourceColumn"/>
                                <xsl:with-param name="group" select="'A'"/>
                            </xsl:call-template>
                        </xsl:variable>
                        <xsl:variable name="statusGroupM">
                            <xsl:call-template name="getPollutantGroup">
                                <xsl:with-param name="sourceRow" select="$sourceRow"/>
                                <xsl:with-param name="sourceColumn" select="$sourceColumn"/>
                                <xsl:with-param name="group" select="'M'"/>
                            </xsl:call-template>
                        </xsl:variable>
                        <xsl:if test="contains($goodCellContents, 'false') or $statusGroupA = 'true' or $statusGroupM = 'true'">false</xsl:if>
                        <xsl:if test="(not(contains($goodCellContents, 'false')) and not($statusGroupA = 'true') and not($statusGroupM = 'true')) or $statusPollutantN = 'true'">true</xsl:if>
					</xsl:when>
				</xsl:choose>
		</xsl:template>
</xsl:stylesheet>