Skip to main content

(Disclaimer: I have only rudimentary understandings of the inner workings of XML.)

The source below is a GML file where I need to fragment/flatten the elements shown. I would like to be able to treat them as "normal" features with regular attributes.

I am using the GML-reader associated with this specific data source, Norweigan SOSI, my settings are also below.

 

Q: What would be the best way to flatten this data?

 

(Or would the XMLfragmenter be a better tool? I must admit I find all this a bit confusing)

 

Skärmavbild 2023-10-09 kl. 18.14.22Skärmavbild 2023-10-09 kl. 18.15.06 

 

Hi @aron​ 

 

Please, could you share a example of your data?

 

 

Thanks in Advance,

Danilo


Hi,

I ended up using a number of listexploders and subsequent sorting to get the job done. It was not pretty.

 

If you want to dig into the data it can be downloaded from the Norweigan Surveying Authorities:

https://kartkatalog.geonorge.no/metadata/stedsnavn/30caed2f-454e-44be-b5cc-26bb5c0110ca


Hi @aron​ ,

If you are sure that the number of elements in the lists is always just one, you can replace all '{0}.' within the attribute names with a specific character (e.g. '_') using BulkAttributeRenamer and then rename the flattened attribute names with a subsequent AttributeManager if necessary.

  • Rename: All Attributes
  • Action: Regular Expression Replace
  • Mode: Rename
  • Text To Find: \\{\\d*\\}\\.
  • String: _

However, if there could be a case where the number of elements is two or more, I think ListExploder would be a common solution.

flatten_lists_with_a_single_element


To flatten the provided XML data, XSLT is a suitable tool. You can create an XSLT stylesheet that defines the transformation rules to convert hierarchical elements into a flat structure with regular attributes.

 

 

 

 

 

 

 

 

 

 

 

 

 

Ever wish for a genie to handle your assignments? https://domypaper.com/ grants your academic wishes with professional writers. I entrust do my papers with all my academic assignments, and they never disappoint. The writers consistently deliver well-researched and articulate papers, meeting even the tightest deadlines. Their reliability makes them a trustworthy partner in academic success.


Reply