View stylesheet

XML schemas http://bd.eionet.europa.eu/schemas/Art12Art17_reporting_2013/art12_generalreport.xsd
Output type RDF
Description RDF output
XSL file bgeneral-rdf.xsl (Last modified: 16 Aug 2012 10:10 )
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id: hgeneral-rdf.xsl 10868 2011-12-06 12:28:57Z lainekai $ -->

 
<!DOCTYPE xsl:stylesheet [
 <!ENTITY sites "http://eunis.eea.europa.eu/sites/">
 <!ENTITY countries "http://rdfdata.eionet.europa.eu/eea/countries/">
]>

<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="birds_general_report ">
        <rdf:RDF>
			<xsl:attribute name="xml:lang"><xsl:value-of select="@xml:lang"/></xsl:attribute>
  		<GeneralReport rdf:about="">
			<rdfs:label>Report for Birds directive article 12 in <xsl:value-of select="country/@desc"/></rdfs:label>
  			<memberstate>
				<xsl:value-of select="country/@desc"/>
			</memberstate>
			<forCountry>
				<xsl:attribute name="rdf:resource">&amp;countries;<xsl:value-of					select="country" /></xsl:attribute>
			</forCountry>
            			<xsl:apply-templates select="child::node()[name() != 'country']" />
		</GeneralReport>
		</rdf:RDF>
	</xsl:template>

	<xsl:template match="species">
		<xsl:if test="normalize-space(speciesname)!=''">
			<OtherSpecies 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() != 'speciesname']"/>
			</OtherSpecies>
		</xsl:if>
	</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">&amp;sites;<xsl:value-of
					select="sitecode" /></xsl:attribute>
					<xsl:value-of select="sitecode"/>
			</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="monitoring_publications">
	
	<MonitoringPublications>

			<xsl:apply-templates/>
	
	</MonitoringPublications>

	</xsl:template>

	

		
<xsl:template match="other_publications">
	
	<OtherPublications>

			<xsl:apply-templates/>
	
	</OtherPublications>

	</xsl:template>


	<xsl:template match="other_species|compensation_measures">

		<xsl:apply-templates/>

	</xsl:template>

	
	<xsl:template match="publication">
	
			<Publication>
				<xsl:apply-templates/> <!-- select="child::node()[name() != 'speciescode' and name() != 'speciesname']"/-->
			</Publication>
		
	</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 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-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>