View stylesheet

XML schemas eper.xsd
Output type TEXT
Description Validates an EPER file with XSL
XSL file eper.xsl (Last modified: 26 May 2006 09:38 )
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!-- EPER XSL validationschema version 1.7   --> 


<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sch="http://www.ascc.net/xml/schematron">
<xsl:output method="text" />

	<xsl:template name="CheckThreshold">
	
		<xsl:param name="n"/>
		<xsl:param name="numEmissions"/>

		<xsl:variable name="lcletters">abcdefghijklmnopqrstuvwxyz</xsl:variable>
		<xsl:variable name="ucletters">ABCDEFGHIJKLMNOPQRSTUVWXYZ</xsl:variable>

			
		<xsl:variable name="pollname" select="Emission[$n]/PollutantName" />
		<xsl:variable name="water" select="Emission[$n]/EmissionValue[../EmissionType > 1 and ../PollutantName = $pollname]"></xsl:variable>
		<xsl:variable name="air" select="Emission[$n]/EmissionValue[../EmissionType = 1 and ../PollutantName = $pollname]"></xsl:variable>


		<!--  Error ! If function gets this far, no emission values where above thresholds -->
		<xsl:if test="$n &gt; $numEmissions ">
				<xsl:text>Facility </xsl:text> <xsl:value-of select="FacilityName"/><xsl:text>&#10;No emissions above the threshold.</xsl:text><xsl:text>&#10;&#10;</xsl:text>
 
		</xsl:if>
		
				
		<xsl:if test=" $n &lt; $numEmissions+1">
			<xsl:choose>
				<xsl:when test="$air &gt; 100000 and translate($pollname,$lcletters,$ucletters) = 'CH4' or
					$air >= 500000 and translate($pollname,$lcletters,$ucletters) = 'CO' or
					$air >= 100000000 and translate($pollname,$lcletters,$ucletters) = 'CO2' or
					$air >= 100 and translate($pollname,$lcletters,$ucletters) = 'HFCS' or
					$air >= 10000 and translate($pollname,$lcletters,$ucletters) = 'N2O' or
					$air >= 10000 and translate($pollname,$lcletters,$ucletters) = 'NH3' or
					$air >= 100000 and translate($pollname,$lcletters,$ucletters) = 'NMVOC' or
					$air >= 100000 and translate($pollname,$lcletters,$ucletters) = 'NOX' or
					$air >= 100 and translate($pollname,$lcletters,$ucletters) = 'PFCS' or
					$air >= 50 and translate($pollname,$lcletters,$ucletters) = 'SF6' or
					$air >= 150000 and translate($pollname,$lcletters,$ucletters) = 'SOX' or
					$air >= 0.001 and translate($pollname,$lcletters,$ucletters) = 'PCDD+PCDF (DIOXINS+FURANS)' or
					$air >= 10 and translate($pollname,$lcletters,$ucletters) = 'PENTACHLOROPHENOL (PCP)' or
					$air >= 2000 and translate($pollname,$lcletters,$ucletters) = 'TETRACHLOROETHYLENE (PER)' or
					$air >= 100 and translate($pollname,$lcletters,$ucletters) = 'TETRACHLOROMETHANE (TCM)' or
					$air >= 10 and translate($pollname,$lcletters,$ucletters) = 'TRICHLOROBENZENES (TCB)' or
					$air >= 100 and translate($pollname,$lcletters,$ucletters) = 'TRICHLOROETHANE-1,1,1 (TCE)' or
					$air >= 2000 and translate($pollname,$lcletters,$ucletters) = 'TRICHLOROETHYLENE (TRI)' or
					$air >= 500 and translate($pollname,$lcletters,$ucletters) = 'TRICHLOROMETHANE' or
					$air >= 1000 and translate($pollname,$lcletters,$ucletters) = 'BENZENE' or
					$air >= 10000 and translate($pollname,$lcletters,$ucletters) = 'CHLORINE AND INORGANIC COMPOUNDS' or
					$air >= 5000 and translate($pollname,$lcletters,$ucletters) = 'FLUORINE AND INORGANIC COMPOUNDS' or
					$air >= 200 and translate($pollname,$lcletters,$ucletters) = 'HCN' or
					$air >= 50000 and translate($pollname,$lcletters,$ucletters) = 'PM10' or
					$water >= 50000 and translate($pollname,$lcletters,$ucletters) = 'TOTAL - NITROGEN' or
					$water >= 5000 and translate($pollname,$lcletters,$ucletters) = 'TOTAL - PHOSPHORUS' or
					$water >= 1 and translate($pollname,$lcletters,$ucletters) = 'CHLOROALKANES (C10-13)' or
					$water >= 1 and translate($pollname,$lcletters,$ucletters) = 'CHLORO-ALKANES (C10-13)' or
					$water >= 1 and translate($pollname,$lcletters,$ucletters) = 'HEXACHLOROBUTADIENE (HCBD)' or
					$water >= 1000 and translate($pollname,$lcletters,$ucletters) = 'HALOGENATED ORGANIC COMPOUNDS' or
					$water >= 200 and translate($pollname,$lcletters,$ucletters) = 'BENZENE, TOLUENE, ETHYLBENZENE, XYLENES' or
					$water >= 1 and translate($pollname,$lcletters,$ucletters) = 'BROMINATED DIPHENYLETHER' or
					$water >= 50 and translate($pollname,$lcletters,$ucletters) = 'ORGANOTIN - COMPOUNDS' or
					$water >= 20 and translate($pollname,$lcletters,$ucletters) = 'PHENOLS' or
					$water >= 50000 and translate($pollname,$lcletters,$ucletters) = 'TOTAL ORGANIC CARBON (TOC)' or
					$water >= 2000000 and translate($pollname,$lcletters,$ucletters) = 'CHLORIDES' or
					$water >= 50 and translate($pollname,$lcletters,$ucletters) = 'CYANIDES' or
					$water >= 2000 and translate($pollname,$lcletters,$ucletters) = 'FLUORIDES' or
					(($air >= 20 or $water >= 5) and translate($pollname,$lcletters,$ucletters) = 'AS AND COMPOUNDS') or
					(($air >= 10 or $water >= 5) and translate($pollname,$lcletters,$ucletters) = 'CD AND COMPOUNDS') or
					(($air >= 100 or $water >= 50) and translate($pollname,$lcletters,$ucletters) = 'CR AND COMPOUNDS') or
					(($air >= 100 or $water >= 50) and translate($pollname,$lcletters,$ucletters) = 'CU AND COMPOUNDS') or
					(($air >= 10 or $water >= 1) and translate($pollname,$lcletters,$ucletters) = 'HG AND COMPOUNDS') or
					(($air >= 50 or $water >= 20) and translate($pollname,$lcletters,$ucletters) = 'NI AND COMPOUNDS') or
					(($air >= 200 or $water >= 20) and translate($pollname,$lcletters,$ucletters) = 'PB AND COMPOUNDS') or
					(($air >= 200 or $water >= 100) and translate($pollname,$lcletters,$ucletters) = 'ZN AND COMPOUNDS') or
					(($air >= 1000 or $water >= 10) and translate($pollname,$lcletters,$ucletters) = 'DICHLOROETHANE-1,2 (DCE)') or
					(($air >= 1000 or $water >= 10) and translate($pollname,$lcletters,$ucletters) = 'DICHLOROMETHANE (DCM)') or
					(($air >= 10 or $water >= 1) and translate($pollname,$lcletters,$ucletters) = 'HEXACHLOROBENZENE (HCB)') or
					(($air >= 10 or $water >= 1) and translate($pollname,$lcletters,$ucletters) = 'HEXACHLOROCYCLOHEXANE(HCH)') or
					(($air >= 50 or $water >= 5) and translate($pollname,$lcletters,$ucletters) = 'POLYCYCLIC AROMATIC HYDROCARBONS')
"/>

				<xsl:otherwise>
				<!--	Emission not above threshold, validating next emission -->
					<xsl:call-template name="CheckThreshold">
						<xsl:with-param name="n" select="$n + 1"/>
						<xsl:with-param name="numEmissions" select="$numEmissions"/>
					</xsl:call-template>	
				</xsl:otherwise>
			</xsl:choose>  
		</xsl:if>
	</xsl:template>
	
	
	
	
	<xsl:template name="CheckActivities">
	
		<xsl:param name="secAct"/>
		<xsl:param name="mainAct"/>
		<xsl:param name="n"/>
		<xsl:param name="numActivities"/>

		<xsl:variable name="ActivityType" select="Activity[$n]/MainActivity" />

			
		<xsl:if test="$secAct &gt; $numActivities ">
				<xsl:text>Facility </xsl:text> <xsl:value-of select="FacilityName"/><xsl:text>&#10;Facility has no Main Activity.</xsl:text><xsl:text>&#10;&#10;</xsl:text>
 		</xsl:if>
 		
		<xsl:if test="$mainAct &gt; 2 ">
				<xsl:text>Facility </xsl:text> <xsl:value-of select="FacilityName"/><xsl:text>&#10;Facility has more than 1 Main Activity.</xsl:text><xsl:text>&#10;&#10;		</xsl:text>
 		</xsl:if>
				


		<xsl:if test="($n &lt; $numActivities+1)   and (not($mainAct   &gt; 2))">		
			<xsl:choose>
				<xsl:when test="$ActivityType = 1" >
					<xsl:call-template name="CheckActivities">
						<xsl:with-param name="secAct" select="$secAct"/>
						<xsl:with-param name="mainAct" select="$mainAct + 1"/>
						<xsl:with-param name="n" select="$n + 1"/>

						<xsl:with-param name="numActivities" select="$numActivities"/>
					</xsl:call-template>	
				</xsl:when>	
				<xsl:otherwise>
					<xsl:call-template name="CheckActivities">
						<xsl:with-param name="secAct" select="$secAct + 1"/>
						<xsl:with-param name="mainAct" select="$mainAct"/>
						<xsl:with-param name="n" select="$n + 1"/>

						<xsl:with-param name="numActivities" select="$numActivities"/>
					</xsl:call-template>	
				</xsl:otherwise>
			</xsl:choose>
		</xsl:if>		
		
	</xsl:template>
	
<xsl:template match="Emission" >
		<xsl:variable name="lcletters">abcdefghijklmnopqrstuvwxyz</xsl:variable>
		<xsl:variable name="ucletters">ABCDEFGHIJKLMNOPQRSTUVWXYZ</xsl:variable>
		<xsl:variable name="pollname"><xsl:value-of select="translate(PollutantName,$lcletters,$ucletters)"/></xsl:variable>
					
					<xsl:choose>
					<xsl:when test="EmissionType = 1">
							<xsl:choose>
							<xsl:when test="$pollname = 'CH4' or 
											$pollname = 'CO' or 
											$pollname = 'CO2' or 
											$pollname = 'HFCS' or 
											$pollname = 'N2O' or 
											$pollname = 'NH3' or 
											$pollname = 'NMVOC' or 
											$pollname = 'NOX' or 
											$pollname = 'PFCS' or 
											$pollname = 'SF6' or 
											$pollname = 'SOX' or 
											$pollname = 'AS AND COMPOUNDS' or 
											$pollname = 'CD AND COMPOUNDS' or 
											$pollname = 'CR AND COMPOUNDS' or 
											$pollname = 'CU AND COMPOUNDS' or 
											$pollname = 'HG AND COMPOUNDS' or 
											$pollname = 'NI AND COMPOUNDS' or 
											$pollname = 'PB AND COMPOUNDS' or 
											$pollname = 'ZN AND COMPOUNDS' or 
											$pollname = 'DICHLOROETHANE-1,2 (DCE)' or 
											$pollname = 'DICHLOROMETHANE (DCM)' or 
											$pollname = 'HEXACHLOROBENZENE (HCB)' or 
											$pollname = 'HEXACHLOROCYCLOHEXANE(HCH)' or 
											$pollname = 'PCDD+PCDF (DIOXINS+FURANS)' or 
											$pollname = 'PENTACHLOROPHENOL (PCP)' or 
											$pollname = 'TETRACHLOROETHYLENE (PER)' or 
											$pollname = 'TETRACHLOROMETHANE (TCM)' or 
											$pollname = 'TRICHLOROBENZENES (TCB)' or 
											$pollname = 'TRICHLOROETHANE-1,1,1 (TCE)' or 
											$pollname = 'TRICHLOROETHYLENE (TRI)' or 
											$pollname = 'TRICHLOROMETHANE' or 
											$pollname = 'BENZENE' or 
											$pollname = 'POLYCYCLIC AROMATIC HYDROCARBONS' or 
											$pollname = 'CHLORINE AND INORGANIC COMPOUNDS' or 
											$pollname = 'FLUORINE AND INORGANIC COMPOUNDS' or 
											$pollname = 'HCN' or 
											$pollname = 'PM10' "/>

									
							<xsl:otherwise>
									<xsl:text>Facility: </xsl:text><xsl:value-of select="../FacilityName"></xsl:value-of>:<xsl:text>&#10;</xsl:text>
									<xsl:text>Pollutant </xsl:text><xsl:value-of select="$pollname"></xsl:value-of><xsl:text> is not valid emission to air.</xsl:text><xsl:text>&#10;&#10;</xsl:text>
							</xsl:otherwise>
							</xsl:choose>
					</xsl:when>
					<xsl:when test="EmissionType = 2 or 3">
							<xsl:choose>
							<xsl:when test="$pollname = 'TOTAL - NITROGEN' or 
											$pollname = 'TOTAL - PHOSPHORUS' or 
											$pollname = 'AS AND COMPOUNDS' or 
											$pollname = 'CD AND COMPOUNDS' or 
											$pollname = 'CR AND COMPOUNDS' or 
											$pollname = 'CU AND COMPOUNDS' or 
											$pollname = 'HG AND COMPOUNDS' or 
											$pollname = 'NI AND COMPOUNDS' or 
											$pollname = 'PB AND COMPOUNDS' or 
											$pollname = 'ZN AND COMPOUNDS' or 
											$pollname = 'DICHLOROETHANE-1,2 (DCE)' or
											$pollname = 'DICHLOROMETHANE (DCM)' or 
											$pollname = 'CHLOROALKANES (C10-13)' or 
											$pollname = 'CHLORO-ALKANES (C10-13)' or 
											$pollname = 'HEXACHLOROBENZENE (HCB)' or 
											$pollname = 'HEXACHLOROBUTADIENE (HCBD)' or 
											$pollname = 'HEXACHLOROCYCLOHEXANE(HCH)' or 
											$pollname = 'HALOGENATED ORGANIC COMPOUNDS' or 
											$pollname = 'BENZENE, TOLUENE, ETHYLBENZENE, XYLENES' or
											$pollname = 'BROMINATED DIPHENYLETHER' or 
											$pollname = 'ORGANOTIN - COMPOUNDS' or 
											$pollname = 'POLYCYCLIC AROMATIC HYDROCARBONS' or
											$pollname = 'PHENOLS' or 
											$pollname = 'TOTAL ORGANIC CARBON (TOC)' or
											$pollname = 'CHLORIDES' or 
											$pollname = 'CYANIDES' or
											$pollname = 'FLUORIDES' 
											"/>
									
							<xsl:otherwise>
									<xsl:text>Facility </xsl:text><xsl:value-of select="../FacilityName"></xsl:value-of>
									<xsl:text>, Emission # </xsl:text><xsl:value-of select="position()"></xsl:value-of>:<xsl:text>&#10;</xsl:text>
									<xsl:text>Pollutant </xsl:text><xsl:value-of select="PollutantName"></xsl:value-of><xsl:text> is not valid emission to water.</xsl:text><xsl:text>&#10;&#10;</xsl:text>
							</xsl:otherwise>
							</xsl:choose>
					</xsl:when>

					</xsl:choose>
		</xsl:template>
	
<xsl:template match="/">
<xsl:text>This stylesheet validates the delivery. If you see nothing else, there are no errors.</xsl:text>

	<!--<xsl:value-of select="count(/report/Facility)"></xsl:value-of>-->
		<!-- Looping throug all emissions for each facility and checking for emissions above threshold -->

		<xsl:for-each select="/report/Facility">
		
			<xsl:variable name="numEmissions"><xsl:value-of select="count(Emission)"></xsl:value-of></xsl:variable>			
					<xsl:call-template name="CheckThreshold">
					<xsl:with-param name="n" select="1"/>
					<xsl:with-param name="numEmissions" select="$numEmissions"/>
					
		    </xsl:call-template>
		    
		</xsl:for-each>
		
		

		<xsl:for-each select="/report/Facility">
			
			<xsl:variable name="numActivities"><xsl:value-of select="count(Activity)"></xsl:value-of></xsl:variable>			
					<xsl:call-template name="CheckActivities">
					<xsl:with-param name="secAct" select="1"/>
					<xsl:with-param name="mainAct" select="1"/>
					<xsl:with-param name="n" select="1"/>

					<xsl:with-param name="numActivities" select="$numActivities"/>
		    </xsl:call-template>
		</xsl:for-each>
		
<xsl:apply-templates select="//Emission"></xsl:apply-templates>
	

<xsl:apply-templates select="/" mode="M0" /></xsl:template>
<xsl:template match="Activity[@code='1.1']" priority="4000" mode="M0">
<xsl:choose>
<xsl:when test="NosePCode = 101.01 or NosePCode = 101.02 or NosePCode = 101.04 or NosePCode = 101.05" />
<xsl:otherwise>
     <xsl:text>Facility </xsl:text><xsl:value-of select="../FacilityName"/>
     <xsl:text>, Activity code </xsl:text><xsl:value-of select="@code"/>
     <xsl:text>, NOSE-P </xsl:text><xsl:value-of select="NosePCode"/><xsl:text>:&#10;</xsl:text>
     <xsl:text>The specified NOSE-P is not valid for the selected Annex I Activity&#10;&#10;</xsl:text>
     
          
 </xsl:otherwise>
</xsl:choose>
<xsl:apply-templates mode="M0" />
</xsl:template>
<xsl:template match="Activity[@code='1.2']" priority="3999" mode="M0">
<xsl:choose>
<xsl:when test="NosePCode= 105.08" />
<xsl:otherwise>

     <xsl:text>Facility </xsl:text><xsl:value-of select="../FacilityName"/>
     <xsl:text>, Activity code </xsl:text><xsl:value-of select="@code"/>
     <xsl:text>, NOSE-P </xsl:text><xsl:value-of select="NosePCode"/><xsl:text>:&#10;</xsl:text>
     <xsl:text>The specified NOSE-P is not valid for the selected Annex I Activity&#10;&#10;</xsl:text>
        
</xsl:otherwise>
</xsl:choose>
<xsl:apply-templates mode="M0" />
</xsl:template>
<xsl:template match="Activity[@code='1.3']" priority="3998" mode="M0">
<xsl:choose>
<xsl:when test="NosePCode= 104.08" />
<xsl:otherwise>
     <xsl:text>Facility </xsl:text><xsl:value-of select="../FacilityName"/>
     <xsl:text>, Activity code </xsl:text><xsl:value-of select="@code"/>
     <xsl:text>, NOSE-P </xsl:text><xsl:value-of select="NosePCode"/><xsl:text>:&#10;</xsl:text>
     <xsl:text>The specified NOSE-P is not valid for the selected Annex I Activity&#10;&#10;</xsl:text>
 </xsl:otherwise>
</xsl:choose>
<xsl:apply-templates mode="M0" />
</xsl:template>
<xsl:template match="Activity[@code='1.4']" priority="3997" mode="M0">
<xsl:choose>
<xsl:when test="NosePCode= 104.08" />
<xsl:otherwise>
     <xsl:text>Facility </xsl:text><xsl:value-of select="../FacilityName"/>
     <xsl:text>, Activity code </xsl:text><xsl:value-of select="@code"/>
     <xsl:text>, NOSE-P </xsl:text><xsl:value-of select="NosePCode"/><xsl:text>:&#10;</xsl:text>
     <xsl:text>The specified NOSE-P is not valid for the selected Annex I Activity&#10;&#10;</xsl:text>
 </xsl:otherwise>
</xsl:choose>
<xsl:apply-templates mode="M0" />
</xsl:template>
<xsl:template match="Activity[@code='2.1/2.2/2.3/2.4/2.5/2.6']" priority="3996" mode="M0">
<xsl:choose>
<xsl:when test="NosePCode= 104.12 or NosePCode= 105.12 or NosePCode= 105.01" />
<xsl:otherwise>
     <xsl:text>Facility </xsl:text><xsl:value-of select="../FacilityName"/>
     <xsl:text>, Activity code </xsl:text><xsl:value-of select="@code"/>
     <xsl:text>, NOSE-P </xsl:text><xsl:value-of select="NosePCode"/><xsl:text>:&#10;</xsl:text>
     <xsl:text>The specified NOSE-P is not valid for the selected Annex I Activity&#10;&#10;</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:apply-templates mode="M0" />
</xsl:template>
<xsl:template match="Activity[@code='3.1/3.3/3.4/3.5']" priority="3995" mode="M0">
<xsl:choose>
<xsl:when test="NosePCode= 104.11" />
<xsl:otherwise>
 <xsl:text>Facility </xsl:text><xsl:value-of select="../FacilityName"/>
     <xsl:text>, Activity code </xsl:text><xsl:value-of select="@code"/>
     <xsl:text>, NOSE-P </xsl:text><xsl:value-of select="NosePCode"/><xsl:text>:&#10;</xsl:text>
     <xsl:text>The specified NOSE-P is not valid for the selected Annex I Activity&#10;&#10;</xsl:text>
 </xsl:otherwise>
</xsl:choose>
<xsl:apply-templates mode="M0" />
</xsl:template>
<xsl:template match="Activity[@code='3.2']" priority="3994" mode="M0">
<xsl:choose>
<xsl:when test="NosePCode= 105.11" />
<xsl:otherwise>
<xsl:text>Facility </xsl:text><xsl:value-of select="../FacilityName"/>
     <xsl:text>, Activity code </xsl:text><xsl:value-of select="@code"/>
     <xsl:text>, NOSE-P </xsl:text><xsl:value-of select="NosePCode"/><xsl:text>:&#10;</xsl:text>
     <xsl:text>The specified NOSE-P is not valid for the selected Annex I Activity&#10;&#10;</xsl:text>
 </xsl:otherwise>
</xsl:choose>
<xsl:apply-templates mode="M0" />
</xsl:template>
<xsl:template match="Activity[@code='4.1']" priority="3993" mode="M0">
<xsl:choose>
<xsl:when test="NosePCode= 105.09 or NosePCode= 107.03" />
<xsl:otherwise>
 <xsl:text>Facility </xsl:text><xsl:value-of select="../FacilityName"/>
     <xsl:text>, Activity code </xsl:text><xsl:value-of select="@code"/>
     <xsl:text>, NOSE-P </xsl:text><xsl:value-of select="NosePCode"/><xsl:text>:&#10;</xsl:text>
     <xsl:text>The specified NOSE-P is not valid for the selected Annex I Activity&#10;&#10;</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:apply-templates mode="M0" />
</xsl:template>
<xsl:template match="Activity[@code='4.2/4.3']" priority="3992" mode="M0">
<xsl:choose>
<xsl:when test="NosePCode= 105.09" />
<xsl:otherwise>
	<xsl:text>Facility </xsl:text><xsl:value-of select="../FacilityName"/>
     <xsl:text>, Activity code </xsl:text><xsl:value-of select="@code"/>
     <xsl:text>, NOSE-P </xsl:text><xsl:value-of select="NosePCode"/><xsl:text>:&#10;</xsl:text>
     <xsl:text>The specified NOSE-P is not valid for the selected Annex I Activity&#10;&#10;</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:apply-templates mode="M0" />
</xsl:template>
<xsl:template match="Activity[@code='4.4/4.6']" priority="3991" mode="M0">
<xsl:choose>
<xsl:when test="NosePCode= 105.09" />
<xsl:otherwise>
     <xsl:text>Facility </xsl:text><xsl:value-of select="../FacilityName"/>
     <xsl:text>, Activity code </xsl:text><xsl:value-of select="@code"/>
     <xsl:text>, NOSE-P </xsl:text><xsl:value-of select="NosePCode"/><xsl:text>:&#10;</xsl:text>
     <xsl:text>The specified NOSE-P is not valid for the selected Annex I Activity&#10;&#10;</xsl:text>
 </xsl:otherwise>
</xsl:choose>
<xsl:apply-templates mode="M0" />
</xsl:template>
<xsl:template match="Activity[@code='4.5']" priority="3990" mode="M0">
<xsl:choose>
<xsl:when test="NosePCode= 107.03" />
<xsl:otherwise>
     <xsl:text>Facility </xsl:text><xsl:value-of select="../FacilityName"/>
     <xsl:text>, Activity code </xsl:text><xsl:value-of select="@code"/>
     <xsl:text>, NOSE-P </xsl:text><xsl:value-of select="NosePCode"/><xsl:text>:&#10;</xsl:text>
     <xsl:text>The specified NOSE-P is not valid for the selected Annex I Activity&#10;&#10;</xsl:text>
 </xsl:otherwise>
</xsl:choose>
<xsl:apply-templates mode="M0" />
</xsl:template>
<xsl:template match="Activity[@code='5.1/5.2']" priority="3989" mode="M0">
<xsl:choose>
<xsl:when test="NosePCode= 109.01 or NosePCode= 109.06 or NosePCode= 109.07 or NosePCode= 105.14" />
<xsl:otherwise>
     <xsl:text>Facility </xsl:text><xsl:value-of select="../FacilityName"/>
     <xsl:text>, Activity code </xsl:text><xsl:value-of select="@code"/>
     <xsl:text>, NOSE-P </xsl:text><xsl:value-of select="NosePCode"/><xsl:text>:&#10;</xsl:text>
     <xsl:text>The specified NOSE-P is not valid for the selected Annex I Activity&#10;&#10;</xsl:text>
  </xsl:otherwise>
</xsl:choose>
<xsl:apply-templates mode="M0" />
</xsl:template>
<xsl:template match="Activity[@code='5.3/5.4']" priority="3988" mode="M0">
<xsl:choose>
<xsl:when test="NosePCode= 109.06 or NosePCode= 109.07" />
<xsl:otherwise>
     <xsl:text>Facility </xsl:text><xsl:value-of select="../FacilityName"/>
     <xsl:text>, Activity code </xsl:text><xsl:value-of select="@code"/>
     <xsl:text>, NOSE-P </xsl:text><xsl:value-of select="NosePCode"/><xsl:text>:&#10;</xsl:text>
     <xsl:text>The specified NOSE-P is not valid for the selected Annex I Activity&#10;&#10;</xsl:text>
  </xsl:otherwise>
</xsl:choose>
<xsl:apply-templates mode="M0" />
</xsl:template>
<xsl:template match="Activity[@code='6.1']" priority="3987" mode="M0">
<xsl:choose>
<xsl:when test="NosePCode= 105.07" />
<xsl:otherwise>
     <xsl:text>Facility </xsl:text><xsl:value-of select="../FacilityName"/>
     <xsl:text>, Activity code </xsl:text><xsl:value-of select="@code"/>
     <xsl:text>, NOSE-P </xsl:text><xsl:value-of select="NosePCode"/><xsl:text>:&#10;</xsl:text>
     <xsl:text>The specified NOSE-P is not valid for the selected Annex I Activity&#10;&#10;</xsl:text>
 </xsl:otherwise>
</xsl:choose>
<xsl:apply-templates mode="M0" />
</xsl:template>
<xsl:template match="Activity[@code='6.2']" priority="3986" mode="M0">
<xsl:choose>
<xsl:when test="NosePCode= 105.04" />
<xsl:otherwise>
     <xsl:text>Facility </xsl:text><xsl:value-of select="../FacilityName"/>
     <xsl:text>, Activity code </xsl:text><xsl:value-of select="@code"/>
     <xsl:text>, NOSE-P </xsl:text><xsl:value-of select="NosePCode"/><xsl:text>:&#10;</xsl:text>
     <xsl:text>The specified NOSE-P is not valid for the selected Annex I Activity&#10;&#10;</xsl:text>
 </xsl:otherwise>
</xsl:choose>
<xsl:apply-templates mode="M0" />
</xsl:template>
<xsl:template match="Activity[@code='6.3']" priority="3985" mode="M0">
<xsl:choose>
<xsl:when test="NosePCode= 105.05" />
<xsl:otherwise>
<xsl:text>Facility </xsl:text><xsl:value-of select="../FacilityName"/>
     <xsl:text>, Activity code </xsl:text><xsl:value-of select="@code"/>
     <xsl:text>, NOSE-P </xsl:text><xsl:value-of select="NosePCode"/><xsl:text>:&#10;</xsl:text>
     <xsl:text>The specified NOSE-P is not valid for the selected Annex I Activity&#10;&#10;</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:apply-templates mode="M0" />
</xsl:template>
<xsl:template match="Activity[@code='6.4']" priority="3984" mode="M0">
<xsl:choose>
<xsl:when test="NosePCode= 105.03" />
<xsl:otherwise>
<xsl:text>Facility </xsl:text><xsl:value-of select="../FacilityName"/>
     <xsl:text>, Activity code </xsl:text><xsl:value-of select="@code"/>
     <xsl:text>, NOSE-P </xsl:text><xsl:value-of select="NosePCode"/><xsl:text>:&#10;</xsl:text>
     <xsl:text>The specified NOSE-P is not valid for the selected Annex I Activity&#10;&#10;</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:apply-templates mode="M0" />
</xsl:template>
<xsl:template match="Activity[@code='6.5']" priority="3983" mode="M0">
<xsl:choose>
<xsl:when test="NosePCode = 109.03 or NosePCode= 109.06 or NosePCode= 105.14" />
<xsl:otherwise>
<xsl:text>Facility </xsl:text><xsl:value-of select="../FacilityName"/>
     <xsl:text>, Activity code </xsl:text><xsl:value-of select="@code"/>
     <xsl:text>, NOSE-P </xsl:text><xsl:value-of select="NosePCode"/><xsl:text>:&#10;</xsl:text>
     <xsl:text>The specified NOSE-P is not valid for the selected Annex I Activity&#10;&#10;</xsl:text>
 </xsl:otherwise>
</xsl:choose>
<xsl:apply-templates mode="M0" />
</xsl:template>
<xsl:template match="Activity[@code='6.6']" priority="3982" mode="M0">
<xsl:choose>
<xsl:when test="NosePCode= 110.04 or NosePCode= 110.05" />
<xsl:otherwise>
 <xsl:text>Facility </xsl:text><xsl:value-of select="../FacilityName"/>
     <xsl:text>, Activity code </xsl:text><xsl:value-of select="@code"/>
     <xsl:text>, NOSE-P </xsl:text><xsl:value-of select="NosePCode"/><xsl:text>:&#10;</xsl:text>
     <xsl:text>The specified NOSE-P is not valid for the selected Annex I Activity&#10;&#10;</xsl:text>
 </xsl:otherwise>
</xsl:choose>
<xsl:apply-templates mode="M0" />
</xsl:template>
<xsl:template match="Activity[@code='6.7']" priority="3981" mode="M0">
<xsl:choose>
<xsl:when test="NosePCode= 107.01 or NosePCode= 107.02 or NosePCode= 107.03 or NosePCode= 107.04" />
<xsl:otherwise>
 <xsl:text>Facility </xsl:text><xsl:value-of select="../FacilityName"/>
     <xsl:text>, Activity code </xsl:text><xsl:value-of select="@code"/>
     <xsl:text>, NOSE-P </xsl:text><xsl:value-of select="NosePCode"/><xsl:text>:&#10;</xsl:text>
     <xsl:text>The specified NOSE-P is not valid for the selected Annex I Activity&#10;&#10;</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:apply-templates mode="M0" />
</xsl:template>
<xsl:template match="Activity[@code='6.8']" priority="3980" mode="M0">
<xsl:choose>
<xsl:when test="NosePCode= 105.09" />
<xsl:otherwise>
<xsl:text>Facility </xsl:text><xsl:value-of select="../FacilityName"/>
     <xsl:text>, Activity code </xsl:text><xsl:value-of select="@code"/>
     <xsl:text>, NOSE-P </xsl:text><xsl:value-of select="NosePCode"/><xsl:text>:&#10;</xsl:text>
     <xsl:text>The specified NOSE-P is not valid for the selected Annex I Activity&#10;&#10;</xsl:text>
 </xsl:otherwise>
</xsl:choose>
<xsl:apply-templates mode="M0" />

</xsl:template>

<xsl:template match="text()" priority="-1" mode="M0" />
<xsl:template match="text()" priority="-1" />

</xsl:stylesheet>