View stylesheet

XML schema http://bd.eionet.europa.eu/schemas/Art12Art17_reporting_2013/art17_species.xsd
Output type RDF
Description RDF output
XSL file species-rdf.xsl (Last modified: 04 Jul 2013 15:08 )
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id: habitats_species-rdf.xsl 14357 2013-07-04 13:06:46Z roug $ -->
 
<!DOCTYPE xsl:stylesheet [
 <!ENTITY biogeo "http://rdfdata.eionet.europa.eu/eea/biogeographic-regions/">
 <!ENTITY countries "http://rdfdata.eionet.europa.eu/eea/countries/">
 <!ENTITY xsd "http://www.w3.org/2001/XMLSchema#">
 <!ENTITY asmnt "http://dd.eionet.europa.eu/vocabulary/art17_2012/assessments/">
 <!ENTITY pmethod "http://dd.eionet.europa.eu/vocabulary/art17_2012/methods_pressures/">
 <!ENTITY umethod "http://dd.eionet.europa.eu/vocabulary/art17_2012/methods_used/">
 <!ENTITY trend "http://dd.eionet.europa.eu/vocabulary/art17_2012/trends/">
 <!ENTITY ctrend "http://dd.eionet.europa.eu/vocabulary/art17_2012/trends_conclusion/">
 <!ENTITY measures "http://dd.eionet.europa.eu/vocabulary/art17_2012/measures/">
 <!ENTITY pnumber "http://dd.eionet.europa.eu/vocabulary/art17_2012/population_number/">
]>
<xsl:stylesheet version="1.0"
        xmlns="http://rdfdata.eionet.europa.eu/article17/ontology/"
        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="habitat_reports|species_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="habitat_report">
        <HabitatTypeReport>
            <xsl:attribute name="rdf:about">#<xsl:value-of select="habitatcode"/></xsl:attribute>
            <rdfs:label>Habitats directive art. 17 report for habitat type <xsl:value-of select="habitatcode"/> in <xsl:value-of select="country/@desc"/></rdfs:label>
            <xsl:apply-templates/>
        </HabitatTypeReport>
    </xsl:template>

    <xsl:template match="species_report">
        <SpeciesReport>
            <xsl:attribute name="rdf:about">#<xsl:value-of select="speciescode"/></xsl:attribute>
            <rdfs:label>Habitat Directive Art. 17 report on  <xsl:value-of select="speciesname"/> in <xsl:value-of select="country/@desc"/></rdfs:label>
            <xsl:apply-templates/>
        </SpeciesReport>
    </xsl:template>

    <xsl:template match="regional">
        <xsl:apply-templates/>
    </xsl:template>

    <xsl:template match="habitat_report/regional/region">
        <hasRegionalReport>
            <HabitatTypeRegionalReport>
                <xsl:attribute name="rdf:about">#<xsl:value-of select="code"/><xsl:value-of select="../../habitatcode"/></xsl:attribute>
                <rdfs:label>Report on habitat type <xsl:value-of select="../../habitatcode"/> for <xsl:value-of select="code"/> biogeographical region in <xsl:value-of select="../../country/@desc"/></rdfs:label>
                <forCountry>
                    <xsl:attribute name="rdf:resource">&countries;<xsl:value-of select="../../country/@isocode"/></xsl:attribute>
                </forCountry>
                <memberstate>
                    <xsl:value-of select="../../country/@desc"/>
                </memberstate>
                <habitatcode>
                        <xsl:value-of select="../../habitatcode"/>
                </habitatcode>
                <region>
                    <xsl:attribute name="rdf:resource">&biogeo;<xsl:value-of select="code"/></xsl:attribute>
                </region>
                <xsl:apply-templates/>
            </HabitatTypeRegionalReport>
        </hasRegionalReport>
    </xsl:template>

    <xsl:template match="species_report/regional/region">
        <hasRegionalReport>
            <SpeciesRegionalReport>
                <xsl:attribute name="rdf:about">#<xsl:value-of select="code"/><xsl:value-of select="../../speciescode"/></xsl:attribute>
                <rdfs:label>Report on species <xsl:value-of select="../../speciescode"/> for <xsl:value-of select="code"/> biogeographical region in <xsl:value-of select="../../country/@desc"/></rdfs:label>
                <forCountry>
                    <xsl:attribute name="rdf:resource">&countries;<xsl:value-of select="../../country/@isocode"/></xsl:attribute>
                </forCountry>
                <memberstate>
                    <xsl:value-of select="../../country/@desc"/>
                </memberstate>
                <speciescode>
                    <xsl:value-of select="../../speciescode"/>
                </speciescode>
                <speciesname>
                    <xsl:value-of select="../../speciesname"/>
                </speciesname>
                <region>
                    <xsl:attribute name="rdf:resource">&biogeo;<xsl:value-of select="code"/></xsl:attribute>
                </region>
                <xsl:apply-templates/>
            </SpeciesRegionalReport>
        </hasRegionalReport>
    </xsl:template>

    <!-- Country reference -->
    <xsl:template match="country">
        <xsl:element name="{local-name()}">
            <xsl:attribute name="rdf:resource">&countries;<xsl:value-of select="@isocode"/></xsl:attribute>
        </xsl:element>
    </xsl:template>

    <!-- Boolean properties -->
    <xsl:template match="distribution_map|additional_distribution_map|range_map|
         complementary_favourable_range_unknown|
         range_reasons_for_change_a|range_reasons_for_change_b|range_reasons_for_change_c|
         complementary_favourable_area_unknown|
         area_reasons_for_change_a|area_reasons_for_change_b|area_reasons_for_change_c|
         type_legal|type_administrative|type_contractual|type_recurrent|type_oneoff|
         location_inside|location_outside|location_both|sensitive_species|
         broad_evaluation_maintain|broad_evaluation_enhance|broad_evaluation_longterm|
         broad_evaluation_noeffect|broad_evaluation_unknown|broad_evaluation_notevaluated|
         complementary_favourable_population_unknown|
         population_reasons_for_change_a|population_reasons_for_change_b|population_reasons_for_change_c|
         habitat_reasons_for_change_a|habitat_reasons_for_change_b|habitat_reasons_for_change_c">
        <xsl:element name="{local-name()}">
            <xsl:attribute name="rdf:datatype">&xsd;boolean</xsl:attribute>
        <xsl:value-of select="."/></xsl:element>
    </xsl:template>

    <!-- Assessments -->
    <xsl:template match="conclusion_range|conclusion_area|conclusion_structure|conclusion_future|conclusion_assessment|
       conclusion_population|conclusion_habitat">
        <xsl:if test="normalize-space(text()) != ''">
            <xsl:element name="{local-name()}">
                <xsl:attribute name="rdf:resource">&asmnt;<xsl:value-of select="normalize-space(text())"/></xsl:attribute>
            </xsl:element>
        </xsl:if>
    </xsl:template>

    <!-- Method used -->
    <xsl:template match="coverage_method|coverage_trend_method|coverage_trend_long_method|
            distribution_method|habitat_method|
            population_method|population_trend_method|population_trend_long_method|
            range_method|structure_and_functions_method|
            natura2000_area_method|natura2000_population_method">
        <xsl:if test="normalize-space(text()) != ''">
            <xsl:element name="{local-name()}">
                <xsl:attribute name="rdf:resource">&umethod;<xsl:value-of select="normalize-space(text())"/></xsl:attribute>
            </xsl:element>
        </xsl:if>
    </xsl:template>

    <!-- Pressures method -->
    <xsl:template match="pressures_method">
        <xsl:if test="normalize-space(text()) != ''">
            <xsl:element name="{local-name()}">
                <xsl:attribute name="rdf:resource">&pmethod;<xsl:value-of select="normalize-space(text())"/></xsl:attribute>
            </xsl:element>
        </xsl:if>
    </xsl:template>

    <!-- Population units -->
    <xsl:template match="population_size_unit|natura2000_population_unit">
        <xsl:if test="normalize-space(text()) != ''">
            <xsl:element name="{local-name()}">
                <xsl:attribute name="rdf:resource">&pnumber;<xsl:value-of select="normalize-space(text())"/></xsl:attribute>
            </xsl:element>
        </xsl:if>
    </xsl:template>

    <xsl:template match="ranking">
        <xsl:if test="normalize-space(text()) != ''">
            <xsl:call-template name="one-resource-predicate">
                <xsl:with-param name="text" select="text()"/>
                <xsl:with-param name="table" select="local-name(.)"/>
                <xsl:with-param name="predicate" select="local-name(.)"/>
            </xsl:call-template>
        </xsl:if>
    </xsl:template>

    <!-- Trend -->
    <xsl:template match="coverage_trend|coverage_trend_long|
            habitat_trend|habitat_trend_long|
            natura2000_area_trend|natura2000_population_trend|
            population_trend|population_trend_long|
            range_trend|range_trend_long">
        <xsl:if test="normalize-space(text()) != ''">
            <xsl:element name="{local-name()}">
                <xsl:choose>
                    <xsl:when test="normalize-space(text()) = '+'">
                        <xsl:attribute name="rdf:resource">&trend;i</xsl:attribute>
                    </xsl:when>
                    <xsl:when test="normalize-space(text()) = '-'">
                        <xsl:attribute name="rdf:resource">&trend;d</xsl:attribute>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:attribute name="rdf:resource">&trend;<xsl:value-of select="text()"/></xsl:attribute>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:element>
        </xsl:if>
    </xsl:template>

    <!-- Conclusion trend -->
    <xsl:template match="conclusion_area_trend|conclusion_range_trend|
            conclusion_population_trend|conclusion_habitat_trend|
            conclusion_future_trends|conclusion_assessment_trend|
            conclusion_structure_trend|conclusion_future_trend">
        <xsl:if test="normalize-space(text()) != ''">
            <xsl:element name="{local-name()}">
                <xsl:choose>
                    <xsl:when test="normalize-space(text()) = '+'">
                        <xsl:attribute name="rdf:resource">&ctrend;p</xsl:attribute>
                    </xsl:when>
                    <xsl:when test="normalize-space(text()) = '-'">
                        <xsl:attribute name="rdf:resource">&ctrend;m</xsl:attribute>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:attribute name="rdf:resource">&ctrend;<xsl:value-of select="text()"/></xsl:attribute>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:element>
        </xsl:if>
    </xsl:template>

    <xsl:template match="pressures|threats|pollution_qualifiers|typical_species|measures">
        <xsl:apply-templates/>
    </xsl:template>

    <xsl:template match="pollution_qualifier">
        <xsl:call-template name="code-name">
            <xsl:with-param name="predicate" select="'pollution_qualifier'"/>
            <xsl:with-param name="text" select="code/@desc"/>
        </xsl:call-template>
        <xsl:apply-templates select="child::node()[name() != 'code']"/>
    </xsl:template>

    <xsl:template match="pressure|threat">
        <xsl:element name="{local-name()}">
            <xsl:attribute name="rdf:parseType">Resource</xsl:attribute>
            <rdfs:label><xsl:value-of select="code/@desc"/></rdfs:label>
            <xsl:call-template name="one-resource-predicate">
                <xsl:with-param name="text" select="code"/>
                <xsl:with-param name="table" select="'threats'"/>
                <xsl:with-param name="predicate" select="'forPressureThreat'"/>
            </xsl:call-template>
            <xsl:apply-templates/>
        </xsl:element>
    </xsl:template>

    <!--  TODO check if measures will be added to rdfdata -->
    <xsl:template match="measure">
        <measure>
            <xsl:attribute name="rdf:parseType">Resource</xsl:attribute>
            <rdfs:label><xsl:value-of select="code/@desc"/></rdfs:label>
            <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:apply-templates/>
        </measure>
    </xsl:template>

<!--
    <xsl:template match="published">
        <xsl:if test="normalize-space(text()) != ''">
            <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:if>
    </xsl:template>
-->

    <xsl:template match="species">
        <xsl:if test="normalize-space(speciesname) != ''">
            <typicalSpecies><xsl:value-of select="normalize-space(speciesname)"/></typicalSpecies>
        </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://dd.eionet.europa.eu/vocabulary/art17_2012/<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"/>
        <xsl:param name="predicate"/>
        <xsl:element name="{$predicate}">
            <xsl:value-of select="$text"/>
        </xsl:element>
    </xsl:template>

    <!-- Drop text nodes incl. whitespace -->
    <xsl:template match="text()"/>

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

    <xsl:template name="code-name">
        <xsl:param name="text" select="code/@desc"/>
        <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>