View stylesheet

XML schema http://water.eionet.europa.eu/schemas/dir91271eec/UWWTD2011.xsd
Output type RDF
Description RDF
XSL file UWWTD2011-rdf.xsl (Last modified: 23 Aug 2013 11:49 )
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [
    <!ENTITY nuts "http://rdfdata.eionet.europa.eu/ramon/nuts/">
    <!ENTITY uwwtref "http://reference.eionet.europa.eu/uwwtd/">
    <!ENTITY uwwtns "http://rdfdata.eionet.europa.eu/uwwtd/ontology/">
    <!ENTITY xsd  "http://www.w3.org/2001/XMLSchema#" >
]>
<xsl:stylesheet 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:xsd="http://www.w3.org/2001/XMLSchema#"
        xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
        xmlns="http://rdfdata.eionet.europa.eu/uwwtd/ontology/"
        version="1.0">
    <!-- $Id: UWWTD2009-rdf.xsl 14668 2013-08-23 09:48:25Z roug $
         For http://water.eionet.europa.eu/schemas/dir91271eec/UWWTD2009.xsd
         and http://water.eionet.europa.eu/schemas/dir91271eec/UWWTD2011.xsd
      -->

    <!--
    <xsl:key name="uwwlist" match="UWWTP" use="uwwCode" />
    <xsl:key name="agglist" match="Agglomeration" use="aggCode" />
    <xsl:key name="rcalist" match="ReceivingArea" use="rcaCode" />
    <xsl:key name="dcplist" match="DischargePoint" use="dcpCode" />
    -->

    <xsl:output method="xml" indent="yes"/>

    <xsl:strip-space elements="aggCode rcaCode bigCityID dcpCode uwwCode indCodePlant aucUwwCode uwwID aucAggCode aggNUTS uwwNUTS dcpNUTS"/>

    <xsl:template match="UWWTD_Data">
        <rdf:RDF>
        <xsl:apply-templates/>
        </rdf:RDF>
    </xsl:template>

    <xsl:template match="UWWTD_Report">
        <rdf:Description rdf:about="">
        <xsl:apply-templates select="Reporter"/>
        <xsl:apply-templates select="ReportPeriod"/>
        <xsl:apply-templates select="MSLevel"/>
        </rdf:Description>
        <xsl:apply-templates select="Contacts"     mode="types"/>
        <xsl:apply-templates select="ReceivingAreas"     mode="types"/>
        <xsl:apply-templates select="Agglomerations"     mode="types"/>
        <xsl:apply-templates select="BigCityDischargers" mode="types"/>
        <xsl:apply-templates select="UWWTPs"             mode="types"/>
        <xsl:apply-templates select="UwwtpAgglos"        mode="types"/>
        <xsl:apply-templates select="DischargePoints"    mode="types"/>
        <xsl:apply-templates select="Industries"         mode="types"/>
    </xsl:template>


    <xsl:template match="*" mode="types">
        <xsl:apply-templates select="*"/>
    </xsl:template>

    <xsl:template match="Reporter|ReportPeriod|MSLevel">
        <xsl:apply-templates select="*" mode="property"/>
    </xsl:template>

    <xsl:template match="Contact">
        <xsl:element name="{local-name()}" namespace="&uwwtns;">
            <xsl:attribute name="rdf:ID"><xsl:value-of select="generate-id()"/></xsl:attribute>
            <xsl:apply-templates select="*" mode="property"/>
        </xsl:element>
    </xsl:template>

    <xsl:template match="ReceivingArea">
        <xsl:element name="{local-name()}" namespace="&uwwtns;">
            <xsl:attribute name="rdf:about">#R-<xsl:value-of select="rcaCode"/></xsl:attribute>
            <xsl:element name="declarationFor" namespace="&uwwtns;">
                <xsl:attribute name="rdf:resource">&uwwtref;ReceivingAreas/<xsl:value-of select="rcaCode"/></xsl:attribute>
            </xsl:element>
            <xsl:apply-templates select="*" mode="property"/>
        </xsl:element>
    </xsl:template>

    <xsl:template match="Agglomeration">
        <xsl:element name="{local-name()}" namespace="&uwwtns;">
            <xsl:attribute name="rdf:about">#A-<xsl:value-of select="aggCode"/></xsl:attribute>
            <rdf:type rdf:resource="http://www.w3.org/2003/01/geo/wgs84_pos#SpatialThing"/>
            <xsl:element name="declarationFor" namespace="&uwwtns;">
                <xsl:attribute name="rdf:resource">&uwwtref;Agglomerations/<xsl:value-of select="aggCode"/></xsl:attribute>
            </xsl:element>
        <xsl:apply-templates select="*" mode="property"/>
        </xsl:element>
    </xsl:template>

    <xsl:template match="BigCityDischarger">
        <xsl:element name="{local-name()}" namespace="&uwwtns;">
            <xsl:attribute name="rdf:about">#B-<xsl:value-of select="bigCityID"/></xsl:attribute>
            <xsl:element name="declarationFor" namespace="&uwwtns;">
                <xsl:attribute name="rdf:resource">&uwwtref;BigCityDischargers/<xsl:value-of select="bigCityID"/></xsl:attribute>
            </xsl:element>
            <xsl:apply-templates select="*" mode="property"/>
        </xsl:element>
    </xsl:template>

    <xsl:template match="UWWTP">
        <xsl:element name="{local-name()}" namespace="&uwwtns;">
            <xsl:attribute name="rdf:about">#U-<xsl:value-of select="uwwCode"/></xsl:attribute>
            <rdf:type rdf:resource="http://www.w3.org/2003/01/geo/wgs84_pos#SpatialThing"/>
            <xsl:element name="declarationFor" namespace="&uwwtns;">
                <xsl:attribute name="rdf:resource">&uwwtref;UWWTPs/<xsl:value-of select="uwwCode"/></xsl:attribute>
            </xsl:element>
            <xsl:apply-templates select="*" mode="property"/>
        </xsl:element>
    </xsl:template>

    <xsl:template match="UwwtpAgglo">
        <xsl:element name="{local-name()}" namespace="&uwwtns;">
            <xsl:attribute name="rdf:about">#<xsl:value-of select="aucUwwCode"/>,<xsl:value-of select="aucAggCode"/></xsl:attribute>
            <xsl:element name="declarationFor" namespace="&uwwtns;">
                <xsl:attribute name="rdf:resource">&uwwtref;UwwtpAgglos/<xsl:value-of select="aucUwwCode"/>,<xsl:value-of select="aucAggCode"/></xsl:attribute>
            </xsl:element>
            <xsl:apply-templates select="*" mode="property"/>
        </xsl:element>
    </xsl:template>

    <xsl:template match="DischargePoint">
        <xsl:element name="{local-name()}" namespace="&uwwtns;">
            <xsl:attribute name="rdf:about">#D-<xsl:value-of select="dcpCode"/></xsl:attribute>
            <rdf:type rdf:resource="http://www.w3.org/2003/01/geo/wgs84_pos#SpatialThing"/>
            <xsl:element name="declarationFor" namespace="&uwwtns;">
                <xsl:attribute name="rdf:resource">&uwwtref;DischargePoints/<xsl:value-of select="dcpCode"/></xsl:attribute>
            </xsl:element>
            <xsl:apply-templates select="*" mode="property"/>
        </xsl:element>
    </xsl:template>

    <xsl:template match="Industry">
        <xsl:element name="{local-name()}" namespace="&uwwtns;">
            <xsl:attribute name="rdf:about">#I-<xsl:value-of select="indCodePlant"/></xsl:attribute>
            <xsl:element name="declarationFor" namespace="&uwwtns;">
                <xsl:attribute name="rdf:resource">&uwwtref;Industries/<xsl:value-of select="indCodePlant"/></xsl:attribute>
            </xsl:element>
            <xsl:apply-templates select="*" mode="property"/>
        </xsl:element>
    </xsl:template>

    <xsl:template match="uwwID|aucUwwCode" mode="property">
        <xsl:element name="{local-name()}" namespace="&uwwtns;"><xsl:value-of select="text()"/></xsl:element>
        <xsl:element name="for{local-name()}" namespace="&uwwtns;">
            <xsl:attribute name="rdf:resource">#U-<xsl:value-of select="text()"/></xsl:attribute>
        </xsl:element>
    </xsl:template>

    <xsl:template match="aggID|aucAggCode" mode="property">
        <xsl:element name="{local-name()}" namespace="&uwwtns;"><xsl:value-of select="text()"/></xsl:element>
        <xsl:element name="for{local-name()}" namespace="&uwwtns;">
            <xsl:attribute name="rdf:resource">#A-<xsl:value-of select="text()"/></xsl:attribute>
        </xsl:element>
    </xsl:template>

    <xsl:template match="rcaID|rcaSensitiveArea" mode="property">
        <xsl:element name="{local-name()}" namespace="&uwwtns;"><xsl:value-of select="text()"/></xsl:element>
        <xsl:element name="for{local-name()}" namespace="&uwwtns;">
            <xsl:attribute name="rdf:resource">#R-<xsl:value-of select="text()"/></xsl:attribute>
        </xsl:element>
    </xsl:template>

    <xsl:template match="aggNUTS|uwwNUTS|dcpNUTS" mode="property">
        <xsl:element name="hasNUTS" namespace="&uwwtns;">
            <xsl:attribute name="rdf:resource">&nuts;<xsl:value-of select="normalize-space(text())"/></xsl:attribute>
        </xsl:element>
        <xsl:element name="{local-name()}" namespace="&uwwtns;">
            <xsl:value-of select="normalize-space(text())"/>
        </xsl:element>
    </xsl:template>

    <!-- Elements containing true/false -->
    <xsl:template match="aggAccOverflows|aggCapacity|aggDilutionRates|aggOtherMeasures|aggPressureTest|aggVideoInspections|
            mslWWReuseAgri|mslWWReuseInd|mslWWReuseOther|
            rcaAbsenceRisk|rcaANitro|rcaAPhos|rcaArt54Applied|rcaB|rcaC|rcaHydraulic|
            rcaHydrologie|rcaMorphology|rcaParameterN|rcaParameterOther|rcaParameterP|
            uwwAccidents|uwwBadDesign|uwwBadPerformance|uwwChlorination|uwwMicroFiltration|uwwNRemoval|uwwOther|uwwOtherTreatment|
            uwwOzonation|uwwPRemoval|uwwPrimaryTreatment|uwwSandFiltration|uwwSecondaryTreatment|uwwUV" mode="property">
        <xsl:element name="{local-name()}" namespace="&uwwtns;">
            <xsl:if test="contains('|true|false|1|0|', normalize-space(text()))">
                <xsl:attribute name="rdf:datatype">&xsd;boolean</xsl:attribute>
            </xsl:if>
             <xsl:value-of select="text()"/>
        </xsl:element>
    </xsl:template>

    <!-- Elements containing numbers -->
    <xsl:template match="aucPercEnteringUWWTP|aggPercWithoutTreatment|
            mslSludgeProduction|mslReuseSoilAgriculture|mslReuseOthers|mslDisposalLandfill|mslDisposalIncineration|mslDisposalOthers|
            rcaPlants|rcaPlantsCapacity|rcaNIncomingMeasured|rcaPIncomingMeasured|rcaNDischargedMeasured|rcaPDischargedMeasured|
            uwwLoadEnteringUWWTP|uwwCapacity" mode="property">
        <xsl:element name="{local-name()}" namespace="&uwwtns;">
            <xsl:if test="number(text()) = text()">
                <xsl:attribute name="rdf:datatype">&xsd;decimal</xsl:attribute>
            </xsl:if>
             <xsl:value-of select="normalize-space(text())"/>
        </xsl:element>
    </xsl:template>

    <xsl:template match="aggLatitude|uwwLatitude|dcpLatitude" mode="property">
        <xsl:element name="geo:lat">
            <xsl:attribute name="rdf:datatype">&xsd;decimal</xsl:attribute>
            <xsl:value-of select="normalize-space(text())"/>
        </xsl:element>
    </xsl:template>

    <xsl:template match="aggLongitude|uwwLongitude|dcpLongitude" mode="property">
        <xsl:element name="geo:long">
            <xsl:attribute name="rdf:datatype">&xsd;decimal</xsl:attribute>
            <xsl:value-of select="normalize-space(text())"/>
        </xsl:element>
    </xsl:template>

    <xsl:template match="uwwName|aggName|rcaName|dcpName" mode="property">
        <xsl:element name="{local-name()}" namespace="&uwwtns;"><xsl:value-of select="text()"/></xsl:element>
        <xsl:element name="rdfs:label"><xsl:value-of select="text()"/></xsl:element>
    </xsl:template>

    <xsl:template match="*" mode="property">
        <xsl:element name="{local-name()}" namespace="&uwwtns;"><xsl:value-of select="text()"/></xsl:element>
    </xsl:template>

</xsl:stylesheet>