View stylesheet

XML schemas http://www.eionet.europa.eu/schemas/eprtr/PollutantReleaseAndTransferReport_2p0.xsd
Output type RDF
Description RDF for Content Registry
XSL file eprtr-to-rdf.xsl (Last modified: 13 Mar 2015 16:38 )
<?xml version="1.0"?>
<!DOCTYPE xsl:stylesheet [
 <!ENTITY biogeo "http://rdfdata.eionet.europa.eu/eea/biogeographic-regions/">
 <!ENTITY countries "http://rdfdata.eionet.europa.eu/ramon/nuts/">
 <!ENTITY facilityreports "http://prtr.ec.europa.eu/rdf/facilityreport/">
 <!ENTITY eprtr "http://prtr.ec.europa.eu/rdf/">
 <!ENTITY nace2 "http://rdfdata.eionet.europa.eu/ramon/nace_r2/">
]>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:rsm="urn:eu:com:env:prtr:data:standard:2"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
    xmlns:dcterms="http://purl.org/dc/terms/"
    xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
    version="1.0">

<!--
     For the schema http://www.eionet.europa.eu/schemas/eprtr/PollutantReleaseAndTransferReport_2p0.xsd
     $Id: eprtr-to-rdf.xsl 12333 2012-07-19 08:49:39Z roug $
  -->
<xsl:output method="xml" indent="yes" />

<xsl:template match="rsm:PollutantReleaseAndTransferReport">
<rdf:RDF xmlns="http://rdfdata.eionet.europa.eu/eprtr/dataflow/">
 <rdf:Description rdf:about="">
     <xsl:apply-templates select="rsm:CoordinateSystemID" mode="predicates"/>
     <xsl:apply-templates select="rsm:CountryID" mode="predicates"/>
     <xsl:apply-templates select="rsm:ReportingYear" mode="predicates"/>
     <xsl:apply-templates select="rsm:CompetentAuthorityParty" mode="predicates"/>
 </rdf:Description>
     <xsl:apply-templates select="rsm:FacilityReport" mode="resource"/>
</rdf:RDF>
</xsl:template>


<xsl:template match="rsm:FacilityReport" mode="resource"  xmlns="http://rdfdata.eionet.europa.eu/eprtr/dataflow/">
  <xsl:element name="{local-name()}" namespace="http://rdfdata.eionet.europa.eu/eprtr/dataflow/">
   <xsl:attribute name="rdf:ID"><xsl:value-of select="generate-id()"/></xsl:attribute>
   <publishedReport>
    <xsl:attribute name="rdf:resource">&facilityreports;<xsl:value-of select="/rsm:PollutantReleaseAndTransferReport/rsm:CountryID"/><xsl:value-of select="rsm:NationalID"/>Y<xsl:value-of select="/rsm:PollutantReleaseAndTransferReport/rsm:ReportingYear"/></xsl:attribute>
   </publishedReport>
   <xsl:apply-templates mode="predicates"/>
  </xsl:element>
</xsl:template>

<xsl:template match="rsm:Activity" mode="predicates" xmlns="http://rdfdata.eionet.europa.eu/eprtr/dataflow/">
 <Activity rdf:parseType="Resource">
   <ActivityCodes><xsl:value-of select="@code"/></ActivityCodes>
   <xsl:apply-templates mode="predicates"/>
 </Activity>
</xsl:template>

<xsl:template match="rsm:WasteHandlerParty|
       rsm:Address|rsm:SiteAddress|
       rsm:CompetentAuthorityParty|rsm:WasteTransfer|rsm:PollutantRelease|
       rsm:PollutantTransfer|rsm:MethodUsed|rsm:PreviousNationalID|rsm:ProductionVolume|rsm:WebsiteCommunication"
          mode="predicates" xmlns="http://rdfdata.eionet.europa.eu/eprtr/dataflow/">
 <xsl:element name="{local-name()}" namespace="http://rdfdata.eionet.europa.eu/eprtr/dataflow/">
 <xsl:attribute name="rdf:parseType">Resource</xsl:attribute>
   <xsl:apply-templates mode="predicates"/>
 </xsl:element>
</xsl:template>

<!-- Drop redundant structure -->
<xsl:template match="rsm:GeographicalCoordinate" mode="predicates" xmlns="http://rdfdata.eionet.europa.eu/eprtr/dataflow/">
   <xsl:apply-templates mode="predicates"/>
</xsl:template>

<xsl:template match="rsm:AccidentalQuantity|rsm:Quantity|rsm:TotalQuantity" mode="predicates" xmlns="http://rdfdata.eionet.europa.eu/eprtr/dataflow/">
 <xsl:element name="{local-name()}" namespace="http://rdfdata.eionet.europa.eu/eprtr/dataflow/">
 <xsl:attribute name="rdf:parseType">Resource</xsl:attribute>
  <rdf:value><xsl:value-of select="."/></rdf:value>
  <unitCode><xsl:value-of select="@unitCode"/></unitCode>
 </xsl:element>
</xsl:template>

<!-- Links to reference data
     See https://svn.eionet.europa.eu/projects/Reportnet/wiki/CodePrefixes
 -->
<xsl:template match="rsm:NutsRegionID" mode="predicates">
 <xsl:element name="{local-name()}" namespace="http://rdfdata.eionet.europa.eu/eprtr/dataflow/">
  <xsl:value-of select="."/>
 </xsl:element>
 <xsl:element name="forNUTS" namespace="http://rdfdata.eionet.europa.eu/eprtr/dataflow/">
  <xsl:attribute name="rdf:resource">http://rdfdata.eionet.europa.eu/ramon/nuts/<xsl:value-of select="."/></xsl:attribute>
 </xsl:element>
</xsl:template>

<xsl:template match="rsm:AnnexIActivityCode" mode="predicates">
 <xsl:element name="annexIActivityCode" namespace="http://rdfdata.eionet.europa.eu/eprtr/dataflow/">
  <xsl:attribute name="rdf:resource">&eprtr;annexIActivity/<xsl:value-of select="."/></xsl:attribute>
 </xsl:element>
</xsl:template>

<xsl:template match="rsm:MediumCode" mode="predicates">
 <xsl:element name="mediumCode" namespace="http://rdfdata.eionet.europa.eu/eprtr/dataflow/">
  <xsl:attribute name="rdf:resource">&eprtr;medium/<xsl:value-of select="."/></xsl:attribute>
 </xsl:element>
</xsl:template>

<xsl:template match="rsm:MethodBasisCode" mode="predicates">
 <xsl:element name="methodBasisCode" namespace="http://rdfdata.eionet.europa.eu/eprtr/dataflow/">
  <xsl:attribute name="rdf:resource">&eprtr;methodBasis/<xsl:value-of select="."/></xsl:attribute>
 </xsl:element>
</xsl:template>

<xsl:template match="rsm:NACEMainEconomicActivityCode" mode="predicates">
 <xsl:element name="{local-name()}" namespace="http://rdfdata.eionet.europa.eu/eprtr/dataflow/">
  <xsl:value-of select="."/>
 </xsl:element>
 <xsl:element name="forNACE" namespace="http://rdfdata.eionet.europa.eu/eprtr/dataflow/">
  <xsl:attribute name="rdf:resource">&nace2;<xsl:value-of select="."/></xsl:attribute>
 </xsl:element>
</xsl:template>

<xsl:template match="rsm:RiverBasinDistrictID" mode="predicates">
 <xsl:element name="{local-name()}" namespace="http://rdfdata.eionet.europa.eu/eprtr/dataflow/">
  <xsl:value-of select="."/>
 </xsl:element>
 <xsl:element name="forRBD" namespace="http://rdfdata.eionet.europa.eu/eprtr/dataflow/">
  <xsl:attribute name="rdf:resource">http://rdfdata.eionet.europa.eu/wise/rbd/<xsl:value-of select="."/></xsl:attribute>
 </xsl:element>
</xsl:template>

<xsl:template match="rsm:LatitudeMeasure" mode="predicates">
 <xsl:element name="geo:lat">
  <xsl:attribute name="rdf:datatype">http://www.w3.org/2001/XMLSchema#double</xsl:attribute>
  <xsl:value-of select="."/>
 </xsl:element>
 <xsl:element name="rdf:type">
  <xsl:attribute name="rdf:resource">http://www.w3.org/2003/01/geo/wgs84_pos#SpatialThing</xsl:attribute>
 </xsl:element>
</xsl:template>

<xsl:template match="rsm:LongitudeMeasure" mode="predicates">
 <xsl:element name="geo:long">
  <xsl:attribute name="rdf:datatype">http://www.w3.org/2001/XMLSchema#double</xsl:attribute>
  <xsl:value-of select="."/>
 </xsl:element>
</xsl:template>

<xsl:template match="*" mode="predicates">
 <xsl:element name="{local-name()}" namespace="http://rdfdata.eionet.europa.eu/eprtr/dataflow/">
  <xsl:value-of select="normalize-space(.)"/>
 </xsl:element>
</xsl:template>

</xsl:stylesheet>