Welcome to Isogeo - XML Toolbelt’s documentation!¶
Author: | Isogeo |
---|---|
Source code: | https://github.com/isogeo/xml-toolbelt-py/ |
Issues: | https://github.com/isogeo/xml-toolbelt-py/issues |
Indices and tables¶
Package modules¶
isogeo_xml_toolbelt¶
isogeo_xml_toolbelt package¶
This package is used to handle geographic metadata asstored as XML in ISO 19139 and 19110.
Subpackages¶
isogeo_xml_toolbelt.enums package¶
isogeo_xml_toolbelt.models package¶
Isogeo XML Fixer - Metadata
Purpose: Read a metadata stored into XML ISO 19110 as an object Authors: Isogeo, inspired by the work did by GeoBretagne on mdchecker Python: 3.6.x
-
class
isogeo_xml_toolbelt.models.xml_19139_fields.
Contact
(contact, namespaces)[source]¶ Bases:
object
Contact in metadata XML 19139
Parameters: - contact (lxml.etree._ElementTree) – Element {http://www.isotc211.org/2005/gmd}CI_ResponsibleParty
- namespaces (dict) – XML namespaces like lxml.etree.getroot().nsmap
isogeo_xml_toolbelt.readers package¶
Isogeo XML Fixer - Metadata
Purpose: Read a metadata stored into XML ISO 19110 as an object Authors: Isogeo, inspired by the work did by GeoBretagne on mdchecker Python: 3.6.x
Isogeo XML Fixer - Metadata
Purpose: Read a metadata stored into XML ISO 19139 as an object Authors: First work by GeoBretagne on mdchecker - updated by Isogeo Python: 3.6.x
isogeo_xml_toolbelt.reporters package¶
Sample module to manage CSV reporting
-
class
isogeo_xml_toolbelt.reporters.csv_reporter.
CsvReporter
(csvpath: pathlib.Path = PosixPath('report.csv'), headers: list = ['header1', 'header2'], extrahead: str = 'ignore')[source]¶ Bases:
object
Produce CSV report. Inherits from standard ‘csv.DictWriter’ lib.
-
add_multiple
(in_data: list)[source]¶ Add a set of rows to the CSV from the input list of data dictionaries.
Parameters: in_data (list) – list of dictionaries of data to be added. Expected structure: [{header1: valueA}, {header2: valueB}]
-
isogeo_xml_toolbelt.utils package¶
Isogeo XML Fixer - Metadata
Purpose: Read a metadata stored into XML ISO 19110 as an object Authors: Isogeo, inspired by the work did by GeoBretagne on mdchecker Python: 3.6.x
-
class
isogeo_xml_toolbelt.utils.xml_utils.
XmlUtils
[source]¶ Bases:
object
Common methods used to parse XML files.
-
parse_string_for_max_date
(dates_as_str: str)[source]¶ Parse string with multiple dates to extract the most recent one. Used to get the latest modification date.
Parameters: dates_as_str (str) – string containing dates
-
xmlGetTextNodes
(doc: lxml.etree._ElementTree, xpath: str, namespaces: dict)[source]¶ Shorthand to retrieve serialized text nodes matching a specific xpath.
Parameters: - doc (lxml.etree._ElementTree) – XML element to parse
- xpath (str) – Xpath to reach
- namespaces (dict) – XML namespaces like lxml.etree.getroot().nsmap
-
xmlGetTextTag
(doc: lxml.etree._ElementTree, xpath: str, namespaces: dict, key: str)[source]¶ Function to get information in tag when information isn’t in nodes matching a specific xpath.
Parameters: - doc (lxml.etree._ElementTree) – XML element to parse
- xpath (str) – Xpath to reach
- namespaces (dict) – XML namespaces like ‘lxml.etree.getroot().nsmap’
:param key : XML key to find like ‘codeListValue’
-
Submodules¶
isogeo_xml_toolbelt.md_xml_fixer module¶
-
class
isogeo_xml_toolbelt.md_xml_fixer.
MetadataXML19139Fixer
[source]¶ Bases:
object
ISO 19139 XML fixer.
-
add_ds_creation_date
()[source]¶ Add metadata creation date into metadata XML.
Under /MD_Metadata/identificationInfo/MD_DataIdentification/citation/CI_Citation/date <date>
- <CI_Date>
- <date>
- <gco:Date>2010-07-07Z</gco:Date>
</date> <dateType>
<CI_DateTypeCode codeList=”http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/codelist/ML_gmxCodelists.xml#CI_DateTypeCode” codeListValue=”creation”>creation</CI_DateTypeCode></dateType>
</CI_Date>
</date>
-
add_md_character_set
()[source]¶ Add metadata creation date into metadata XML.
Under /MD_Metadata/characterSet AND /MD_Metadata/identificationInfo/MD_DataIdentification/characterSet <characterSet>
<MD_CharacterSetCode codeList=”http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/codelist/ML_gmxCodelists.xml#MD_CharacterSetCode” codeListValue=”utf8”>utf-8</MD_CharacterSetCode></characterSet>
-
fix_cgus
()[source]¶ Add dataset usage conditions and limitations into metadata XML.
Under /MD_Metadata/identificationInfo/MD_DataIdentification/resourceConstraints
- <resourceConstraints>
- <MD_Constraints>
- <useLimitation>
- <gmx:Anchor xl:href=”http://www.etalab.gouv.fr/licence-ouverte-open-licence” xl:title=”Licence ouverte ETALAB 1.0” />
</useLimitation> <useLimitation>
<gco:CharacterString>Conditions sur [geopaysdebrest.fr > Usage des données](https://geo.pays-de-brest.fr/usages/Pages/default.aspx).</gco:CharacterString></useLimitation>
</MD_Constraints>
</resourceConstraints> <resourceConstraints>
- <MD_LegalConstraints>
- <useLimitation>
- <gco:CharacterString>Pas de restriction d’accès public selon INSPIRE</gco:CharacterString>
</useLimitation> <useLimitation>
<gco:CharacterString>Conditions sur [geopaysdebrest.fr > Usage des données](https://geo.pays-de-brest.fr/usages/Pages/default.aspx).</gco:CharacterString></useLimitation> <accessConstraints>
<MD_RestrictionCode codeList=”http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/codelist/gmxCodelists.xml#MD_RestrictionCode” codeListValue=”license”>license</MD_RestrictionCode></accessConstraints>
</MD_LegalConstraints>
</resourceConstraints>
-
fix_srs
()[source]¶ Fix Spatial Reference System.
Under /MD_Metadata/referenceSystemInfo/MD_ReferenceSystem/referenceSystemIdentifier/RS_Identifier <referenceSystemInfo>
- <MD_ReferenceSystem>
- <referenceSystemIdentifier>
- <RS_Identifier>
- <code>
- <gco:CharacterString>urn:ogc:def:crs:EPSG:2154</gco:CharacterString>
</code>
</RS_Identifier>
</referenceSystemIdentifier>
</MD_ReferenceSystem>
</referenceSystemInfo>
-