View stylesheet

XML schemas http://biodiversity.eionet.europa.eu/schemas/bernconvention/derogations.xsd
Output type RDF
Description Show as RDF
XSL file derogations-rdf.xsl (Last modified: 06 Mar 2013 15:44 )
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [
 <!ENTITY biogeo "http://rdfdata.eionet.europa.eu/eea/biogeographic-regions/">
 <!ENTITY countries "http://rdfdata.eionet.europa.eu/ramon/nuts/">
 <!ENTITY nuts "http://rdfdata.eionet.europa.eu/ramon/nuts/">
]>
<!--
     For http://biodiversity.eionet.europa.eu/schemas/bernconvention/derogations.xsd
     $Id: derogations-rdf.xsl 13512 2013-03-06 14:42:10Z roug $
  -->
<xsl:stylesheet version="1.0"
    xmlns="http://rdfdata.eionet.europa.eu/habdir/ontology/"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:l="http://biodiversity.eionet.europa.eu/art17dataflow"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method='xml' version='1.0' encoding='UTF-8' indent='yes'/>

<xsl:variable name="habitatsURL" select="'http://rod.eionet.europa.eu/obligations/268'"/>
<xsl:variable name="birdsURL" select="'http://rod.eionet.europa.eu/obligations/276'"/>

<xsl:template match="derogationJustification|licensingAuthority|licenseValidFrom|licenseValidUntil|
      sensitive|numberOfLicenses|location|alternativesAssessed|
      supervisoryMeasure|comments|licensedJustification|
      strictlySupervisedConditions|selectiveBasis|impactOnPopulation">
    <xsl:if test="string-length(.) &gt; 0">
        <xsl:element name="{local-name()}"><xsl:value-of select="text()"/></xsl:element>
    </xsl:if>
</xsl:template>

<xsl:template match="species">
    <xsl:element name="{local-name()}"><xsl:value-of select="text()"/></xsl:element>
    <xsl:if test="normalize-space(.)!=''">
        <xsl:call-template name="split-species">
            <xsl:with-param name="text" select="." />
        </xsl:call-template>
    </xsl:if>
</xsl:template>

<xsl:template name="split-species">
    <xsl:param name="text" select="."/>
    <xsl:choose>
        <xsl:when test="contains($text, ',')">
            <xsl:call-template name="get-eunis-species-code">
                <xsl:with-param name="text" select="normalize-space(substring-before($text, ','))"/>
            </xsl:call-template>
            <xsl:call-template name="split-species">
                <xsl:with-param name="text" select="substring-after($text, ',')"/>
            </xsl:call-template>
        </xsl:when>
        <xsl:otherwise>
            <xsl:call-template name="get-eunis-species-code">
                <xsl:with-param name="text" select="normalize-space($text)"/>
            </xsl:call-template>
        </xsl:otherwise>
    </xsl:choose>
</xsl:template>

<xsl:template name="get-eunis-species-code">
    <xsl:param name="text" select="."/>
    <speciesClean><xsl:value-of select="$text"/></speciesClean>
    <xsl:if test="document('http://converters.eionet.europa.eu/xmlfile/map-eunis-species.xml')/l:eunis/l:species[@name=$text] != ''">
        <xsl:element name="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>
        </xsl:element>
    </xsl:if>
</xsl:template>

<xsl:template match="bioRegions/bioRegion">
    <xsl:element name="{local-name()}">
        <xsl:attribute name="rdf:resource">&biogeo;<xsl:value-of select="./@code"/></xsl:attribute>
    </xsl:element>
</xsl:template>

<xsl:template match="regions/region">
    <xsl:element name="{local-name()}">
        <xsl:attribute name="rdf:resource">&nuts;<xsl:value-of select="./@code"/></xsl:attribute>
    </xsl:element>
</xsl:template>

<xsl:template match="reasons/reason|activities/activity|methods/method">
    <xsl:element name="{local-name()}"><xsl:value-of select="text()"/></xsl:element>
</xsl:template>

<xsl:template match="licensed|actuallyTaken|populationSize">
    <xsl:for-each select="*">
        <xsl:if test="string-length(.) &gt; 0">
            <xsl:element name="{concat(local-name(..),'_',local-name())}">
                <xsl:if test="string(number(text())) != 'NaN'">
                     <xsl:attribute name="rdf:datatype">http://www.w3.org/2001/XMLSchema#decimal</xsl:attribute>
                </xsl:if>
            <xsl:value-of select="text()"/></xsl:element>
        </xsl:if>
    </xsl:for-each>
</xsl:template>


<xsl:template match="/">
  <rdf:RDF>
  
  <xsl:for-each select="derogations/derogation">
    <Derogation>
        <xsl:attribute name="rdf:ID"><xsl:value-of select="generate-id()"/></xsl:attribute>
        <rdfs:label>Derogation for <xsl:value-of select="species"/> in <xsl:value-of select="regions/region"/></rdfs:label>
        <country><xsl:value-of select="/derogations/@country"/></country>
        <countryRef>
            <xsl:attribute name="rdf:resource">&countries;<xsl:value-of select="/derogations/@country"/></xsl:attribute>
        </countryRef>
        <userIdentity><xsl:value-of select="./@userIdentity"/></userIdentity>
	<derogationReference><xsl:value-of select="./@derogation_reference"/></derogationReference>
        <userDerogationReference><xsl:value-of select="./@user_derogation_ref"/></userDerogationReference>
	<forObligation><xsl:attribute name="rdf:resource"><xsl:value-of select="./@directive"/></xsl:attribute></forObligation>

        <xsl:apply-templates/>

	</Derogation>
	</xsl:for-each>
</rdf:RDF>
</xsl:template>


</xsl:stylesheet>