Skip to main content
Question

Expose attributes in XMLFlattener based on list


tb09114
Supporter
Forum|alt.badge.img+23

I am getting features in through a WFS and pump the resulting XML structures through an XMLFlattener.

The Elements to Match are ‘grouped’ by an attribute value and thereby dynamic.

What I cannot make dynamic are the Attributes to Expose. I can either write them myself, or import them, but how can I get e.g. a list to work there, or the value of an attribute?

Best thing would be the option of a conditional value… 😉

6 replies

joepk
Influencer
Forum|alt.badge.img+20
  • Influencer
  • March 7, 2024

I don't think dynamically exposing attributes like that is possible. There are a lot of threads asking this, and a few workarounds for specific scenarios have been found, do you need the attributes in your canvas or do you just need to write them?


tb09114
Supporter
Forum|alt.badge.img+23
  • Author
  • Supporter
  • March 7, 2024

Hi @joepk I only need to write them. The issue is that there are more than 80 different elements to match , and each comes with its own set of attributes I have to expose. I don’t mind preparing the different lists, it needs to be done anyway, but having 80 XMLFlatteners in my workspace… not exactly how I imagined.


joepk
Influencer
Forum|alt.badge.img+20
  • Influencer
  • March 7, 2024

If you only have to read and write the features you do not have to expose the attributes. Unexposed attributes are still there when you write them using a dynamic writer. This article could help you set up a dynamic writer, or this tutorial, or maybe this documentation of the SchemaScanner


tb09114
Supporter
Forum|alt.badge.img+23
  • Author
  • Supporter
  • March 7, 2024

My workspace already uses a SchemaScanner and a dynamic Writer. The attributes I have to expose are not all of the attributes per element, but just a subset. Many of the attributes that come with the elements are of no interest to me, and I would like to get rid of them as fast as possible. For sure I do not want to write them out.


joepk
Influencer
Forum|alt.badge.img+20
  • Influencer
  • March 7, 2024

Ah so you want to keep a certain set of attributes which changes depending on the element that is matched.

I would consider using a separate WorkspaceRunner to create a string of attributes you want to keep (assuming you have these lists somewhere), and pass that string onto your actual analysis workspace as a User Parameter, where the User Parameter can be used in an AttributeKeeper, removing all other attributes. 


tb09114
Supporter
Forum|alt.badge.img+23
  • Author
  • Supporter
  • March 13, 2024

Took me a while but I found the BulkAttributeKeeper, a community transformer at FME Hub.

This one allows directly what I need through regex.

 


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings