Code Monkey home page Code Monkey logo

xml-toolbelt-py's People

Contributors

guts avatar leodarengosse avatar simonsampere avatar

Watchers

 avatar  avatar  avatar

xml-toolbelt-py's Issues

Améliorer le lecteur de Métadonnées

Champs à récupérer qui ne sont pas dans la fonction asDict()

  • Mots-clés
<gmd:descriptiveKeywords>
     <gmd:MD_Keywords>
          <gmd:keyword>
              <gco:CharacterString>Urbanisme</gco:CharacterString>
          </gmd:keyword>
          <gmd:keyword>
              <gco:CharacterString>Emplacement</gco:CharacterString>
          </gmd:keyword>
          <gmd:keyword>
              <gco:CharacterString>Réservé</gco:CharacterString>
          </gmd:keyword>
  • Thématiques INSPIRE
<gmd:descriptiveKeywords>
     <gmd:MD_Keywords>
          <gmd:keyword>
               <gco:CharacterString>Adresses</gco:CharacterString>
          </gmd:keyword>
          <gmd:type>
                <gmd:MD_KeywordTypeCode codeListValue="theme" codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/codelist/ML_gmxCodelists.xml#MD_KeywordTypeCode" />
          </gmd:type>
          <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 codeListValue="publication" codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/codelist/ML_gmxCodelists.xml#CI_DateTypeCode" />
                              </gmd:dateType>

  • Résolution
  <gmd:MD_Metadata>
     <gmd:identificationInfo>
       <gmd:MD_DataIdentification>
         <gmd:spatialResolution>
          <gmd:MD_Resolution>
           <gmd:distance>
            <gco:Distance uom="cm">25</gco:Distance>
           </gmd:distance>
  • Conditions
  • Limitations
  • Spécifications

Champs qui ne fonctionnent pas dans la fonction asDict() --> rien n'est retourné alors que l'information existe

  • Type de géométrie
<gmd:spatialRepresentationInfo>
    <gmd:MD_VectorSpatialRepresentation>
      <gmd:geometricObjects>
        <gmd:MD_GeometricObjects>
          <gmd:geometricObjectType>
            <gmd:MD_GeometricObjectTypeCode codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/codelist/ML_gmxCodelists.xml#MD_GeometricObjectTypeCode" codeListValue="point" />
          </gmd:geometricObjectType>
        </gmd:MD_GeometricObjects>
      </gmd:geometricObjects>
    </gmd:MD_VectorSpatialRepresentation>
  </gmd:spatialRepresentationInfo>
  • Catalogue d'attributs associés
<gmd:contentInfo xmlns:date="http://exslt.org/dates-and-times">
 <gmd:MD_FeatureCatalogueDescription>
  <gmd:includedWithDataset/>
   <gmd:featureCatalogueCitation uuidref="0a80da9e-c5dc-4343-97fa-b6d5e05dfa9e" xlink:href="http://www.mongeosource.fr/geosource/1197/fre/csw?service=CSW&request=GetRecordById&version=2.0.2&outputSchema=http://www.isotc211.org/2005/gmd&elementSetName=full&id=0a80da9e-c5dc-4343-97fa-b6d5e05dfa9e#MD_DataIdentification"/>
  </gmd:MD_FeatureCatalogueDescription>
</gmd:contentInfo>
  • Contacts

Lien unidirectionnel entre la fiche et le catalogue d'attributs

On retrouve dans la fiche l’identifiant du catalogue d’attribut associé dans la balise ci-dessous :

<gmd:contentInfo xmlns:date="http://exslt.org/dates-and-times">
<gmd:MD_FeatureCatalogueDescription>
<gmd:includedWithDataset/>
<gmd:featureCatalogueCitation uuidref="0a80da9e-c5dc-4343-97fa-b6d5e05dfa9e" xlink:href="http://www.mongeosource.fr/geosource/1197/fre/csw?service=CSW&request=GetRecordById&version=2.0.2&outputSchema=http://www.isotc211.org/2005/gmd&elementSetName=full&id=0a80da9e-c5dc-4343-97fa-b6d5e05dfa9e#MD_DataIdentification"/>
</gmd:MD_FeatureCatalogueDescription>
</gmd:contentInfo>

Un catalogue d’attributs peut être associé à 1...n fiche(s) → il n’y a pas dans le catalogue d’attributs, le ou les identifiants des fiches qui lui ont été associée.

Ajouter une fonction pour renommer les métadonnées XML avec leur titre et identifiant en nom de fichier

Exemple de structure avec les exports de géosource :

export-full-1542728453496
    Fiche
         0aad7122-baa3-42b4-8d79-cf9c3e83035c
	      metadata	
                    metadata.xml
              private
	      public
              info.xml
    Catalogue d’attribut
        0a80da9e-c5dc-4343-97fa-b6d5e05dfa9e
	      metadata	
                    metadata.xml
              private
	      public
              info.xml

Vieux script à MAJ et inclure :

from os import path, rename, walk

path_src = path.realpath(r"C:\Users\XXXXXXXXX\Downloads\export-full-1503398299781")
path_dest = path.realpath(r"C:\Users\XXXXXXXX\Downloads\export-full-1503398299781")

for root, dirs, files in walk(path_src):
    for i in files:
        extension = path.splitext(path.join(root, i))[1]
        filename = path.basename(path.join(root, i))
        # print(i, filename, extension)
        if extension == ".xml" and "metadata" in i:
            #print(path.dirname(path.join(root, i)))
            md_id = path.split(path.dirname(path.dirname(path.join(root, i ))))[1]
            # print(i, filename, extension)
            rename(path.join(root,i), path.join(path_dest, md_id + extension))
            

Détecter les champs xml manquants (balises absentes) et les ajouter

Exemple de champs XML (Titre de la métadonnée)

<gmd:identificationInfo>
    <gmd:MD_DataIdentification gco:isoType="gmd:MD_DataIdentification">
        <gmd:citation>
            <gmd:CI_Citation>
                <gmd:title>
                   <gco:CharacterString>Axe de Seine et points kilométriques (SEINE_AXE)</gco:CharacterString>
                </gmd:title>

Si la balise gmd:identificationInfo et ses sous-jacentes n'existent pas dans le fichier xml testé, il faut pouvoir prévenir l'utilisateur qu'il manque ce champs et le rajouter ensuite.

Au préalable, il faut définir avec l'utilisateur ce qu'il veut renseigner dans le champs manquant. (Exemple du titre ci-dessus : Axe de Seine et points kilométriques)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.