View stylesheet

XML schemas http://bd.eionet.europa.eu/schemas/Art12Art17_reporting_2013/art12_birds.xsd
Output type RDF
Description RDF output
XSL file birds-rdf.xsl (Last modified: 16 Aug 2012 10:09 )
<?xml version="1.0" encoding="UTF-8"?>
 <!-- $Id: birds-rdf.xsl 11635 2012-04-12 08:43:03Z lainekai $ -->
 
<!DOCTYPE xsl:stylesheet [
 <!ENTITY biogeo "http://rdfdata.eionet.europa.eu/eea/biogeographic-regions/">
 <!ENTITY countries "http://rdfdata.eionet.europa.eu/eea/countries/">
]>
<xsl:stylesheet version="1.0" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:l="http://biodiversity.eionet.europa.eu/art17dataflow" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://rdfdata.eionet.europa.eu/article17/ontology/">
	<xsl:output method="xml" indent="yes"/>
	<xsl:template match="bird_reports">
		<rdf:RDF>
			<xsl:attribute name="xml:lang">
				<xsl:value-of select="@xml:lang"/>
			</xsl:attribute>
			<xsl:apply-templates/>
		</rdf:RDF>
	</xsl:template>
	<xsl:template match="bird_report">
		<BirdReport rdf:about="">
			<rdfs:label>Birds Directive Art. 12 report on  <xsl:value-of select="concat(speciesname,  ' - ', season/@desc)"/> in <xsl:value-of select="country/@desc"/>
			</rdfs:label>
			<xsl:call-template name="get-eunis-species-code"/><!--  xsl:with-param name="text" select="habitatcode"/>
			</xsl:call-template-->
			<memberstate>
				<xsl:value-of select="country/@desc"/>
			</memberstate>
			<xsl:apply-templates/>
			<forCountry>
				<xsl:attribute name="rdf:resource">&amp;countries;<xsl:value-of select="country"/>
				</xsl:attribute>
			</forCountry>
		</BirdReport>
	</xsl:template>
	<xsl:template match="range_trend|population_trend|population_trend_long|pressures_threats|measures">
		<xsl:apply-templates/>
	</xsl:template>
	<xsl:template match="pressure_threat">
		<BirdPressureThreat rdf:parseType="Resource">
			<xsl:call-template name="one-resource-predicate">
				<xsl:with-param name="text" select="code"/>
				<xsl:with-param name="table" select="local-name(parent::*)"/>
				<xsl:with-param name="predicate" select="'forPressureThreat'"/>
			</xsl:call-template>
			<xsl:call-template name="code-name"/>
			<xsl:apply-templates select="child::node()[name() != 'code']"/>
		</BirdPressureThreat>
	</xsl:template><!--  TODO check if measures will be added to rdfdata -->
	<xsl:template match="measure">
		<BirdMeasure rdf:parseType="Resource">
			<xsl:call-template name="one-resource-predicate">
				<xsl:with-param name="text" select="code"/>
				<xsl:with-param name="table" select="local-name(parent::*)"/>
				<xsl:with-param name="predicate" select="'forMeasure'"/>
			</xsl:call-template>
			<xsl:call-template name="code-name"/>
			<xsl:apply-templates select="child::node()[name() != 'code']"/>
		</BirdMeasure>
	</xsl:template>
	<xsl:template match="published">
		<xsl:call-template name="break-at-newlines">
			<xsl:with-param name="text" select="published"/>
			<xsl:with-param name="predicate" select="'published'"/>
		</xsl:call-template>
	</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: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 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, '
')">
				<xsl:call-template name="one-literal-predicate">
					<xsl:with-param name="text" select="substring-before($text, '
')"/>
					<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, '
')"/>
					<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-species-code">
		<xsl:param name="speciesname" select="speciescode/@desc"/>
		<speciesname xml:lang="">
			<xsl:value-of select="$speciesname"/>
		</speciesname>
		<xsl:if test="speciescode/@euniscode!=''">
			<forSpecies>
				<xsl:attribute name="rdf:resource">http://eunis.eea.europa.eu/species/<xsl:value-of select="speciescode/@euniscode"/>
				</xsl:attribute>
			</forSpecies>
		</xsl:if>
		<xsl:if test="speciescode/@euniscode='' ">
			<xsl:if test="document('http://converters.eionet.europa.eu/xmlfile/map-eunis-species.xml')/l:eunis/l:species[@name=$speciesname] != ''">
				<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=$speciesname]"/>
					</xsl:attribute>
				</forSpecies>
			</xsl:if>
		</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>