View stylesheet

XML schemas http://bd.eionet.europa.eu/schemas/Art12Art17_reporting_2013/art17_generalreport.xsd
Output type RDF
Description RDF output
XSL file hgeneral-rdf.xsl (Last modified: 16 Aug 2012 10:11 )
<?xml version="1.0" encoding="UTF-8"?>
 
<!DOCTYPE xsl:stylesheet [
 <!ENTITY sites "http://eunis.eea.europa.eu/sites/">
 <!ENTITY countries "http://rdfdata.eionet.europa.eu/eea/countries/">
]>
<!-- $Id: hgeneral-rdf.xsl 11512 2012-03-26 06:56:52Z lainekai $ -->
<xsl:stylesheet version="1.0"
	xmlns="http://rdfdata.eionet.europa.eu/article17/generalreport" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
	xmlns:l="http://biodiversity.eionet.europa.eu/art17dataflow/">
	<xsl:output method="xml" indent="yes"/>

	<xsl:template match="report">
        <rdf:RDF>
			<xsl:attribute name="xml:lang"><xsl:value-of select="@xml:lang"/></xsl:attribute>
  		<GeneralReport rdf:about="">
			<rdfs:label>General Report for Habitats directive article 17 in <xsl:value-of select="country/@desc"/></rdfs:label>
  			<memberstate>
				<xsl:value-of select="country/@desc"/>
			</memberstate>
			<forCountry>
				<xsl:attribute name="rdf:resource">&countries;<xsl:value-of   select="country" /></xsl:attribute>
			</forCountry>
            <xsl:apply-templates/>
		</GeneralReport>
		</rdf:RDF>
	</xsl:template>

	<xsl:template
		match="compensation_measures|reintroduction_of_species">
		<xsl:apply-templates/>
	</xsl:template>


	<!--  TODO check if measures will be added to rdfdata -->
	<xsl:template match="measure">
		<CompensationMeasure rdf:parseType="Resource">
            		<sitecode>
				<xsl:attribute name="rdf:resource">&sites;<xsl:value-of    select="sitecode" /></xsl:attribute>
			</sitecode>
			<xsl:apply-templates select="child::node()[name() != 'sitecode']"/>
		</CompensationMeasure>
	</xsl:template>

	<xsl:template match="additional_information">
		<xsl:call-template name="break-at-newlines">
			<xsl:with-param name="text" select="published"/>
			<xsl:with-param name="predicate" select="'additional_information'"/>
		</xsl:call-template>
	</xsl:template>

	<xsl:template match="species">
		<xsl:if test="normalize-space(speciescode)!=''">
			<ReintroductionOfSpecies rdf:parseType="Resource">
				<xsl:call-template name="get-eunis-species-code">
					<xsl:with-param name="text" select="normalize-space(speciesname)"/>
				</xsl:call-template>
				<xsl:apply-templates select="child::node()[name() != 'speciescode' and name() != 'speciesname']"/>
			</ReintroductionOfSpecies>
		</xsl:if>
	</xsl:template>

	<xsl:template name="fill-multiple">
		<xsl:param name="text"/>
		<xsl:param name="predicate"/>
		<xsl:param name="table"/>
		<xsl:choose>
			<xsl:when test="contains($text, ' ')">
				<xsl:call-template name="one-resource-predicate">
					<xsl:with-param name="text" select="substring-before($text, ' ')"/>
					<xsl:with-param name="predicate" select="$predicate"/>
					<xsl:with-param name="table" select="$table"/>
				</xsl:call-template>

				<xsl:text disable-output-escaping="yes"> </xsl:text>
				<xsl:call-template name="fill-multiple">
					<xsl:with-param name="text" select="substring-after($text, ' ')"/>
					<xsl:with-param name="predicate" select="$predicate"/>
					<xsl:with-param name="table" select="$table"/>
				</xsl:call-template>
			</xsl:when>
			<xsl:when test="$text=''"/>
			<xsl:otherwise>
				<xsl:call-template name="one-resource-predicate">
					<xsl:with-param name="text" select="$text"/>
					<xsl:with-param name="predicate" select="$predicate"/>
					<xsl:with-param name="table" select="$table"/>
				</xsl:call-template>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template match="favourable-range">
		<xsl:if test="string-length(@qualifier)!=0 or string-length(.)!=0">
			<complementary_favourable_range>
				<xsl:choose>
					<xsl:when test="string-length(@qualifier)!= 0">
						<xsl:value-of select="@qualifier"/>
						<xsl:text> </xsl:text>
						<xsl:value-of select="../../range/surface-area"/>
						<xsl:text> km2</xsl:text>
					</xsl:when>
					<xsl:otherwise>
						<xsl:value-of select="."/>
					</xsl:otherwise>
				</xsl:choose>
			</complementary_favourable_range>
		</xsl:if>
	</xsl:template>

	<xsl:template match="favourable-area">
		<xsl:if test="string-length(@qualifier)!=0 or string-length(.)!=0">
			<complementary_favourable_area>
				<xsl:choose>
					<xsl:when test="string-length(@qualifier)!= 0">
						<xsl:value-of select="@qualifier"/>
						<xsl:text> </xsl:text>
						<xsl:value-of select="../../coverage/surface-area"/>
						<xsl:text> km2</xsl:text>
					</xsl:when>
					<xsl:otherwise>
						<xsl:value-of select="."/>
					</xsl:otherwise>
				</xsl:choose>
			</complementary_favourable_area>
		</xsl:if>
	</xsl:template>

	<xsl:template name="one-resource-predicate">
		<xsl:param name="text"/>
		<xsl:param name="predicate"/>
		<xsl:param name="table"/>
		<xsl:if test="string-length($text)!=0">
			<xsl:element name="{$predicate}">
				<xsl:attribute name="rdf:resource">http://rdfdata.eionet.europa.eu/article17/<xsl:value-of
					select="$table" />/<xsl:value-of select="$text"/></xsl:attribute>
			</xsl:element>
		</xsl:if>
	</xsl:template>

	<xsl:template name="break-at-newlines">
		<xsl:param name="text"/>
		<xsl:param name="predicate"/>
		<xsl:choose>
			<xsl:when test="contains($text, '&#13;')">
				<xsl:call-template name="one-literal-predicate">
					<xsl:with-param name="text"
						select="substring-before($text, '&#13;')" />
					<xsl:with-param name="predicate" select="$predicate"/>
				</xsl:call-template>
				<xsl:call-template name="break-at-newlines">
					<xsl:with-param name="text"
						select="substring-after($text, '&#13;')" />
					<xsl:with-param name="predicate" select="$predicate"/>
				</xsl:call-template>
			</xsl:when>
			<xsl:when test="$text=''"/>
			<xsl:otherwise>
				<xsl:call-template name="one-literal-predicate">
					<xsl:with-param name="text" select="$text"/>
					<xsl:with-param name="predicate" select="$predicate"/>
				</xsl:call-template>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template name="one-literal-predicate">
		<xsl:param name="text" select="."/>
		<xsl:param name="predicate" select="name(.)"/>
		<xsl:element name="{$predicate}">
			<xsl:value-of select="$text"/>
		</xsl:element>
	</xsl:template>

	<xsl:template match="text()"/>

	<xsl:template name="get-eunis-habitats-code">
		<xsl:param name="text" select="."/>
		<habitatcode>
			<xsl:value-of select="$text"/>
		</habitatcode>
		<xsl:if
			test="document('http://converters.eionet.europa.eu/xmlfile/map-eunis-habitats.xml')/l:n2000habitats/l:n2000[@code=$text] != ''">
			<forHabitat>
				<xsl:attribute name="rdf:resource">http://eunis.eea.europa.eu/habitats/<xsl:value-of
					select="document('http://converters.eionet.europa.eu/xmlfile/map-eunis-habitats.xml')/l:n2000habitats/l:n2000[@code=$text]" /></xsl:attribute>
			</forHabitat>
		</xsl:if>
	</xsl:template>

	<xsl:template name="get-eunis-species-code">
		<xsl:param name="text" select="."/>
		<speciesname xml:lang="">
			<xsl:value-of select="$text"/>
		</speciesname>
		<xsl:if
			test="document('http://converters.eionet.europa.eu/xmlfile/map-eunis-species.xml')/l:eunis/l:species[@name=$text] != ''">
			<forSpecies>
				<xsl:attribute name="rdf:resource">http://eunis.eea.europa.eu/species/<xsl:value-of
					select="document('http://converters.eionet.europa.eu/xmlfile/map-eunis-species.xml')/l:eunis/l:species[@name=$text]" /></xsl:attribute>
			</forSpecies>
		</xsl:if>
	</xsl:template>

	<xsl:template match="*">
		<xsl:if test="string-length(@desc)!=0">
			<xsl:call-template name="one-literal-predicate">
				<xsl:with-param name="text">
					<xsl:value-of select="concat(@desc, ' (' , . , ')') "/>
				</xsl:with-param>
			</xsl:call-template>
		</xsl:if>
		<xsl:if test="not (@desc)">
			<xsl:call-template name="one-literal-predicate"/>
		</xsl:if>
	</xsl:template>

	<xsl:template name="code-name">
		<xsl:param name="text" select="code/@desc"/>
		<!--
			xsl:param name="predicate" select="concat(local-name(parent::*)
			,'name')"/
		-->
		<xsl:param name="predicate" select="concat(name(.) ,'name')"/>
		<xsl:call-template name="one-literal-predicate">
			<xsl:with-param name="text" select="$text"/>
			<xsl:with-param name="predicate" select="$predicate"/>
		</xsl:call-template>
	</xsl:template>

</xsl:stylesheet>