Skip to main content
Question

Expose attributes in XMLFlattener based on list

  • Mar 6, 2024 5:26 PM UTC
  • 6 replies
  • 231 views

tb09114
Enthusiast
Forum|alt.badge.img+28

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+22
  • Influencer
  • Mar 7, 2024 8:57 AM UTC

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
Enthusiast
Forum|alt.badge.img+28
  • Author
  • Enthusiast
  • Mar 7, 2024 11:41 AM UTC

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+22
  • Influencer
  • Mar 7, 2024 1:03 PM UTC

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
Enthusiast
Forum|alt.badge.img+28
  • Author
  • Enthusiast
  • Mar 7, 2024 1:21 PM UTC

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+22
  • Influencer
  • Mar 7, 2024 2:24 PM UTC

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
Enthusiast
Forum|alt.badge.img+28
  • Author
  • Enthusiast
  • Mar 13, 2024 1:28 PM UTC

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

This one allows directly what I need through regex.