View stylesheet

XML schema http://water.eionet.europa.eu/schemas/dir200856ec/GES_1p0.xsd
Output type RDF
Description
XSL file GES_1p0-rdf.xslt (Last modified: 04 Jul 2012 13:03 )
<?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/eea/countries/">
]>
 <xsl:stylesheet version="1.0" xmlns="http://rdfdata.eionet.europa.eu/msfd/ontology/" xmlns:ms="http://water.eionet.europa.eu/schemas/dir200856ec/mscommon"
    xmlns:n1="http://water.eionet.europa.eu/schemas/dir200856ec" xmlns:dc="http://purl.org/dc/elements/1.1/" 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:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xdt="http://www.w3.org/2005/xpath-datatypes" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="ms n1 xs xsi">
    <xsl:output method="xml" indent="yes" encoding="UTF-8"/>
    <xsl:variable name="lcletters">
        abcdefghijklmnopqrstuvwxyz
    </xsl:variable>
    <xsl:variable name="ucletters">
        ABCDEFGHIJKLMNOPQRSTUVWXYZ
    </xsl:variable>
    <xsl:template match="n1:GES">
        <rdf:RDF>
            <rdf:Description rdf:about="">
                <rdfs:label>
                   		Reporting requirement for  the  determination of good environmental status of the marine environment., art 9, Marine Strategy Framework Directive for for <xsl:value-of select="Country"/>, <xsl:value-of select="Region"/>
                </rdfs:label>
                <forCountry>
                    <xsl:attribute name="rdf:resource">&amp;countries;<xsl:value-of select="Country"/></xsl:attribute>
                </forCountry>
                <!-- TODO replace with code/resource from http://rdfdata.eionet.europa.eu/eea/biogeographic-regions/ ? -->
                <BioGeoRegion>
                    <xsl:value-of select="Region"/>
                </BioGeoRegion>
                <DescriptionApproach>
                    <xsl:value-of select="DescriptionApproach"/>
                </DescriptionApproach>
                <dc:Language>
                    <xsl:value-of select="@Language"/>
                </dc:Language>
                <Email>
                    <xsl:value-of select="@Email"/>
                </Email>
                <dc:Created>
                    <xsl:value-of select="@CreationDate"/>
                </dc:Created>
                <Contact>
                    <xsl:value-of select="@Contact"/>
                </Contact>
                <dc:Description>
                    <xsl:value-of select="@Description"/>
                </dc:Description>
                <dc:Creator>
                    <xsl:value-of select="@Creator"/>
                </dc:Creator>
                <GeneratedBy>
                    <xsl:value-of select="@GeneratedBy"/>
                </GeneratedBy>
                <!-- find more DC matches? -->
            </rdf:Description>
            <xsl:apply-templates select="n1:Descriptors"/>
        </rdf:RDF>
    </xsl:template>

    <xsl:template match="n1:Descriptors">
        <xsl:element name="{concat(local-name(),'Declaration')}">
            <xsl:attribute name="rdf:ID"><xsl:value-of select="generate-id()"/></xsl:attribute>
        <xsl:apply-templates mode="predicates"/>
        </xsl:element>
    </xsl:template>
    <xsl:template match="n1:DesriptorCriterionIndicator" mode="predicates">
    <xsl:element name="desriptorCriterionIndicator"><xsl:value-of select="."/></xsl:element>
        <xsl:element name="rdfs:label"><xsl:value-of select="."/></xsl:element>
    </xsl:template>
    <xsl:template match="*" mode="predicates">
        <xsl:choose>
            <xsl:when test="count(child::*)=0">
                <xsl:element name="{concat(translate(substring(local-name(),1,1),$ucletters,$lcletters),substring(local-name(),2))}">
                    <xsl:value-of select="."/>
                </xsl:element>
            </xsl:when>
            <xsl:when test="count(child::*)=1">
                      <xsl:apply-templates mode="predicates"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:element name="{concat(translate(substring(local-name(),1,1),$ucletters,$lcletters),substring(local-name(),2))}">
                    <xsl:element name="rdf:Description">
                        <!--xsl:attribute name="rdf:id"><xsl:value-of select="generate-id()"/></xsl:attribute -->
                        <xsl:apply-templates mode="predicates"/>
                    </xsl:element>
                </xsl:element>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    <xsl:template match="*" mode="ignore"/>
</xsl:stylesheet>