Solved

explode xml string to features

  • 12 March 2020
  • 4 replies
  • 6 views

I have a metadata string in a file and want to export this to its own attributes so I can export it to a database. 

If i use the fragmenter it gives only <missing> as output. I have elements to match: gmi:MI_Metadata and expose gmd:fileIdentifier.

 

Same happens when i use the XMLflattener. I can't figure out what i'm doing wrong. Being stuck at this for a few days already. Only solution what worked for me was

  • Export to XML
  • Open XML in Sublime text to Replace &lt; for < and &gt; for >
  • Open the XML in a new workflow to extract to databases

 

Sometimes i get this message

message:prefix 'gmi' can not be resolved to namespace URI

 

Example:

<?xml version="1.0" encoding="UTF-8"?>
<!-- BAG Metadata - Created with: -vSABER_5.2.0.9.5ISO TC211 schema -->
<gmi:MI_Metadata xmlns:gmi="http://www.isotc211.org/2005/gmi" xmlns:gmd="http://www.isotc211.org/2005/gmd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:gml="http://www.opengis.net/gml/3.2" xmlns:gco="http://www.isotc211.org/2005/gco" xmlns:xlink="http://www.w3.org/1999/xlink"  xmlns:bag="http://www.opennavsurf.org/schema/bag">
    <gmd:fileIdentifier><gco:CharacterString>19495cff-1e71-1b03-0ad9-03766b8b4567</gco:CharacterString></gmd:fileIdentifier>
    <gmd:language>
        <gmd:LanguageCode codeList="http://www.loc.gov/standards/iso639-2/" codeListValue="eng">eng</gmd:LanguageCode>
    </gmd:language>
    <gmd:characterSet>
        <gmd:MD_CharacterSetCode codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_CharacterSetCode" codeListValue="utf8">utf8</gmd:MD_CharacterSetCode>
    </gmd:characterSet>
    <gmd:hierarchyLevel>
        <gmd:MD_ScopeCode codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_ScopeCode" codeListValue="dataset">dataset</gmd:MD_ScopeCode>
    </gmd:hierarchyLevel>
    <gmd:contact>
        <gmd:CI_ResponsibleParty>
            <gmd:individualName>
                <gco:CharacterString>Paul L. Donaldson</gco:CharacterString>
            </gmd:individualName>
        <gmd:positionName><gco:CharacterString>Lead Hydrographer</gco:CharacterString> </gmd:positionName> 
    <gmd:role>
                <gmd:CI_RoleCode codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#CI_RoleCode" codeListValue="pointOfContact">pointOfContact</gmd:CI_RoleCode>
            </gmd:role>
        </gmd:CI_ResponsibleParty>
    </gmd:contact>
</gmi:MI_Metadata>
Can someone help me in the right direction?
icon

Best answer by takashi 12 March 2020, 15:00

View original

4 replies

Userlevel 2
Badge +17

Hi @wilco,

you should be able to extract any values in an XML document with the XMLFlattener. Just be aware that the extracted attribute name will be a concatenated string that represents XML path, and you need to expose it.

You can see the extracted attribute names if you send the resulting feature to a Logger (Translation Log window) or an Inspector (Feature Information window of Data Inspector).

For example, if you set MI_Metadata to the Elements to Match parameter and run the XMLFlattener, extracted attribute names look like this.

Hi @wilco,

you should be able to extract any values in an XML document with the XMLFlattener. Just be aware that the extracted attribute name will be a concatenated string that represents XML path, and you need to expose it.

You can see the extracted attribute names if you send the resulting feature to a Logger (Translation Log window) or an Inspector (Feature Information window of Data Inspector).

For example, if you set MI_Metadata to the Elements to Match parameter and run the XMLFlattener, extracted attribute names look like this.

Hi @takashi

I can only recreate your output if I export the string to a XML first and import the XML file to a flattener.

The XML is in a string of a BAG file. When I use the flattener to extract the string it outputs the whole string into 1 feature.

Im sure im doing something wrong, but I can't figure out yet what Im doing wrong to get the same output.

Badge +10

Hi @takashi

I can only recreate your output if I export the string to a XML first and import the XML file to a flattener.

The XML is in a string of a BAG file. When I use the flattener to extract the string it outputs the whole string into 1 feature.

Im sure im doing something wrong, but I can't figure out yet what Im doing wrong to get the same output.

It doesn't look like you have exposed any of the attributes

You will need to enter the attributes to expose in the flattener

Thank you @takashi and @ebygomm

 

Its working now :) It's a long xml document but it will be worth typing it out for further documents in the future!

Thank you a lot! now I can continue with my project

 

Reply