Skip to main content

Hi there,

I have following input:

  • a list with unknown/varying keys and values

What I need:

  • the name of the keys as attribute values

Examples

What I already tried:

  • ListHistogrammer
    This has no effect. Is it because it’s a “nested list”?

 

Cheers,
Maria

Is the ListExploder what you are looking for? I tried recreating your list using a couple of AttributeCreators and a ListBuilder, I now have a feature with an ID attribute and three attributes stored in a list:

When I use the ListExploder on the list PropertyDef{}, every list entry (Definition, Name and PropertyType) gets stored in a separate attribute:

Note that if you have multiple values stored in PropertyDef{}.PropertyType, PropertyDef{}.Name or PropertyDef{}.Definition, you would get multiple features with the same ID for each of those list items. 

Hope this helps!

Edit: I misread your post. I see you want the keys stored as attribute values, not attributes… Maybe you can try the AttributeExploder after the ListExploder (and after some filtering to avoid having to juggle hundreds of features). It will probably be a pain to stitch everything back together using an Aggregator. But it seems Dustin has already provided a Safe-certified workflow


FME cannot dynamically expose all attributes in cases like this.

The XMLFlattener would be your starting point, if it isn’t already. This will create attributes from your XML elements, but they have to be specifically defined (not helpful in your dynamic situation).

There is a tip provided by @daveatsafe in the link below that I think you will find useful. I use this method sometimes when working with XML/JSON. Using this, you can write the schema out to CSV, then use that external file to populate an AttributeExposer. It’s not a complete solution since any new XML elements you encounter in the future will not be accounted for. However, it may be your best best. You could always build upon the CSV when you receive new data.

 


Reply