Working with Multiple Copies of Custom Transformers

If a custom transformer will be used in multiple locations (for example, after you duplicate it), it is important to understand how each instance of that transformer references other parts of a workspace as input.

For example, if you have a single instance of a custom transformer that references an attribute name, the first instance of a custom transformer will see the attribute name as being available, because FME can guarantee that the attribute is available within that stream. However, when you reuse the transformer, FME cannot guarantee that the transformer will be connected to a stream containing the same set of attributes.

To avoid the potential problem of referencing a non-existent attribute, when you duplicate and reuse a custom transformer, FME automatically publishes any parameters that are referenced as input. This allows you to individually select different attributes for each instance of the transformer, and keep the custom transformer valid and usable.  

There are two potential workflow scenarios when you reuse custom transformers:

Reusing custom transformers: changing input attributes

The simple example below shows what happens when you create a custom transformer that needs to reference different attributes for each instance of the transformer.

This example shows a set of transformers.

As the Summary Annotation shows, the Buffer Amount field in the Bufferer is linked to the road_width attribute from the Creator.

Create a custom transformer from the Bufferer transformer.

When the custom transformer appears, click the yellow properties button. The Bufferer transformer is still referencing the original attribute from the Creator transformer.

 

Click the Main tab in the workspace window.

Select the custom transformer and copy/paste it (or choose Duplicate from the command menu). The properties button on the duplicated transformer is red because the transformer is looking for the original road_width attribute.

Click the tab that contains the new custom transformer.

FME has automatically published the Buffer Amount parameter, and the missing attribute is listed under Published Parameters in the Navigator pane.

If you delete this published parameter, the properties button of the custom transformer will turn red, since it will still be trying to reference road_width.

Publishing the parameters means that if you now connect the River features to the reused custom transformer, you have the option to choose river_length as the attribute, instead of road_width.

This alternate example shows the situation where both instances do use the same attribute.  

Other ways of identifying referenced attributes

Inserting an AttributeExposer into the custom transformer can identify any hidden referenced attributes. In this scenario, there is no need to select a different attribute when you insert a custom transformer into a workspace.

In this example, we deleted the published parameter that FME created, and replaced it by inserting an AttributeExposer. By manually exposing the road_width attribute, we have made the attribute available within every instance of this custom transformer.

Note: You must be absolutely certain that any workflow that incorporates this custom transformer includes the road_width attribute, since it is now "hard-coded” into the transformer.