Skip to content

Instantly share code, notes, and snippets.

@kalxas
Last active November 4, 2021 17:25
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kalxas/e86d845f02b99067c129 to your computer and use it in GitHub Desktop.
Save kalxas/e86d845f02b99067c129 to your computer and use it in GitHub Desktop.
INSPIRE validation

Inspire Validation using OWSLib

Installation steps

  1. Create virtualenv:

    $ virtualenv owslib_test

    $ cd owslib_test

    $ . ./bin/activate

  2. Clone modified OWSLib:

    $ mkdir src

    $ cd src

    $ git clone https://github.com/geopython/OWSLib.git owslib

    $ cd owslib

    $ python setup.py build

    $ python setup.py install

    $ cd ..

  3. Install lxml

    $ pip install lxml

    $ pip install jinja2

  4. Clone gist:

    $ git clone https://gist.github.com/e86d845f02b99067c129.git inspire_validator

    $ cd inspire_validator

    $ python inspire.py

<?xml version="1.0" encoding="UTF-8"?>
<gmd:MD_Metadata xsi:schemaLocation="http://www.isotc211.org/2005/gmd http://schemas.opengis.net/iso/19139/20060504/gmd/gmd.xsd" xmlns:gmd="http://www.isotc211.org/2005/gmd" xmlns:gco="http://www.isotc211.org/2005/gco" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:gml="http://www.opengis.net/gml" xmlns:xlink="http://www.w3.org/1999/xlink">
<gmd:fileIdentifier><gco:CharacterString>6b1d06b6-b1d3-4ba2-8e62-c5c410ed502a</gco:CharacterString></gmd:fileIdentifier><gmd:language><gmd:LanguageCode codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#LanguageCode" codeListValue="gre">gre</gmd:LanguageCode></gmd:language><gmd:hierarchyLevel>
<gmd:MD_ScopeCode codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#MD_ScopeCode" codeListValue="dataset">dataset</gmd:MD_ScopeCode>
</gmd:hierarchyLevel>
<gmd:contact><gmd:CI_ResponsibleParty><gmd:organisationName><gco:CharacterString>Κέντρο Ανανεώσιμων Πηγών και Εξοικονόμησης Ενέργειας</gco:CharacterString></gmd:organisationName><gmd:contactInfo><gmd:CI_Contact><gmd:address><gmd:CI_Address><gmd:electronicMailAddress><gco:CharacterString>info@geodata.gov.gr</gco:CharacterString></gmd:electronicMailAddress></gmd:CI_Address></gmd:address></gmd:CI_Contact></gmd:contactInfo><gmd:role><gmd:CI_RoleCode codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#CI_RoleCode" codeListValue="pointOfContact">pointOfContact</gmd:CI_RoleCode></gmd:role></gmd:CI_ResponsibleParty></gmd:contact><gmd:dateStamp>
<gco:Date>2010-09-14</gco:Date>
</gmd:dateStamp>
<gmd:metadataStandardName>
<gco:CharacterString>ISO19115</gco:CharacterString>
</gmd:metadataStandardName>
<gmd:metadataStandardVersion>
<gco:CharacterString>2003/Cor.1:2006</gco:CharacterString>
</gmd:metadataStandardVersion>
<gmd:identificationInfo>
<gmd:MD_DataIdentification>
<gmd:citation>
<gmd:CI_Citation>
<gmd:title>
<gco:CharacterString>Αιολικός χάρτης της Ελλάδας</gco:CharacterString>
</gmd:title>
<gmd:date><gmd:CI_Date><gmd:date><gco:Date>2001-07-31</gco:Date></gmd:date><gmd:dateType><gmd:CI_DateTypeCode codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#CI_DateTypeCode" codeListValue="creation">creation</gmd:CI_DateTypeCode></gmd:dateType></gmd:CI_Date></gmd:date><gmd:date><gmd:CI_Date><gmd:date><gco:Date>2010-09-14</gco:Date></gmd:date><gmd:dateType><gmd:CI_DateTypeCode codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#CI_DateTypeCode" codeListValue="publication">publication</gmd:CI_DateTypeCode></gmd:dateType></gmd:CI_Date></gmd:date><gmd:date><gmd:CI_Date><gmd:date><gco:Date>2001-07-31</gco:Date></gmd:date><gmd:dateType><gmd:CI_DateTypeCode codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#CI_DateTypeCode" codeListValue="revision">revision</gmd:CI_DateTypeCode></gmd:dateType></gmd:CI_Date></gmd:date><gmd:identifier><gmd:RS_Identifier><gmd:code><gco:CharacterString>UID</gco:CharacterString></gmd:code><gmd:codeSpace><gco:CharacterString>http://geodata.gov.gr</gco:CharacterString></gmd:codeSpace></gmd:RS_Identifier></gmd:identifier></gmd:CI_Citation>
</gmd:citation>
<gmd:abstract>
<gco:CharacterString>Ο αιολικός χάρτης περιλαμβάνει το αιολικό δυναμικό του Ελληνικού χώρου (πλην Κρήτης και μέρρους των νομών Καβάλας και Ξάνθης) σε κάνναβο 150 x 150 m, όπως αυτό υπολογίστηκε από το ΚΑΠΕ με βάση ένα ευρύ πρόγραμμα επί τόπου μετρήσεων και εφαρμογή μαθηματικών μοντέλων. Ο χάρτης εκφράζει το αιολικό δυναμικό με βάση την μέση ετήσια ταχύτητα του αέρα σε μέτρα το δευτερόλεπτο, σε υπολογισμένο ύψος 40 μέτρων. 1η έκδοση Ιούνιος 2001.
Πληροφοριακά πεδία χάρτη:
WV: Μέση ετήσια ταχύτητα ανέμου στα 40m από την επιφάνεια του εδάφους.
Επικοινωνία: geodata@cres.gr</gco:CharacterString>
</gmd:abstract>
<gmd:pointOfContact><gmd:CI_ResponsibleParty><gmd:organisationName><gco:CharacterString>Κέντρο Ανανεώσιμων Πηγών και Εξοικονόμησης Ενέργειας</gco:CharacterString></gmd:organisationName><gmd:contactInfo><gmd:CI_Contact><gmd:address><gmd:CI_Address><gmd:electronicMailAddress><gco:CharacterString>geodata@cres.gr</gco:CharacterString></gmd:electronicMailAddress></gmd:CI_Address></gmd:address></gmd:CI_Contact></gmd:contactInfo><gmd:role><gmd:CI_RoleCode codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#CI_RoleCode" codeListValue="resourceProvider">resourceProvider</gmd:CI_RoleCode></gmd:role></gmd:CI_ResponsibleParty></gmd:pointOfContact><gmd:descriptiveKeywords><gmd:MD_Keywords><gmd:keyword><gco:CharacterString>Atmospheric conditions</gco:CharacterString></gmd:keyword><gmd:keyword><gco:CharacterString>Meteorological geographical features</gco:CharacterString></gmd:keyword><gmd:thesaurusName><gmd:CI_Citation><gmd:title><gco:CharacterString>GEMET - INSPIRE themes, version 1.0</gco:CharacterString></gmd:title><gmd:date><gmd:CI_Date><gmd:date><gco:Date>2008-06-01</gco:Date></gmd:date><gmd:dateType><gmd:CI_DateTypeCode codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#CI_DateTypeCode" codeListValue="publication">publication</gmd:CI_DateTypeCode></gmd:dateType></gmd:CI_Date></gmd:date></gmd:CI_Citation></gmd:thesaurusName></gmd:MD_Keywords></gmd:descriptiveKeywords><gmd:descriptiveKeywords><gmd:MD_Keywords><gmd:keyword><gco:CharacterString>αιολικό δυναμικό</gco:CharacterString></gmd:keyword><gmd:keyword><gco:CharacterString>άνεμος</gco:CharacterString></gmd:keyword><gmd:keyword><gco:CharacterString>ταχύτητα ανέμου</gco:CharacterString></gmd:keyword><gmd:keyword><gco:CharacterString>ελλαδικός χώρος</gco:CharacterString></gmd:keyword><gmd:keyword><gco:CharacterString>ΚΑΠΕ</gco:CharacterString></gmd:keyword></gmd:MD_Keywords></gmd:descriptiveKeywords><gmd:resourceConstraints><gmd:MD_Constraints><gmd:useLimitation><gco:CharacterString>no conditions apply</gco:CharacterString></gmd:useLimitation></gmd:MD_Constraints></gmd:resourceConstraints><gmd:resourceConstraints><gmd:MD_LegalConstraints><gmd:accessConstraints><gmd:MD_RestrictionCode codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#MD_RestrictionCode" codeListValue="otherRestrictions">otherRestrictions</gmd:MD_RestrictionCode></gmd:accessConstraints><gmd:otherConstraints><gco:CharacterString>no limitations</gco:CharacterString></gmd:otherConstraints></gmd:MD_LegalConstraints></gmd:resourceConstraints><gmd:language><gmd:LanguageCode codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#LanguageCode" codeListValue="gre">gre</gmd:LanguageCode></gmd:language><gmd:language><gmd:LanguageCode codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#LanguageCode" codeListValue="eng">eng</gmd:LanguageCode></gmd:language><gmd:topicCategory><gmd:MD_TopicCategoryCode>climatologyMeteorologyAtmosphere</gmd:MD_TopicCategoryCode></gmd:topicCategory><gmd:extent><gmd:EX_Extent><gmd:geographicElement><gmd:EX_GeographicBoundingBox><gmd:westBoundLongitude><gco:Decimal>16.76871</gco:Decimal></gmd:westBoundLongitude><gmd:eastBoundLongitude><gco:Decimal>30.655429</gco:Decimal></gmd:eastBoundLongitude><gmd:southBoundLatitude><gco:Decimal>33.188516</gco:Decimal></gmd:southBoundLatitude><gmd:northBoundLatitude><gco:Decimal>43.339883</gco:Decimal></gmd:northBoundLatitude></gmd:EX_GeographicBoundingBox></gmd:geographicElement></gmd:EX_Extent></gmd:extent></gmd:MD_DataIdentification>
</gmd:identificationInfo>
<gmd:distributionInfo><gmd:MD_Distribution><gmd:distributionFormat><gmd:MD_Format><gmd:name gco:nilReason="inapplicable"/><gmd:version gco:nilReason="inapplicable"/></gmd:MD_Format></gmd:distributionFormat><gmd:transferOptions><gmd:MD_DigitalTransferOptions><gmd:onLine><gmd:CI_OnlineResource><gmd:linkage><gmd:URL>http://geodata.gov.gr</gmd:URL></gmd:linkage></gmd:CI_OnlineResource></gmd:onLine></gmd:MD_DigitalTransferOptions></gmd:transferOptions></gmd:MD_Distribution></gmd:distributionInfo><gmd:dataQualityInfo><gmd:DQ_DataQuality><gmd:scope><gmd:DQ_Scope><gmd:level><gmd:MD_ScopeCode codeListValue="dataset" codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#MD_ScopeCode">dataset</gmd:MD_ScopeCode></gmd:level></gmd:DQ_Scope></gmd:scope><gmd:report><gmd:DQ_DomainConsistency xsi:type="gmd:DQ_DomainConsistency_Type"><gmd:measureIdentification><gmd:RS_Identifier><gmd:code><gco:CharacterString>Conformity_001</gco:CharacterString></gmd:code><gmd:codeSpace><gco:CharacterString>INSPIRE</gco:CharacterString></gmd:codeSpace></gmd:RS_Identifier></gmd:measureIdentification><gmd:result><gmd:DQ_ConformanceResult xsi:type="gmd:DQ_ConformanceResult_Type"><gmd:specification><gmd:CI_Citation><gmd:title><gco:CharacterString>INSPIRE IR on Metadata</gco:CharacterString></gmd:title><gmd:date><gmd:CI_Date><gmd:date><gco:Date>2010-09-14</gco:Date></gmd:date><gmd:dateType><gmd:CI_DateTypeCode codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#CI_DateTypeCode" codeListValue="creation">creation</gmd:CI_DateTypeCode></gmd:dateType></gmd:CI_Date></gmd:date></gmd:CI_Citation></gmd:specification><gmd:explanation><gco:CharacterString>See the referenced specification</gco:CharacterString></gmd:explanation><gmd:pass gco:nilReason="template"/></gmd:DQ_ConformanceResult></gmd:result></gmd:DQ_DomainConsistency></gmd:report><gmd:lineage><gmd:LI_Lineage><gmd:statement><gco:CharacterString>Κέντρο Ανανεώσιμων Πηγών και Εξοικονόμησης Ενέργειας</gco:CharacterString></gmd:statement></gmd:LI_Lineage></gmd:lineage></gmd:DQ_DataQuality></gmd:dataQualityInfo></gmd:MD_Metadata>
<?xml version="1.0" encoding="UTF-8"?>
<gmd:MD_Metadata xsi:schemaLocation="http://www.isotc211.org/2005/gmd http://schemas.opengis.net/iso/19139/20060504/gmd/gmd.xsd" xmlns:gmd="http://www.isotc211.org/2005/gmd" xmlns:gco="http://www.isotc211.org/2005/gco" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:gml="http://www.opengis.net/gml" xmlns:xlink="http://www.w3.org/1999/xlink">
<gmd:fileIdentifier><gco:CharacterString>d59c2895-49c0-416f-a77e-122459cc8cac</gco:CharacterString></gmd:fileIdentifier><gmd:language><gmd:LanguageCode codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#LanguageCode" codeListValue="gre">gre</gmd:LanguageCode></gmd:language><gmd:hierarchyLevel>
<gmd:MD_ScopeCode codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#MD_ScopeCode" codeListValue="dataset">dataset</gmd:MD_ScopeCode>
</gmd:hierarchyLevel>
<gmd:contact><gmd:CI_ResponsibleParty><gmd:organisationName><gco:CharacterString>Υπουργείο Προστασίας του Πολίτη</gco:CharacterString></gmd:organisationName><gmd:contactInfo><gmd:CI_Contact><gmd:address><gmd:CI_Address><gmd:electronicMailAddress><gco:CharacterString>info@geodata.gov.gr</gco:CharacterString></gmd:electronicMailAddress></gmd:CI_Address></gmd:address></gmd:CI_Contact></gmd:contactInfo><gmd:role><gmd:CI_RoleCode codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#CI_RoleCode" codeListValue="pointOfContact">pointOfContact</gmd:CI_RoleCode></gmd:role></gmd:CI_ResponsibleParty></gmd:contact><gmd:dateStamp>
<gco:Date>2010-04-21</gco:Date>
</gmd:dateStamp>
<gmd:metadataStandardName>
<gco:CharacterString>ISO19115</gco:CharacterString>
</gmd:metadataStandardName>
<gmd:metadataStandardVersion>
<gco:CharacterString>2003/Cor.1:2006</gco:CharacterString>
</gmd:metadataStandardVersion>
<gmd:identificationInfo>
<gmd:MD_DataIdentification>
<gmd:citation>
<gmd:CI_Citation>
<gmd:title>
<gco:CharacterString>Ακτογραμμή</gco:CharacterString>
</gmd:title>
<gmd:date><gmd:CI_Date><gmd:date><gco:Date>2010-04-21</gco:Date></gmd:date><gmd:dateType><gmd:CI_DateTypeCode codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#CI_DateTypeCode" codeListValue="creation">creation</gmd:CI_DateTypeCode></gmd:dateType></gmd:CI_Date></gmd:date><gmd:date><gmd:CI_Date><gmd:date><gco:Date>2010-06-01</gco:Date></gmd:date><gmd:dateType><gmd:CI_DateTypeCode codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#CI_DateTypeCode" codeListValue="publication">publication</gmd:CI_DateTypeCode></gmd:dateType></gmd:CI_Date></gmd:date><gmd:identifier><gmd:RS_Identifier><gmd:code><gco:CharacterString>UID</gco:CharacterString></gmd:code><gmd:codeSpace><gco:CharacterString>http://geo.data.gov.g</gco:CharacterString></gmd:codeSpace></gmd:RS_Identifier></gmd:identifier></gmd:CI_Citation>
</gmd:citation>
<gmd:abstract>
<gco:CharacterString>Περιλαμβάνεται η ακτογραμμή της Ελλάδας και οριοθετούνται τα σύνορά της.</gco:CharacterString>
</gmd:abstract>
<gmd:descriptiveKeywords><gmd:MD_Keywords><gmd:keyword><gco:CharacterString>Administrative units</gco:CharacterString></gmd:keyword><gmd:thesaurusName><gmd:CI_Citation><gmd:title><gco:CharacterString>GEMET - INSPIRE themes, version 1.0</gco:CharacterString></gmd:title><gmd:date><gmd:CI_Date><gmd:date><gco:Date>2008-06-01</gco:Date></gmd:date><gmd:dateType><gmd:CI_DateTypeCode codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#CI_DateTypeCode" codeListValue="publication">publication</gmd:CI_DateTypeCode></gmd:dateType></gmd:CI_Date></gmd:date></gmd:CI_Citation></gmd:thesaurusName></gmd:MD_Keywords></gmd:descriptiveKeywords><gmd:descriptiveKeywords><gmd:MD_Keywords><gmd:keyword><gco:CharacterString>ακτογραμμή</gco:CharacterString></gmd:keyword><gmd:keyword><gco:CharacterString>σύνορα</gco:CharacterString></gmd:keyword><gmd:keyword><gco:CharacterString>Ελλάδα</gco:CharacterString></gmd:keyword></gmd:MD_Keywords></gmd:descriptiveKeywords><gmd:resourceConstraints><gmd:MD_Constraints><gmd:useLimitation><gco:CharacterString>no conditions apply</gco:CharacterString></gmd:useLimitation></gmd:MD_Constraints></gmd:resourceConstraints><gmd:resourceConstraints><gmd:MD_LegalConstraints><gmd:accessConstraints><gmd:MD_RestrictionCode codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#MD_RestrictionCode" codeListValue="otherRestrictions">otherRestrictions</gmd:MD_RestrictionCode></gmd:accessConstraints><gmd:otherConstraints><gco:CharacterString>no limitations</gco:CharacterString></gmd:otherConstraints></gmd:MD_LegalConstraints></gmd:resourceConstraints><gmd:language><gmd:LanguageCode codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#LanguageCode" codeListValue="gre">gre</gmd:LanguageCode></gmd:language><gmd:language><gmd:LanguageCode codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#LanguageCode" codeListValue="eng">eng</gmd:LanguageCode></gmd:language><gmd:topicCategory><gmd:MD_TopicCategoryCode>boundaries</gmd:MD_TopicCategoryCode></gmd:topicCategory><gmd:extent><gmd:EX_Extent><gmd:geographicElement><gmd:EX_GeographicBoundingBox><gmd:westBoundLongitude><gco:Decimal>16.988437</gco:Decimal></gmd:westBoundLongitude><gmd:eastBoundLongitude><gco:Decimal>30.875156</gco:Decimal></gmd:eastBoundLongitude><gmd:southBoundLatitude><gco:Decimal>32.902872</gco:Decimal></gmd:southBoundLatitude><gmd:northBoundLatitude><gco:Decimal>43.054239</gco:Decimal></gmd:northBoundLatitude></gmd:EX_GeographicBoundingBox></gmd:geographicElement></gmd:EX_Extent></gmd:extent></gmd:MD_DataIdentification>
</gmd:identificationInfo>
<gmd:distributionInfo><gmd:MD_Distribution><gmd:distributionFormat><gmd:MD_Format><gmd:name gco:nilReason="inapplicable"/><gmd:version gco:nilReason="inapplicable"/></gmd:MD_Format></gmd:distributionFormat><gmd:transferOptions><gmd:MD_DigitalTransferOptions/></gmd:transferOptions></gmd:MD_Distribution></gmd:distributionInfo><gmd:dataQualityInfo><gmd:DQ_DataQuality><gmd:scope><gmd:DQ_Scope><gmd:level><gmd:MD_ScopeCode codeListValue="dataset" codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#MD_ScopeCode">dataset</gmd:MD_ScopeCode></gmd:level></gmd:DQ_Scope></gmd:scope><gmd:report><gmd:DQ_DomainConsistency xsi:type="gmd:DQ_DomainConsistency_Type"><gmd:measureIdentification><gmd:RS_Identifier><gmd:code><gco:CharacterString>Conformity_001</gco:CharacterString></gmd:code><gmd:codeSpace><gco:CharacterString>INSPIRE</gco:CharacterString></gmd:codeSpace></gmd:RS_Identifier></gmd:measureIdentification><gmd:result><gmd:DQ_ConformanceResult xsi:type="gmd:DQ_ConformanceResult_Type"><gmd:specification><gmd:CI_Citation><gmd:title><gco:CharacterString>INSPIRE IR for metadata</gco:CharacterString></gmd:title><gmd:date><gmd:CI_Date><gmd:date><gco:Date>2010-04-21</gco:Date></gmd:date><gmd:dateType><gmd:CI_DateTypeCode codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#CI_DateTypeCode" codeListValue="creation">creation</gmd:CI_DateTypeCode></gmd:dateType></gmd:CI_Date></gmd:date></gmd:CI_Citation></gmd:specification><gmd:explanation><gco:CharacterString>See the referenced specification</gco:CharacterString></gmd:explanation><gmd:pass gco:nilReason="template"/></gmd:DQ_ConformanceResult></gmd:result></gmd:DQ_DomainConsistency></gmd:report><gmd:lineage><gmd:LI_Lineage><gmd:statement><gco:CharacterString>ΚΤΠ Α.Ε.</gco:CharacterString></gmd:statement></gmd:LI_Lineage></gmd:lineage></gmd:DQ_DataQuality></gmd:dataQualityInfo></gmd:MD_Metadata>
<?xml version="1.0" encoding="UTF-8"?>
<gmd:MD_Metadata xsi:schemaLocation="http://www.isotc211.org/2005/gmd http://schemas.opengis.net/iso/19139/20060504/gmd/gmd.xsd" xmlns:gmd="http://www.isotc211.org/2005/gmd" xmlns:gco="http://www.isotc211.org/2005/gco" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:gml="http://www.opengis.net/gml" xmlns:xlink="http://www.w3.org/1999/xlink">
<gmd:fileIdentifier><gco:CharacterString>286c0725-146e-4533-b1bf-d6e367f6c342</gco:CharacterString></gmd:fileIdentifier>
<gmd:language><gmd:LanguageCode codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#LanguageCode" codeListValue="eng">eng</gmd:LanguageCode></gmd:language>
<gmd:hierarchyLevel><gmd:MD_ScopeCode codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#MD_ScopeCode" codeListValue="dataset">dataset</gmd:MD_ScopeCode></gmd:hierarchyLevel>
<gmd:contact><gmd:CI_ResponsibleParty><gmd:organisationName><gco:CharacterString>xouxoutos</gco:CharacterString></gmd:organisationName><gmd:contactInfo><gmd:CI_Contact><gmd:address><gmd:CI_Address><gmd:electronicMailAddress><gco:CharacterString>foufoutos@gmail.com</gco:CharacterString></gmd:electronicMailAddress><gmd:electronicMailAddress><gco:CharacterString>tsiou@gmail.com</gco:CharacterString></gmd:electronicMailAddress></gmd:CI_Address></gmd:address></gmd:CI_Contact></gmd:contactInfo><gmd:role><gmd:CI_RoleCode codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#CI_RoleCode" codeListValue="pointOfContact">pointOfContact</gmd:CI_RoleCode></gmd:role></gmd:CI_ResponsibleParty></gmd:contact>
<gmd:contact><gmd:CI_ResponsibleParty><gmd:organisationName><gco:CharacterString>momos</gco:CharacterString></gmd:organisationName><gmd:contactInfo><gmd:CI_Contact><gmd:address><gmd:CI_Address><gmd:electronicMailAddress><gco:CharacterString>kokos@gmail.com</gco:CharacterString></gmd:electronicMailAddress><gmd:electronicMailAddress><gco:CharacterString>lolos@gmail.com</gco:CharacterString></gmd:electronicMailAddress></gmd:CI_Address></gmd:address></gmd:CI_Contact></gmd:contactInfo><gmd:role><gmd:CI_RoleCode codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#CI_RoleCode" codeListValue="pointOfContact">pointOfContact</gmd:CI_RoleCode></gmd:role></gmd:CI_ResponsibleParty></gmd:contact>
<gmd:dateStamp><gco:Date>2014-05-20</gco:Date></gmd:dateStamp>
<gmd:metadataStandardName><gco:CharacterString>ISO19115</gco:CharacterString></gmd:metadataStandardName>
<gmd:metadataStandardVersion><gco:CharacterString>2003/Cor.1:2006</gco:CharacterString></gmd:metadataStandardVersion>
<gmd:identificationInfo>
<gmd:MD_DataIdentification>
<gmd:citation>
<gmd:CI_Citation>
<gmd:title><gco:CharacterString>Title bla bla</gco:CharacterString></gmd:title>
<gmd:date><gmd:CI_Date><gmd:date><gco:Date>2014-05-06</gco:Date></gmd:date><gmd:dateType><gmd:CI_DateTypeCode codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#CI_DateTypeCode" codeListValue="publication">publication</gmd:CI_DateTypeCode></gmd:dateType></gmd:CI_Date></gmd:date>
<gmd:date><gmd:CI_Date><gmd:date><gco:Date>2014-05-08</gco:Date></gmd:date><gmd:dateType><gmd:CI_DateTypeCode codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#CI_DateTypeCode" codeListValue="publication">publication</gmd:CI_DateTypeCode></gmd:dateType></gmd:CI_Date></gmd:date>
<gmd:date><gmd:CI_Date><gmd:date><gco:Date>2014-05-01</gco:Date></gmd:date><gmd:dateType><gmd:CI_DateTypeCode codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#CI_DateTypeCode" codeListValue="creation">creation</gmd:CI_DateTypeCode></gmd:dateType></gmd:CI_Date></gmd:date>
<gmd:date><gmd:CI_Date><gmd:date><gco:Date>2014-05-12</gco:Date></gmd:date><gmd:dateType><gmd:CI_DateTypeCode codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#CI_DateTypeCode" codeListValue="revision">revision</gmd:CI_DateTypeCode></gmd:dateType></gmd:CI_Date></gmd:date>
<gmd:identifier><gmd:RS_Identifier><gmd:code><gco:CharacterString>286c0725-146e-4533-b1bf-d6e367f6c342</gco:CharacterString></gmd:code></gmd:RS_Identifier></gmd:identifier>
</gmd:CI_Citation>
</gmd:citation>
<gmd:abstract><gco:CharacterString>Abstract blah blah</gco:CharacterString></gmd:abstract>
<gmd:pointOfContact><gmd:CI_ResponsibleParty><gmd:organisationName><gco:CharacterString>NTUA</gco:CharacterString></gmd:organisationName><gmd:contactInfo><gmd:CI_Contact><gmd:address><gmd:CI_Address><gmd:electronicMailAddress><gco:CharacterString>lolo2@gmail.com</gco:CharacterString></gmd:electronicMailAddress></gmd:CI_Address></gmd:address></gmd:CI_Contact></gmd:contactInfo><gmd:role><gmd:CI_RoleCode codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#CI_RoleCode" codeListValue="owner">owner</gmd:CI_RoleCode></gmd:role></gmd:CI_ResponsibleParty></gmd:pointOfContact>
<gmd:descriptiveKeywords><gmd:MD_Keywords><gmd:keyword><gco:CharacterString>Agricultural and aquaculture facilities</gco:CharacterString></gmd:keyword><gmd:keyword><gco:CharacterString>Bio-geographical regions</gco:CharacterString></gmd:keyword><gmd:thesaurusName><gmd:CI_Citation><gmd:title><gco:CharacterString>GEMET - INSPIRE themes, version 1.0</gco:CharacterString></gmd:title><gmd:date><gmd:CI_Date><gmd:date><gco:Date>2008-06-01</gco:Date></gmd:date><gmd:dateType><gmd:CI_DateTypeCode codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#CI_DateTypeCode" codeListValue="publication">publication</gmd:CI_DateTypeCode></gmd:dateType></gmd:CI_Date></gmd:date></gmd:CI_Citation></gmd:thesaurusName></gmd:MD_Keywords></gmd:descriptiveKeywords>
<gmd:descriptiveKeywords><gmd:MD_Keywords><gmd:keyword><gco:CharacterString>test</gco:CharacterString></gmd:keyword><gmd:thesaurusName><gmd:CI_Citation><gmd:title><gco:CharacterString>oeo</gco:CharacterString></gmd:title><gmd:date><gmd:CI_Date><gmd:date><gco:Date>2014-05-20</gco:Date></gmd:date><gmd:dateType><gmd:CI_DateTypeCode codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#CI_DateTypeCode" codeListValue="creation">creation</gmd:CI_DateTypeCode></gmd:dateType></gmd:CI_Date></gmd:date></gmd:CI_Citation></gmd:thesaurusName></gmd:MD_Keywords></gmd:descriptiveKeywords>
<gmd:resourceConstraints><gmd:MD_Constraints><gmd:useLimitation><gco:CharacterString>no conditions apply</gco:CharacterString></gmd:useLimitation></gmd:MD_Constraints></gmd:resourceConstraints>
<gmd:resourceConstraints><gmd:MD_LegalConstraints><gmd:accessConstraints><gmd:MD_RestrictionCode codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#MD_RestrictionCode" codeListValue="otherRestrictions">otherRestrictions</gmd:MD_RestrictionCode></gmd:accessConstraints><gmd:otherConstraints><gco:CharacterString>no limitations</gco:CharacterString></gmd:otherConstraints></gmd:MD_LegalConstraints></gmd:resourceConstraints>
<gmd:spatialResolution><gmd:MD_Resolution><gmd:equivalentScale><gmd:MD_RepresentativeFraction><gmd:denominator><gco:Integer>5000</gco:Integer></gmd:denominator></gmd:MD_RepresentativeFraction></gmd:equivalentScale></gmd:MD_Resolution></gmd:spatialResolution>
<gmd:spatialResolution><gmd:MD_Resolution><gmd:distance><gco:Distance uom="Meters">2</gco:Distance></gmd:distance></gmd:MD_Resolution></gmd:spatialResolution>
<gmd:language><gmd:LanguageCode codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#LanguageCode" codeListValue="eng">eng</gmd:LanguageCode></gmd:language>
<gmd:language><gmd:LanguageCode codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#LanguageCode" codeListValue="gre">gre</gmd:LanguageCode></gmd:language>
<gmd:topicCategory><gmd:MD_TopicCategoryCode>biota</gmd:MD_TopicCategoryCode></gmd:topicCategory>
<gmd:topicCategory><gmd:MD_TopicCategoryCode>economy</gmd:MD_TopicCategoryCode></gmd:topicCategory>
<gmd:topicCategory><gmd:MD_TopicCategoryCode>environment</gmd:MD_TopicCategoryCode></gmd:topicCategory>
<gmd:extent><gmd:EX_Extent><gmd:geographicElement><gmd:EX_GeographicBoundingBox><gmd:westBoundLongitude><gco:Decimal>23.04</gco:Decimal></gmd:westBoundLongitude><gmd:eastBoundLongitude><gco:Decimal>25.05</gco:Decimal></gmd:eastBoundLongitude><gmd:southBoundLatitude><gco:Decimal>44.03</gco:Decimal></gmd:southBoundLatitude><gmd:northBoundLatitude><gco:Decimal>45.01</gco:Decimal></gmd:northBoundLatitude></gmd:EX_GeographicBoundingBox></gmd:geographicElement></gmd:EX_Extent></gmd:extent>
<gmd:extent><gmd:EX_Extent><gmd:temporalElement><gmd:EX_TemporalExtent><gmd:extent><gml:TimePeriod gml:id="ID_05d1d6c2-111f-4dc5-b51d-551a93cfdbbc" xsi:type="gml:TimePeriodType"><gml:beginPosition>2014-05-20</gml:beginPosition><gml:endPosition>2014-05-21</gml:endPosition></gml:TimePeriod></gmd:extent></gmd:EX_TemporalExtent></gmd:temporalElement></gmd:EX_Extent></gmd:extent>
</gmd:MD_DataIdentification>
</gmd:identificationInfo>
<gmd:distributionInfo><gmd:MD_Distribution><gmd:distributionFormat><gmd:MD_Format><gmd:name gco:nilReason="inapplicable"/><gmd:version gco:nilReason="inapplicable"/></gmd:MD_Format></gmd:distributionFormat><gmd:transferOptions><gmd:MD_DigitalTransferOptions><gmd:onLine><gmd:CI_OnlineResource><gmd:linkage><gmd:URL>http://publicamundi.eu</gmd:URL></gmd:linkage></gmd:CI_OnlineResource></gmd:onLine></gmd:MD_DigitalTransferOptions></gmd:transferOptions></gmd:MD_Distribution></gmd:distributionInfo>
<gmd:dataQualityInfo><gmd:DQ_DataQuality>
<gmd:scope><gmd:DQ_Scope><gmd:level><gmd:MD_ScopeCode codeListValue="dataset" codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#MD_ScopeCode">dataset</gmd:MD_ScopeCode></gmd:level></gmd:DQ_Scope></gmd:scope>
<gmd:report><gmd:DQ_DomainConsistency xsi:type="gmd:DQ_DomainConsistency_Type"><gmd:measureIdentification><gmd:RS_Identifier><gmd:code><gco:CharacterString>Conformity_001</gco:CharacterString></gmd:code><gmd:codeSpace><gco:CharacterString>INSPIRE</gco:CharacterString></gmd:codeSpace></gmd:RS_Identifier></gmd:measureIdentification><gmd:result><gmd:DQ_ConformanceResult xsi:type="gmd:DQ_ConformanceResult_Type"><gmd:specification><gmd:CI_Citation><gmd:title><gco:CharacterString>Commission Regulation (EU) No 1089/2010 of 23 November 2010 implementing Directive 2007/2/EC of the European Parliament and of the Council as regards interoperability of spatial data sets and services</gco:CharacterString></gmd:title><gmd:date><gmd:CI_Date><gmd:date><gco:Date>2010-12-08</gco:Date></gmd:date><gmd:dateType><gmd:CI_DateTypeCode codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#CI_DateTypeCode" codeListValue="publication">publication</gmd:CI_DateTypeCode></gmd:dateType></gmd:CI_Date></gmd:date></gmd:CI_Citation></gmd:specification><gmd:explanation><gco:CharacterString>See the referenced specification</gco:CharacterString></gmd:explanation><gmd:pass><gco:Boolean>true</gco:Boolean></gmd:pass></gmd:DQ_ConformanceResult></gmd:result></gmd:DQ_DomainConsistency></gmd:report>
<gmd:lineage><gmd:LI_Lineage><gmd:statement><gco:CharacterString>history blah blah blah</gco:CharacterString></gmd:statement></gmd:LI_Lineage></gmd:lineage>
</gmd:DQ_DataQuality></gmd:dataQualityInfo>
</gmd:MD_Metadata>
from owslib.iso import *
from lxml import etree
from jinja2 import Environment, FileSystemLoader
def validate_inspire(md):
result = {}
result["status"] = "succeded"
result["errors"] = []
result["num_of_errors"] = "0"
errors = 0
if md.identification is None:
result["errors"].append("gmd:CI_ResponsibleParty: Organization missing")
result["errors"].append("gmd:CI_ResponsibleParty: E-mail missing")
result["errors"].append("gmd:CI_ResponsibleParty: Role missing")
result["errors"].append("gmd:MD_DataIdentification: Title is missing")
result["errors"].append("gmd:MD_DataIdentification: Abstract is missing")
result["errors"].append("gmd:MD_ScopeCode: Resource Type is missing")
result["errors"].append("gmd:language: Resource Language is missing")
result["errors"].append("gmd:RS_Identifier: Unique Resource Identifier is missing")
result["errors"].append("gmd:topicCategory: TopicCategory is missing")
result["errors"].append("gmd:MD_Keywords: Keywords are missing")
result["errors"].append("gmd:thesaurusName: Thesaurus Title is missing")
result["errors"].append("gmd:thesaurusName: Thesaurus Date is missing")
result["errors"].append("gmd:thesaurusName: Thesaurus Date Type is missing")
result["errors"].append("gmd:EX_Extent: extent element is missing")
result["errors"].append("gmd:EX_GeographicBoundingBox: bbox is missing")
result["errors"].append("Both gmd:EX_TemporalExtent and gmd:CI_Date are missing")
result["errors"].append("gmd:useLimitation is missing")
result["errors"].append("gmd:accessConstraints is missing")
result["errors"].append("gmd:otherConstraints is missing")
errors += 20
else:
if md.identification.contact is None or len(md.identification.contact) < 1:
result["errors"].append("gmd:CI_ResponsibleParty: Organization missing")
result["errors"].append("gmd:CI_ResponsibleParty: E-mail missing")
result["errors"].append("gmd:CI_ResponsibleParty: Role missing")
errors += 3
else:
if md.identification.contact[0].organization is None:
result["errors"].append("gmd:CI_ResponsibleParty: Organization missing")
errors += 1
if md.identification.contact[0].email is None:
result["errors"].append("gmd:CI_ResponsibleParty: E-mail missing")
errors += 1
if md.identification.contact[0].role is None:
result["errors"].append("gmd:CI_ResponsibleParty: Role missing")
errors += 1
if md.identification.title is None:
result["errors"].append("gmd:MD_DataIdentification: Title is missing")
errors += 1
if md.identification.abstract is None:
result["errors"].append("gmd:MD_DataIdentification: Abstract is missing")
errors += 1
if md.identification.identtype is None:
result["errors"].append("gmd:MD_ScopeCode: Resource Type is missing")
errors += 1
if md.identification.resourcelanguage is None or len(md.identification.resourcelanguage) < 1:
result["errors"].append("gmd:language: Resource Language is missing")
errors += 1
if md.identification.uricode is None or len(md.identification.uricode) < 1:
result["errors"].append("gmd:RS_Identifier: Unique Resource Identifier is missing")
errors += 1
if md.identification.topiccategory is None or len(md.identification.topiccategory) < 1:
result["errors"].append("gmd:topicCategory: TopicCategory is missing")
errors += 1
if md.identification.keywords is None or len(md.identification.keywords) < 1:
result["errors"].append("gmd:MD_Keywords: Keywords are missing")
result["errors"].append("gmd:thesaurusName: Thesaurus Title is missing")
result["errors"].append("gmd:thesaurusName: Thesaurus Date is missing")
result["errors"].append("gmd:thesaurusName: Thesaurus Date Type is missing")
errors += 4
else:
if md.identification.keywords[0]['keywords'] is None or len(md.identification.keywords[0]['keywords']) < 1:
result["errors"].append("gmd:MD_Keywords: Keywords are missing")
errors += 1
if md.identification.keywords[0]['thesaurus'] is None:
result["errors"].append("gmd:thesaurusName: Thesaurus Title is missing")
result["errors"].append("gmd:thesaurusName: Thesaurus Date is missing")
result["errors"].append("gmd:thesaurusName: Thesaurus Date Type is missing")
errors += 3
else:
if md.identification.keywords[0]['thesaurus']['title'] is None:
result["errors"].append("gmd:thesaurusName: Thesaurus Title is missing")
errors += 1
if md.identification.keywords[0]['thesaurus']['date'] is None:
result["errors"].append("gmd:thesaurusName: Thesaurus Date is missing")
errors += 1
if md.identification.keywords[0]['thesaurus']['datetype'] is None:
result["errors"].append("gmd:thesaurusName: Thesaurus Date Type is missing")
errors += 1
if md.identification.extent is None:
result["errors"].append("gmd:EX_Extent: extent element is missing")
errors += 1
else:
if md.identification.extent.boundingBox is None:
result["errors"].append("gmd:EX_GeographicBoundingBox: bbox is missing")
errors += 1
else:
if md.identification.extent.boundingBox.minx is None:
result["errors"].append("gmd:westBoundLongitude: minx is missing")
errors += 1
if md.identification.extent.boundingBox.maxx is None:
result["errors"].append("gmd:eastBoundLongitude: maxx is missing")
errors += 1
if md.identification.extent.boundingBox.miny is None:
result["errors"].append("gmd:southBoundLatitude: miny is missing")
errors += 1
if md.identification.extent.boundingBox.maxy is None:
result["errors"].append("gmd:northBoundLatitude: maxy is missing")
errors += 1
if len(md.identification.date) < 1 and (md.identification.temporalextent_start is None or md.identification.temporalextent_end is None):
result["errors"].append("Both gmd:EX_TemporalExtent and gmd:CI_Date are missing")
errors += 1
if len(md.identification.uselimitation) < 1:
result["errors"].append("gmd:useLimitation is missing")
errors += 1
if len(md.identification.accessconstraints) < 1:
result["errors"].append("gmd:accessConstraints is missing")
errors += 1
if len(md.identification.otherconstraints) < 1:
result["errors"].append("gmd:otherConstraints is missing")
errors += 1
if md.languagecode is None:
result["errors"].append("gmd:LanguageCode: Language code missing")
errors += 1
if md.datestamp is None:
result["errors"].append("gmd:dateStamp: Date is missing")
errors += 1
if md.identifier is None:
result["errors"].append("gmd:identifier: Identifier is missing")
errors += 1
if md.dataquality is None:
result["errors"].append("gmd:LI_Lineage is missing")
result["errors"].append("gmd:DQ_ConformanceResult: date is missing")
result["errors"].append("gmd:DQ_ConformanceResult: date type is missing")
# result["errors"].append("gmd:DQ_ConformanceResult: degree is missing")
result["errors"].append("gmd:DQ_ConformanceResult: title is missing")
errors += 4
else:
if md.dataquality.lineage is None:
result["errors"].append("gmd:LI_Lineage is missing")
errors += 1
if len(md.dataquality.conformancedate) < 1:
result["errors"].append("gmd:DQ_ConformanceResult: date is missing")
errors += 1
if len(md.dataquality.conformancedatetype) < 1:
result["errors"].append("gmd:DQ_ConformanceResult: date type is missing")
errors += 1
# if len(md.dataquality.conformancedegree) < 1:
# result["errors"].append("gmd:DQ_ConformanceResult: degree is missing")
# errors += 1
if len(md.dataquality.conformancetitle) < 1:
result["errors"].append("gmd:DQ_ConformanceResult: title is missing")
errors += 1
if md.contact is None:
result["errors"].append("gmd:contact: Organization name is missing")
result["errors"].append("gmd:contact: e-mail is missing")
errors += 2
else:
if md.contact[0].organization is None:
result["errors"].append("gmd:contact: Organization name is missing")
errors += 1
if md.contact[0].email is None:
result["errors"].append("gmd:contact: e-mail is missing")
errors += 1
if errors > 0:
result["status"] = "failed"
result["num_of_errors"] = str(errors)
return result
def export_iso(md,template,outfile):
pass
filename1 = 'aiolikos_charths.xml'
filename2 = 'aktogrammh.xml'
filename3 = 'full.xml'
# Create instances to test
valid_md = MD_Metadata(etree.parse(filename1))
not_valid_md = MD_Metadata(etree.parse(filename2))
full_md = MD_Metadata(etree.parse(filename3))
###########################
### create a new record ###
###########################
md = MD_Metadata()
md.identification = MD_DataIdentification()
md.dataquality = DQ_DataQuality()
md.distribution = MD_Distribution()
md.identification.extent = EX_Extent()
md.identification.extent.boundingBox = EX_GeographicBoundingBox()
# Metadata/Point Of Contact (GIMED):
val = CI_ResponsibleParty()
val.organization = 'xouxoutos'
val.email = 'foufoutos@gmail.com'
val.role = 'pointOfContact'
md.contact.append(val)
val = CI_ResponsibleParty() # record2
val.organization = 'momos'
val.email = 'kokos@gmail.com'
val.role = 'pointOfContact'
md.contact.append(val)
# Metadata/Metadata Date (GIMED):
md.datestamp = '2014-05-20'
# Metadata/Metadata Language (GIMED):
md.languagecode = 'eng'
# Identification/Resource Title (GIMED):
md.identification.title = 'Title blah blah'
# Identification/Resource Abstract (GIMED):
md.identification.abstract = 'Abstract blah blah'
# Identification/Resource Type (GIMED):
md.identification.identtype = 'dataset'
# Identification/Resource Locator (GIMED):
val = CI_OnlineResource()
val.url = 'http://publicamundi.eu'
md.distribution.online.append(val)
# Identification/Unique Resource Identifier (GIMED):
md.identifier = '286c0725-146e-4533-b1bf-d6e367f6c342'
md.identification.uricode.append('286c0725-146e-4533-b1bf-d6e367f6c342')
# Identification/Resource Language (GIMED):
md.identification.resourcelanguage.append('eng')
md.identification.resourcelanguage.append('gre')
# Classification/Topic Category (GIMED):
md.identification.topiccategory.append('biota')
md.identification.topiccategory.append('environment')
# Keyword/Keyword (GIMED):
kw = {}
kw['keywords'] = []
kw['keywords'].append('Agricultural and aquaculture facilities')
kw['keywords'].append('Bio-geographical regions')
kw['type'] = None
kw['thesaurus'] = {}
kw['thesaurus']['date'] = '2008-06-01'
kw['thesaurus']['datetype'] = 'publication'
kw['thesaurus']['title'] = 'GEMET - INSPIRE themes, version 1.0'
md.identification.keywords.append(kw)
kw = {}
kw['keywords'] = []
kw['keywords'].append('test')
kw['type'] = None
kw['thesaurus'] = {}
kw['thesaurus']['date'] = '2014-05-20'
kw['thesaurus']['datetype'] = 'creation'
kw['thesaurus']['title'] = 'test themes, version 2.0'
md.identification.keywords.append(kw)
# Geographic/Geographic (GIMED):
md.identification.extent.boundingBox.minx = '23.04'
md.identification.extent.boundingBox.maxx = '25.05'
md.identification.extent.boundingBox.miny = '44.03'
md.identification.extent.boundingBox.maxy = '45.01'
# Temporal/Temporal Extent (GIMED):
md.identification.temporalextent_start = '2014-05-20'
md.identification.temporalextent_end = '2014-05-21'
# Temporal/Date of publication (GIMED):
val = CI_Date()
val.date = '2014-05-06'
val.type = 'publication'
md.identification.date.append(val)
val = CI_Date()
val.date = '2014-05-08'
val.type = 'publication'
md.identification.date.append(val)
# Temporal/Date of creation (GIMED):
val = CI_Date()
val.date = '2014-05-01'
val.type = 'creation'
md.identification.date.append(val)
# Temporal/Date of revision (GIMED):
val = CI_Date()
val.date = '2014-05-12'
val.type = 'revision'
md.identification.date.append(val)
# Quality/Spatial Resolution (GIMED):
md.identification.denominators.append('5000')
md.identification.distance.append('2')
md.identification.uom.append('Meters')
# Quality/Lineage (GIMED):
md.dataquality.lineage = 'history blah blah blah'
# Conformity/Title (GIMED):
md.dataquality.conformancetitle.append('Commission Regulation (EU) No 1089/2010 of 23 November 2010 implementing Directive 2007/2/EC of the European Parliament and of the Council as regards interoperability of spatial data sets and services')
# Conformity/Date (GIMED):
md.dataquality.conformancedate.append('2010-12-08')
md.dataquality.conformancedatetype.append('publication')
# Conformity/Degree (GIMED):
md.dataquality.conformancedegree.append('true')
# Constraints/Limitations on public access (GIMED):
md.identification.accessconstraints.append('otherRestrictions')
md.identification.otherconstraints.append('no limitations')
# Constraints/Conditions for access and use-general (GIMED):
md.identification.uselimitation.append('no conditions apply')
# Organisation/Responsible Party (GIMED):
val = CI_ResponsibleParty()
val.email = 'lolos@gmail.com'
val.organization = 'NTUA'
val.role = 'owner'
md.identification.contact.append(val)
#######################
### end of creation ###
#######################
# Validate INSPIRE
print "------------------------------------------------"
print "Validation result for %s:" % filename1
print validate_inspire(valid_md)
print "------------------------------------------------"
print "Validation result for %s:" % filename2
print validate_inspire(not_valid_md)
print "------------------------------------------------"
print "Validation result for %s:" % filename3
print validate_inspire(full_md)
print "------------------------------------------------"
print "Validation result for custom MD_Metadata record:"
print validate_inspire(md)
print "------------------------------------------------"
# Save custom record to a valid ISO XML file
env = Environment(loader=FileSystemLoader('.'))
env.globals.update(zip=zip)
template = env.get_template('mdmetadata2iso.xml')
iso_xml = template.render(md=md)
xml_file = "md.xml"
xml_file = open("md.xml", "w")
xml_file.write(iso_xml)
xml_file.close()
xml_file = "md.xml"
new_md = MD_Metadata(etree.parse(xml_file))
print "Validation result for custom MD_Metadata XML record:"
print validate_inspire(new_md)
print "------------------------------------------------"
# # Validate against ISO xsd
# try:
# schema = 'http://schemas.opengis.net/iso/19139/20060504/gmd/gmd.xsd'
# #schema = './iso/19139/20060504/gmd/gmd.xsd'
# schema = etree.XMLSchema(file=schema)
# parser = etree.XMLParser(schema=schema,no_network=False)
# with open(filename1, 'r') as f:
# doc = etree.fromstring(f.read(), parser)
# print "ISO file is valid"
# except Exception, err:
# errortext = \
# 'Exception: document not valid.\nError: %s.' % str(err)
# print errortext
# # Validate against ISO schematron
# iso_sch = 'schematron-rules-iso.sch'
# sct_doc = etree.parse(iso_sch)
# schematron = isoschematron.Schematron(sct_doc)
# xml_doc = etree.parse(filename1)
# print schematron.validate(xml_doc)
# # Validate against INSPIRE schematron
# ins_sch = 'schematron-rules-inspire.sch'
# sct_doc = etree.parse(ins_sch)
# schematron = isoschematron.Schematron(sct_doc)
# xml_doc = etree.parse(filename1)
# print schematron.validate(xml_doc)
<?xml version="1.0" encoding="UTF-8"?>
<!-- ISO 19115:2003 file created from OWSLib object model -->
<gmd:MD_Metadata xsi:schemaLocation="http://www.isotc211.org/2005/gmd http://schemas.opengis.net/iso/19139/20060504/gmd/gmd.xsd" xmlns:gmd="http://www.isotc211.org/2005/gmd" xmlns:gco="http://www.isotc211.org/2005/gco" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:gml="http://www.opengis.net/gml" xmlns:xlink="http://www.w3.org/1999/xlink">
<gmd:fileIdentifier>
<gco:CharacterString>{{ md.identifier }}</gco:CharacterString>
</gmd:fileIdentifier>
<gmd:language>
<gmd:LanguageCode codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#LanguageCode" codeListValue="eng">{{ md.languagecode }}</gmd:LanguageCode>
</gmd:language>
<gmd:hierarchyLevel>
<gmd:MD_ScopeCode codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_ScopeCode" codeListValue="dataset" codeSpace="ISOTC211/19115">{{ md.identification.identtype }}</gmd:MD_ScopeCode>
</gmd:hierarchyLevel>
{% for co in md.contact -%}
<gmd:contact>
<gmd:CI_ResponsibleParty>
<gmd:organisationName>
<gco:CharacterString>{{ co.organization }}</gco:CharacterString>
</gmd:organisationName>
<gmd:contactInfo>
<gmd:CI_Contact>
<gmd:address>
<gmd:CI_Address>
<gmd:electronicMailAddress>
<gco:CharacterString>{{ co.email }}</gco:CharacterString>
</gmd:electronicMailAddress>
</gmd:CI_Address>
</gmd:address>
</gmd:CI_Contact>
</gmd:contactInfo>
<gmd:role>
<gmd:CI_RoleCode codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#CI_RoleCode" codeListValue={{ "\"%s\"" % co.role }} codeSpace="ISOTC211/19115">{{ co.role }}</gmd:CI_RoleCode>
</gmd:role>
</gmd:CI_ResponsibleParty>
</gmd:contact>
{% endfor -%}
<gmd:dateStamp>
<gco:Date>{{ md.datestamp }}</gco:Date>
</gmd:dateStamp>
<gmd:metadataStandardName>
<gco:CharacterString>ISO 19115</gco:CharacterString>
</gmd:metadataStandardName>
<gmd:metadataStandardVersion>
<gco:CharacterString>2003/Cor.1:2006</gco:CharacterString>
</gmd:metadataStandardVersion>
<gmd:identificationInfo>
<gmd:MD_DataIdentification>
<gmd:citation>
<gmd:CI_Citation>
<gmd:title>
<gco:CharacterString>{{ md.identification.title }}</gco:CharacterString>
</gmd:title>
{% for d in md.identification.date -%}
<gmd:date>
<gmd:CI_Date>
<gmd:date>
<gco:DateTime>{{ d.date }}</gco:DateTime>
</gmd:date>
<gmd:dateType>
<gmd:CI_DateTypeCode codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#CI_DateTypeCode" codeListValue={{ "\"%s\"" % d.type }} codeSpace="ISOTC211/19115">{{ d.type }}</gmd:CI_DateTypeCode>
</gmd:dateType>
</gmd:CI_Date>
</gmd:date>
{% endfor -%}
<gmd:identifier>
<gmd:RS_Identifier>
<gmd:code>
<gco:CharacterString>{{ md.identifier }}</gco:CharacterString>
</gmd:code>
</gmd:RS_Identifier>
</gmd:identifier>
</gmd:CI_Citation>
</gmd:citation>
<gmd:abstract>
<gco:CharacterString>{{ md.identification.abstract }}</gco:CharacterString>
</gmd:abstract>
{% for co in md.identification.contact -%}
<gmd:pointOfContact>
<gmd:CI_ResponsibleParty>
<gmd:organisationName>
<gco:CharacterString>{{ co.organization }}</gco:CharacterString>
</gmd:organisationName>
<gmd:contactInfo>
<gmd:CI_Contact>
<gmd:address>
<gmd:CI_Address>
<gmd:electronicMailAddress>
<gco:CharacterString>{{ co.email }}</gco:CharacterString>
</gmd:electronicMailAddress>
</gmd:CI_Address>
</gmd:address>
</gmd:CI_Contact>
</gmd:contactInfo>
<gmd:role>
<gmd:CI_RoleCode codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#CI_RoleCode" codeListValue={{ "\"%s\"" % co.role }} codeSpace="ISOTC211/19115">{{ co.role }}</gmd:CI_RoleCode>
</gmd:role>
</gmd:CI_ResponsibleParty>
</gmd:pointOfContact>
{% endfor -%}
{% for k in md.identification.keywords -%}
<gmd:descriptiveKeywords>
<gmd:MD_Keywords>
{% for kw in k['keywords'] -%}
<gmd:keyword>
<gco:CharacterString>{{ kw }}</gco:CharacterString>
</gmd:keyword>
{% endfor -%}
<gmd:thesaurusName>
<gmd:CI_Citation>
<gmd:title>
<gco:CharacterString>{{ k['thesaurus']['title'] }}</gco:CharacterString>
</gmd:title>
<gmd:date>
<gmd:CI_Date>
<gmd:date>
<gco:Date>{{ k['thesaurus']['date'] }}</gco:Date>
</gmd:date>
<gmd:dateType>
<gmd:CI_DateTypeCode codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#CI_DateTypeCode" codeListValue={{ "\"%s\"" % k['thesaurus']['datetype'] }}>{{ k['thesaurus']['datetype'] }}</gmd:CI_DateTypeCode>
</gmd:dateType>
</gmd:CI_Date>
</gmd:date>
</gmd:CI_Citation>
</gmd:thesaurusName>
</gmd:MD_Keywords>
</gmd:descriptiveKeywords>
{% endfor -%}
{% for rc in md.identification.uselimitation -%}
<gmd:resourceConstraints>
<gmd:MD_Constraints>
<gmd:useLimitation>
<gco:CharacterString>{{ rc }}</gco:CharacterString>
</gmd:useLimitation>
</gmd:MD_Constraints>
</gmd:resourceConstraints>
{% endfor -%}
{% for oc in md.identification.otherconstraints -%}
<gmd:resourceConstraints>
<gmd:MD_LegalConstraints>
<gmd:accessConstraints>
<gmd:MD_RestrictionCode codeList="http://www.isotc211.org/2005/resources/Codelist/ML_gmxCodelists.xml#MD_RestrictionCode" codeListValue="otherRestrictions">otherRestrictions</gmd:MD_RestrictionCode>
</gmd:accessConstraints>
<gmd:otherConstraints>
<gco:CharacterString>{{ oc }}</gco:CharacterString>
</gmd:otherConstraints>
</gmd:MD_LegalConstraints>
</gmd:resourceConstraints>
{% endfor -%}
{% if md.identification.denominators|length > 0 -%}
{% for den in md.identification.denominators -%}
<gmd:spatialResolution>
<gmd:MD_Resolution>
<gmd:equivalentScale>
<gmd:MD_RepresentativeFraction>
<gmd:denominator>
<gco:Integer>{{ den }}</gco:Integer>
</gmd:denominator>
</gmd:MD_RepresentativeFraction>
</gmd:equivalentScale>
</gmd:MD_Resolution>
</gmd:spatialResolution>
{% endfor -%}
{% endif -%}
{% if md.identification.distance|length > 0 and md.identification.uom|length > 0 -%}
{% for (d,u) in zip(md.identification.distance, md.identification.uom) -%}
<gmd:spatialResolution>
<gmd:MD_Resolution>
<gmd:distance>
<gco:Distance uom={{ "\"%s\"" % u }}>{{ d }}</gco:Distance>
</gmd:distance>
</gmd:MD_Resolution>
</gmd:spatialResolution>
{% endfor -%}
{% endif -%}
{% for lan in md.identification.resourcelanguage -%}
<gmd:language>
<gmd:LanguageCode codeList="http://www.isotc211.org/2005/resources/Codelist/ML_gmxCodelists.xml#LanguageCode" codeListValue={{ "\"%s\"" % lan }}>{{ lan }}</gmd:LanguageCode>
</gmd:language>
{% endfor -%}
{% for tc in md.identification.topiccategory -%}
<gmd:topicCategory>
<gmd:MD_TopicCategoryCode>{{ tc }}</gmd:MD_TopicCategoryCode>
</gmd:topicCategory>
{% endfor -%}
<gmd:extent>
<gmd:EX_Extent>
<gmd:geographicElement>
<gmd:EX_GeographicBoundingBox>
<gmd:westBoundLongitude>
<gco:Decimal>{{ md.identification.extent.boundingBox.minx }}</gco:Decimal>
</gmd:westBoundLongitude>
<gmd:eastBoundLongitude>
<gco:Decimal>{{ md.identification.extent.boundingBox.maxx }}</gco:Decimal>
</gmd:eastBoundLongitude>
<gmd:southBoundLatitude>
<gco:Decimal>{{ md.identification.extent.boundingBox.miny }}</gco:Decimal>
</gmd:southBoundLatitude>
<gmd:northBoundLatitude>
<gco:Decimal>{{ md.identification.extent.boundingBox.maxy }}</gco:Decimal>
</gmd:northBoundLatitude>
</gmd:EX_GeographicBoundingBox>
</gmd:geographicElement>
</gmd:EX_Extent>
</gmd:extent>
{% if md.identification.temporalextent_start != None -%}
<gmd:extent>
<gmd:EX_Extent>
<gmd:temporalElement>
<gmd:EX_TemporalExtent>
<gmd:extent>
<gml:TimePeriod xsi:type="gml:TimePeriodType">
<gml:beginPosition>{{ md.identification.temporalextent_start }}</gml:beginPosition>
<gml:endPosition>{{ md.identification.temporalextent_end }}</gml:endPosition>
</gml:TimePeriod>
</gmd:extent>
</gmd:EX_TemporalExtent>
</gmd:temporalElement>
</gmd:EX_Extent>
</gmd:extent>
{% endif -%}
</gmd:MD_DataIdentification>
</gmd:identificationInfo>
<gmd:distributionInfo>
<gmd:MD_Distribution>
<gmd:distributionFormat>
<gmd:MD_Format>
<gmd:name gco:nilReason="inapplicable"/>
<gmd:version gco:nilReason="inapplicable"/>
</gmd:MD_Format>
</gmd:distributionFormat>
<gmd:transferOptions>
<gmd:MD_DigitalTransferOptions>
{% for ln in md.distribution.online -%}
<gmd:onLine>
<gmd:CI_OnlineResource>
<gmd:linkage>
<gmd:URL>{{ ln.url }}</gmd:URL>
</gmd:linkage>
</gmd:CI_OnlineResource>
</gmd:onLine>
{% endfor -%}
</gmd:MD_DigitalTransferOptions>
</gmd:transferOptions>
</gmd:MD_Distribution>
</gmd:distributionInfo>
<gmd:dataQualityInfo>
<gmd:DQ_DataQuality>
<gmd:scope>
<gmd:DQ_Scope>
<gmd:level>
<gmd:MD_ScopeCode codeListValue={{ "\"%s\"" % md.identification.identtype }} codeList="http://www.isotc211.org/2005/resources/Codelist/ML_gmxCodelists.xml#MD_ScopeCode">{{ md.identification.identtype }}</gmd:MD_ScopeCode>
</gmd:level>
</gmd:DQ_Scope>
</gmd:scope>
{% for (t,d,dt,dg) in zip(md.dataquality.conformancetitle,md.dataquality.conformancedate,md.dataquality.conformancedatetype,md.dataquality.conformancedegree) -%}
<gmd:report>
<gmd:DQ_DomainConsistency xsi:type="gmd:DQ_DomainConsistency_Type">
<gmd:result>
<gmd:DQ_ConformanceResult xsi:type="gmd:DQ_ConformanceResult_Type">
<gmd:specification>
<gmd:CI_Citation>
<gmd:title>
<gco:CharacterString>{{ t }}</gco:CharacterString>
</gmd:title>
<gmd:date>
<gmd:CI_Date>
<gmd:date>
<gco:Date>{{ d }}</gco:Date>
</gmd:date>
<gmd:dateType>
<gmd:CI_DateTypeCode codeList="http://www.isotc211.org/2005/resources/Codelist/ML_gmxCodelists.xml#CI_DateTypeCode" codeListValue={{ "\"%s\"" % dt }}>{{ dt }}</gmd:CI_DateTypeCode>
</gmd:dateType>
</gmd:CI_Date>
</gmd:date>
</gmd:CI_Citation>
</gmd:specification>
<gmd:explanation>
<gco:CharacterString>See the referenced specification</gco:CharacterString>
</gmd:explanation>
<gmd:pass>
<gco:Boolean>{{ dg }}</gco:Boolean>
</gmd:pass>
</gmd:DQ_ConformanceResult>
</gmd:result>
</gmd:DQ_DomainConsistency>
</gmd:report>
{% endfor -%}
<gmd:lineage>
<gmd:LI_Lineage>
<gmd:statement>
<gco:CharacterString>{{ md.dataquality.lineage }}</gco:CharacterString>
</gmd:statement>
</gmd:LI_Lineage>
</gmd:lineage>
</gmd:DQ_DataQuality>
</gmd:dataQualityInfo>
</gmd:MD_Metadata>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment