View stylesheet

XML schema http://www.eionet.europa.eu/schemas/eprtr/ImplementationReport.xsd
Output type EXCEL
Description MS Excel
XSL file e-prtr-questionnaire-excel.xsl (Last modified: 04 Mar 2011 09:21 )
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:office='http://openoffice.org/2000/office' 	xmlns:table='http://openoffice.org/2000/table' xmlns:text='http://openoffice.org/2000/text'>
	<xsl:output method="xml" indent="yes"/>
	
	<xsl:param name="xml_folder_uri"/>
	<xsl:param name="envelopeurl"/>

	<xsl:variable name="lang">en</xsl:variable>

	<xsl:variable name="labels" select="document(concat($xml_folder_uri,'e-prtr-questionnaire-labels.xml'))/labels" />
	<xsl:variable name="country" select="document(concat($envelopeurl,'/xml'))/envelope/countrycode"/>
	
	<xsl:variable name="type" select="/questionnaire/@type"/>
	
	<xsl:template match="questionnaire">
		<office:document-content xmlns:office='urn:oasis:names:tc:opendocument:xmlns:office:1.0' xmlns:table='urn:oasis:names:tc:opendocument:xmlns:table:1.0' office:version='1.0' xmlns:xlink='http://www.w3.org/1999/xlink' xmlns:number='urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0' xmlns:text='urn:oasis:names:tc:opendocument:xmlns:text:1.0' xmlns:fo='urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0' xmlns:style='urn:oasis:names:tc:opendocument:xmlns:style:1.0'>
			<office:automatic-styles>
				<style:style style:name='cell1' style:family='table-cell' >
					<style:properties fo:text-align='justify' fo:font-size='10pt' style:column-width="20cm"/>
					<style:text-properties fo:font-size='10pt'/>
					<style:paragraph-properties fo:text-align="justify"/>
				</style:style>
				<style:style style:name='cell2' style:family='table-cell' >
					<style:properties fo:text-align='justify' fo:font-size='10pt' style:column-width="4cm"/>
					<style:text-properties fo:font-size='10pt'/>
					<style:paragraph-properties fo:text-align="justify"/>
				</style:style>
				<style:style style:name='cell3' style:family='table-cell' >
					<style:properties fo:text-align='justify' fo:font-size='10pt' style:column-width="8cm"/>
					<style:text-properties fo:font-size='10pt'/>
					<style:paragraph-properties fo:text-align="justify"/>
				</style:style>
				<style:style style:name='Heading1' style:family="table-cell" style:parent-style-name="Default">
					<style:text-properties fo:text-align='left' fo:font-size='12pt' fo:font-style='italic' style:text-align-source='fix' fo:font-weight='bold'/>
					<style:properties fo:text-align='left' fo:font-size='12pt' fo:font-style='italic' style:text-align-source='fix' fo:font-weight='bold'/>
				</style:style>
				<style:style style:name='Heading2' style:family='table-cell' >
					<style:text-properties fo:text-align='auto' fo:font-size='11pt' fo:font-weight='bold' />
					<style:properties fo:text-align='auto' fo:font-size='11pt' fo:font-weight='bold' />
				</style:style>
				<style:style style:name='Heading3' style:family='table-cell' >
					<style:properties fo:text-align='justify' fo:font-size='10pt' fo:font-weight='bold' fo:font-style="italic"/>
					<style:text-properties  fo:font-size='10pt' fo:font-weight='bold' fo:font-style="italic"/>
					<style:paragraph-properties fo:text-align="justify"/>
				</style:style>
				<style:style style:name='Heading4' style:family='table-cell' >
					<style:text-properties fo:text-align='right' fo:font-size='10pt' fo:font-weight='bold' fo:font-style="italic"/>
					<style:properties fo:text-align='right' fo:font-size='10pt' fo:font-weight='bold' fo:font-style="italic"/>
					<style:paragraph-properties fo:text-align="justify"/>
				</style:style>
				<style:style style:name="co1" style:family="table-column">
					<style:table-column-properties fo:break-before="auto" style:column-width="30cm"/>
				</style:style>
				<style:style style:name="co2" style:family="table-column">
					<style:table-column-properties fo:break-before="auto" style:column-width="10cm"/>
				</style:style>
				<style:style style:name="co3" style:family="table-column">
					<style:table-column-properties fo:break-before="auto" style:column-width="4cm"/>
				</style:style>
				<style:style style:name="co4" style:family="table-column">
					<style:table-column-properties fo:break-before="auto" style:column-width="8cm"/>
				</style:style>
				
			</office:automatic-styles>
			<office:body>
				<office:spreadsheet>
					<table:table>
						<xsl:attribute name="table:name">Questionnaire</xsl:attribute>
						<table:table-columns>
							<table:table-column table:default-cell-value-type='string' table:default-cell-style-name='cell1' table:style-name="co1"/>
							<table:table-column table:style-name="co2" table:default-cell-style-name="cell1"/>
						</table:table-columns>
						<!-- create header rows -->
						<table:table-rows>
							<table:table-header-rows>
								<table:table-row >
									<table:table-cell >
										<text:p></text:p>
									</table:table-cell>
									<table:table-cell>
										<text:p></text:p>
									</table:table-cell>
								</table:table-row>
								<table:table-row >
									<table:table-cell table:style-name="Heading1">
										<text:p><xsl:value-of select="$labels/itemset[@type=$type and @xml:lang='en']/item[@id='h1']"/></text:p>
									</table:table-cell>
								</table:table-row>
								<table:table-row>
									<table:table-cell>
										<text:p></text:p>
									</table:table-cell>
								</table:table-row>
							</table:table-header-rows>

							<xsl:call-template name="metadata"/>

							<xsl:call-template name="buildHeading"><xsl:with-param name="heading"><xsl:value-of select="$labels/itemset[@type='B' and @xml:lang='en']/item[@id='q-1-heading']"/></xsl:with-param></xsl:call-template>
							<xsl:apply-templates select="q-1 | q-1-a | q-1-b"/>
							<xsl:call-template name="buildHeading"><xsl:with-param name="heading"><xsl:value-of select="$labels/itemset[@type='B' and @xml:lang='en']/item[@id='q-2-heading']"/></xsl:with-param></xsl:call-template>
							<xsl:apply-templates select="q-2 | q-2-a  | q-2-a-i | q-2-a-ii | q-2-b | q-2-c | q-2-d | q-2-d-i | q-2-e | q-2-f | q-2-g"/>
							<xsl:call-template name="buildHeading"><xsl:with-param name="heading"><xsl:value-of select="$labels/itemset[@type='B' and @xml:lang='en']/item[@id='q-3-heading']"/></xsl:with-param></xsl:call-template>
							<xsl:apply-templates select="q-3 | q-3-a | q-3-b | q-3-c | q-3-c | q-3-d | q-3-e | q-3-f | q-3-g | q-3-h | q-3-i| q-3-ii| q-3-iii"/>
							<xsl:call-template name="buildHeading"><xsl:with-param name="heading"><xsl:value-of select="$labels/itemset[@type='B' and @xml:lang='en']/item[@id='q-4-heading']"/></xsl:with-param></xsl:call-template>
							<xsl:apply-templates select="q-4 | q-4-a | q-4-b | q-4-c | q-4-d | q-4-a-i |q-4-a-ii-repeated | q-4-a-ii | q-4-b-i | q-4-b-ii | q-4-b-iii | q-4-b-iv | q-4-c-i" />
							<xsl:call-template name="buildHeading"><xsl:with-param name="heading"><xsl:value-of select="$labels/itemset[@type='B' and @xml:lang='en']/item[@id='q-5-heading']"/></xsl:with-param></xsl:call-template>
							<xsl:apply-templates select="q-5 | q-5-a  | q-5-b  | q-5-c" />
							<xsl:call-template name="buildHeading"><xsl:with-param name="heading"><xsl:value-of select="$labels/itemset[@type='B' and @xml:lang='en']/item[@id='q-6-heading']"/></xsl:with-param></xsl:call-template>
							<xsl:apply-templates select="q-6 | q-6-a | q-6-b" />
							<xsl:call-template name="buildHeading"><xsl:with-param name="heading"><xsl:value-of select="$labels/itemset[@type='B' and @xml:lang='en']/item[@id='q-7-heading']"/></xsl:with-param></xsl:call-template>
							<xsl:apply-templates select="q-7 | q-7-a | q-7-b | q-7-c | q-7-c-i " />
							<xsl:call-template name="buildHeading"><xsl:with-param name="heading"><xsl:value-of select="$labels/itemset[@type='A' and @xml:lang='en']/item[@id='q-8-heading']"/></xsl:with-param></xsl:call-template>
							<xsl:apply-templates select="q-8 | q-8-a" />
							<xsl:call-template name="buildHeading"><xsl:with-param name="heading"><xsl:value-of select="$labels/itemset[@type='A' and @xml:lang='en']/item[@id='q-9-heading']"/></xsl:with-param></xsl:call-template>
							<xsl:apply-templates select="q-9 | q-9-a" />
							<xsl:call-template name="buildHeading"><xsl:with-param name="heading"><xsl:value-of select="$labels/itemset[@type='A' and @xml:lang='en']/item[@id='q-10-heading']"/></xsl:with-param></xsl:call-template>
							<xsl:apply-templates select="q-10 | q-10-a | q-10-b" />
							<xsl:call-template name="buildHeading"><xsl:with-param name="heading"><xsl:value-of select="$labels/itemset[@type='A' and @xml:lang='en']/item[@id='q-11-heading']"/></xsl:with-param></xsl:call-template>
							<xsl:apply-templates select="q-11| q-11-a| q-11-b| q-11-c| q-11-d| q-11-e" />
							<xsl:call-template name="buildHeading"><xsl:with-param name="heading"><xsl:value-of select="$labels/itemset[@type='A' and @xml:lang='en']/item[@id='q-12-heading']"/></xsl:with-param></xsl:call-template>
							<xsl:apply-templates select="q-12| q-12-a" />
						</table:table-rows>
					</table:table>
					<xsl:apply-templates select="q-3-ii-table"/>
					<xsl:apply-templates select="q-4-table"/>
					<xsl:apply-templates select="q-5-b-table"/>
				</office:spreadsheet>
			</office:body>
		</office:document-content>
	</xsl:template>
	
	
	<xsl:template match="*">
		<xsl:variable  name="elem-name" select="local-name(.)"/>
		<table:table-row>
			<xsl:call-template name="buildQuestion">
				<xsl:with-param name="q"><xsl:value-of select="$labels/itemset[@type='A' and @xml:lang='en']/item[@id= $elem-name ]"/></xsl:with-param>
			</xsl:call-template>
			<xsl:call-template name="buildAnswer">
				<xsl:with-param name="answer"><xsl:value-of select="."/></xsl:with-param>
				<xsl:with-param name="yesno"><xsl:value-of select="$elem-name='q-4-b-i' or $elem-name='q-4-b-iii' or $elem-name='q-4-a-ii-repeated'"/></xsl:with-param>
			</xsl:call-template>
		</table:table-row>
	</xsl:template>
	
	<!-- ##################################       question  3-ii  table           ############################################-->
	
	<xsl:template match="q-3-ii-table">
		
		<table:table table:name="Question 3.ii">
			<table:table-columns>
				<table:table-column table:default-cell-value-type='string' table:default-cell-style-name='cell2' table:style-name="co3"/>
				<table:table-column table:default-cell-value-type='string' table:default-cell-style-name='cell3' table:style-name="co4"/>
				<table:table-column table:default-cell-value-type='string' table:default-cell-style-name='cell3' table:style-name="co4"/>
				<table:table-column table:default-cell-value-type='string' table:default-cell-style-name='cell3' table:style-name="co4"/>
				<table:table-column table:default-cell-value-type='string' table:default-cell-style-name='cell3' table:style-name="co4"/>
			</table:table-columns>
			<!-- create header rows -->
			<table:table-rows>
				<table:table-header-rows>
					<table:table-row   table:default-cell-value-type='string'>
						<table:table-cell><text:p></text:p></table:table-cell>
						<table:table-cell><text:p></text:p></table:table-cell>
						<table:table-cell><text:p></text:p></table:table-cell>
						<table:table-cell><text:p></text:p></table:table-cell>
						<table:table-cell><text:p></text:p></table:table-cell>
					</table:table-row>
					<table:table-row   table:default-cell-value-type='string' table:default-cell-style-name='Heading3' >
						<table:table-cell table:style-name="Heading2">
							<text:p><xsl:value-of select="$labels/itemset[@type='A' and @xml:lang='en']/item[@id= 'q-3-ii' ]"/></text:p>
						</table:table-cell>
					</table:table-row>
					<table:table-row   table:default-cell-value-type='string'>
						<table:table-cell table:style-name="Heading3"><text:p><xsl:value-of select="$labels/itemset[@type='A' and @xml:lang='en']/item[@id='q-3-ii-institution']"/></text:p></table:table-cell>
						<table:table-cell table:style-name="Heading3"><text:p><xsl:value-of select="$labels/itemset[@type='A' and @xml:lang='en']/item[@id='q-3-ii-institution-name']"/></text:p></table:table-cell>
						<table:table-cell table:style-name="Heading3"><text:p><xsl:value-of select="$labels/itemset[@type='A' and @xml:lang='en']/item[@id='q-3-ii-pathway']"/></text:p></table:table-cell>						
						<table:table-cell table:style-name="Heading3"><text:p><xsl:value-of select="$labels/itemset[@type='A' and @xml:lang='en']/item[@id='q-3-ii-validation']"/></text:p></table:table-cell>
						<table:table-cell table:style-name="Heading3"><text:p><xsl:value-of select="$labels/itemset[@type='A' and @xml:lang='en']/item[@id='q-3-ii-remarks']"/></text:p></table:table-cell>
					</table:table-row>
				</table:table-header-rows>
				<xsl:apply-templates/>
			</table:table-rows>
		</table:table>
	</xsl:template>
	<xsl:template match="q-3-ii-row">
		<table:table-row   table:default-cell-value-type='string'>
			<table:table-cell><text:p><xsl:value-of select="institution-type"/></text:p></table:table-cell>
			<table:table-cell><text:p><xsl:value-of select="institution-name"/></text:p></table:table-cell>
			<table:table-cell><text:p><xsl:value-of select="pathway"/></text:p></table:table-cell>
			<table:table-cell><text:p><xsl:value-of select="validation"/></text:p></table:table-cell>
			<table:table-cell><text:p><xsl:value-of select="remarks"/></text:p></table:table-cell>
		</table:table-row>
	</xsl:template>

	<!-- ##################################       question  4-a  table           ############################################-->
	
	<xsl:template match="q-4-table">
		<table:table table:name="Question 4.a">
			<table:table-columns>
				<table:table-column table:default-cell-value-type='string' table:default-cell-style-name='cell2' table:style-name="co3"/>
				<table:table-column table:default-cell-value-type='string' table:default-cell-style-name='cell3' table:style-name="co4"/>
				<table:table-column table:default-cell-value-type='string' table:default-cell-style-name='cell3' table:style-name="co4"/>
				<table:table-column table:default-cell-value-type='string' table:default-cell-style-name='cell3' table:style-name="co4"/>
			</table:table-columns>
			<!-- create header rows -->
			<table:table-rows>
				<table:table-header-rows>
					<table:table-row   table:default-cell-value-type='string'>
						<table:table-cell><text:p></text:p></table:table-cell>
						<table:table-cell><text:p></text:p></table:table-cell>
						<table:table-cell><text:p></text:p></table:table-cell>
						<table:table-cell><text:p></text:p></table:table-cell>
					</table:table-row>
					<table:table-row   table:default-cell-value-type='string' table:default-cell-style-name='Heading3' >
						<table:table-cell table:style-name="Heading2">
							<text:p><xsl:value-of select="$labels/itemset[@type='A' and @xml:lang='en']/item[@id= 'q-4-a' ]"/></text:p>
						</table:table-cell>
					</table:table-row>
					<table:table-row   table:default-cell-value-type='string'>
						<table:table-cell table:style-name="Heading3"><text:p><xsl:value-of select="$labels/itemset[@type='A' and @xml:lang='en']/item[@id='q-4-institution']"/></text:p></table:table-cell>
						<table:table-cell table:style-name="Heading3"><text:p><xsl:value-of select="$labels/itemset[@type='A' and @xml:lang='en']/item[@id='q-4-institution-name']"/></text:p></table:table-cell>
						<table:table-cell table:style-name="Heading3"><text:p><xsl:value-of select="$labels/itemset[@type='A' and @xml:lang='en']/item[@id='q-4-deadline']"/></text:p></table:table-cell>						
						<table:table-cell table:style-name="Heading3"><text:p><xsl:value-of select="$labels/itemset[@type='A' and @xml:lang='en']/item[@id='q-4-year']"/></text:p></table:table-cell>
					</table:table-row>
				</table:table-header-rows>
				<xsl:apply-templates/>
			</table:table-rows>
		</table:table>
	</xsl:template>
	<xsl:template match="q-4-row">
		<table:table-row   table:default-cell-value-type='string'>
			<table:table-cell><text:p><xsl:value-of select="institution-type"/></text:p></table:table-cell>
			<table:table-cell><text:p><xsl:value-of select="institution-name"/></text:p></table:table-cell>
			<table:table-cell><text:p><xsl:value-of select="deadline"/></text:p></table:table-cell>
			<table:table-cell><text:p><xsl:value-of select="year"/></text:p></table:table-cell>
		</table:table-row>
	</xsl:template>
	<!-- ##################################       question  5-b  table           ############################################-->
	
	<xsl:template match="q-5-b-table">
		<table:table table:name="Question 5.b">
			<table:table-columns>
				<table:table-column table:default-cell-value-type='string' table:default-cell-style-name='cell2' table:style-name="co3"/>
				<table:table-column table:default-cell-value-type='string' table:default-cell-style-name='cell3' table:style-name="co4"/>
				<table:table-column table:default-cell-value-type='string' table:default-cell-style-name='cell3' table:style-name="co4"/>
				<table:table-column table:default-cell-value-type='string' table:default-cell-style-name='cell3' table:style-name="co4"/>
			</table:table-columns>
			<!-- create header rows -->
			<table:table-rows>
				<table:table-header-rows>
					<table:table-row   table:default-cell-value-type='string'>
						<table:table-cell><text:p></text:p></table:table-cell>
						<table:table-cell><text:p></text:p></table:table-cell>
						<table:table-cell><text:p></text:p></table:table-cell>
						<table:table-cell><text:p></text:p></table:table-cell>
					</table:table-row>
					<table:table-row   table:default-cell-value-type='string' table:default-cell-style-name='Heading3' >
						<table:table-cell table:style-name="Heading2">
							<text:p><xsl:value-of select="$labels/itemset[@type='A' and @xml:lang='en']/item[@id= 'q-5-b' ]"/></text:p>
						</table:table-cell>
					</table:table-row>
					<table:table-row   table:default-cell-value-type='string'>
						<table:table-cell table:style-name="Heading3"><text:p><xsl:value-of select="$labels/itemset[@type='A' and @xml:lang='en']/item[@id='q-5-b-measure-type']"/></text:p></table:table-cell>
						<table:table-cell table:style-name="Heading3"><text:p><xsl:value-of select="$labels/itemset[@type='A' and @xml:lang='en']/item[@id='q-5-b-reference']"/></text:p></table:table-cell>
						<table:table-cell table:style-name="Heading3"><text:p><xsl:value-of select="$labels/itemset[@type='A' and @xml:lang='en']/item[@id='q-5-b-authority']"/></text:p></table:table-cell>						
						<table:table-cell table:style-name="Heading3"><text:p><xsl:value-of select="$labels/itemset[@type='A' and @xml:lang='en']/item[@id='q-5-b-data-quality-check']"/></text:p></table:table-cell>
					</table:table-row>
				</table:table-header-rows>
				<xsl:apply-templates/>
			</table:table-rows>
		</table:table>
	</xsl:template>
	<xsl:template match="q-5-b-row">
		<table:table-row   table:default-cell-value-type='string'>
			<table:table-cell><text:p><xsl:value-of select="measure-type"/></text:p></table:table-cell>
			<table:table-cell><text:p><xsl:value-of select="reference"/></text:p></table:table-cell>
			<table:table-cell><text:p><xsl:value-of select="authority"/></text:p></table:table-cell>
			<table:table-cell><text:p><xsl:value-of select="data-quality-check"/></text:p></table:table-cell>
		</table:table-row>
	</xsl:template>
	<xsl:template name="buildHeading">
		<xsl:param name="heading" select="''"/>
		
		<table:table-row>
			<table:table-cell  table:style-name="Heading2">
				<text:p>
					<xsl:value-of select="$heading"/>
				</text:p>
			</table:table-cell>
		</table:table-row>
	</xsl:template>
	
	<xsl:template name="buildQuestion">
		<xsl:param name="q" select="''"/>
		<table:table-cell  table:style-name="Heading3">
			<text:p>
				<xsl:value-of select="$q"/>
			</text:p>
		</table:table-cell>
	</xsl:template>
	
	<xsl:template name="buildAnswer">
		<xsl:param name="answer" select="''"/>		
		<xsl:param name="yesno" select="'false'"/>		
			<table:table-cell  table:style-name="cell1">
				<text:p>
					<xsl:choose>
						<xsl:when test="$yesno='true'">
							<xsl:call-template name="YesNoUnknown">
								<xsl:with-param name="Param" select="."/>
							</xsl:call-template>
						</xsl:when>
						<xsl:otherwise>
							<xsl:value-of select="."/>
						</xsl:otherwise>
					</xsl:choose>
				</text:p>
			</table:table-cell>
	</xsl:template>
	<!-- YesNoUnknown implementation -->
	<xsl:template name="YesNoUnknown">
		<xsl:param name="Param"/>
		<xsl:choose>
			<xsl:when test="$Param = '1' or $Param = 'true'">yes</xsl:when>
			<xsl:when test="$Param = '0' or $Param = 'false'">no</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="."/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	<xsl:template name="metadata">
		<table:table-row>
			<table:table-cell  table:style-name="Heading4">
				<text:p>Reporting country</text:p>
			</table:table-cell>
			<table:table-cell  table:style-name="cell1">
				<text:p><xsl:value-of select="$country"/></text:p>
			</table:table-cell>
		</table:table-row>
		<table:table-row>
			<table:table-cell  table:style-name="Heading4">
				<text:p>Questionnaire type</text:p>
			</table:table-cell>
			<table:table-cell  table:style-name="cell1">
				<text:p>
					<xsl:if test="@type='A'">A - mandatory + voluntary questions</xsl:if>
					<xsl:if test="@type='B'">B - mandatory questions</xsl:if>
				</text:p>
			</table:table-cell>
		</table:table-row>
		<table:table-row>
			<table:table-cell  table:style-name="Heading4">
				<text:p>Reporting language</text:p>
			</table:table-cell>
			<table:table-cell  table:style-name="cell1">
				<text:p><xsl:value-of select="@xml:lang"/></text:p>
			</table:table-cell>
		</table:table-row>
	</xsl:template>
</xsl:stylesheet>