About Writer Feature Types: User Attributes

Writer Feature Types are objects on the Workbench canvas that define the schema of the data being written. Most importantly, they define two specific things: 

  • the layers being written to a destination dataset, and
  • the attributes that those layers are to possess.

Attribute Definitions

Writer Feature Type Attributes

Every Writer Feature Type dialog contains a User Attributes tab. These parameters allow you to define the attributes that will be associated with this feature type. Attributes can be defined by editing an existing feature type, or when a new feature type is added to a workspace.

Attributes can be defined in three ways: Automatic, Manual, or Dynamic.

The default option is Manual.

Manual User Attribute Definitions

A manual User Attribute definition is when the workspace author can manually enter attribute names, select the attribute type, and define cell width, formatting (where applicable), and values. This example shows three attributes that have been defined for an address table:

On the Workbench canvas, the feature type looks like this:

To assign a User Attribute value, you can enter a fixed (constant) value, set a conditional value, open an editor, or select User Parameters. This example shows three attributes that have been defined for an address table, and one attribute that has a defined value:

On the Workbench canvas, the feature type indicates that the attribute has a defined value.

Automatic User Attribute Definitions

An Automatic Attribute Definition is when Workbench automatically defines the list of attributes, depending on which Reader feature types are connected. When you click the Automatic option, the attribute definition fields are empty and you cannot edit them.

Similarly, on the Workbench canvas, the feature type is also empty:

What makes the definitions automatic is the action that occurs when a Reader feature type is connected:

Notice that all of the attributes defined on the Reader feature type are now copied over to the Writer feature type automatically.

Because this operates automatically, if the Reader feature type is removed, and another one is connected, the list of attributes on the Writer feature type will be immediately updated to match. Or, if a second Reader feature type is connected, then the list of attributes updates to become a union of the two types:

This is useful because it means that multiple streams of data can be merged into a single feature type, and all attribute definitions are automatically defined.

However, what the Automatic option does not do is handle a scenario where you change the Reader dataset parameter to read data with a different set of attributes. In other words, the Writer attributes will only be defined by what is connected, not what actually exists in the source data. For that scenario, you need Dynamic Attributes.

Dynamic User Attribute Definitions

Specifying dynamic attributes also causes the Dynamic Schema Definition option (in the Parameters tab) to be selected.

Similar to an Automatic Attribute Definition, the initial feature type will not contain attributes. And when Reader feature types are connected, the feature type will still not contain attributes. A dynamic feature type truly has no definition in advance. Instead, it dynamically takes its attribute definitions from either the data that is fed to it when the workspace is run, or another set of schema definitions selected by the user.

Differences between Automatic and Dynamic Attribute Definitions

  • The Automatic Attribute Definition takes its attribute definition from whatever is connected to it in the workspace. If the Source Dataset parameter is changed, it will have no effect.
  • The Dynamic Attribute Definition is different. If the Source Dataset parameter is changed, a dynamic schema will (by default) take its attribute definition from whatever source data is being read.

Adding and Managing Feature Types

As we have already seen, the Writer schema defines "what we want" as a destination dataset. So if you want to write data to a particular layer, in a particular dataset, then you have to ensure that the layer is defined as a feature type in the canvas.

In some cases, this happens automatically. When you generate a workspace, the source dataset(s) you choose are scanned and all of the layers within get matching feature type objects in the workspace – both on the Reader and the Writer.

Note: When FME adds Writer feature types as part of a new workspace, those feature types will get a fixed (manual) attribute definition that is taken from the selected source dataset. You can then manually edit these attributes.

However, in most cases you need to manage Writer feature types separately, because what you want from the Writer is not the same as what you have in the Reader. For example, if you want to divide an incoming layer of data into two layers in the output dataset, you will need to add a new Writer feature type.

Adding a Writer feature type manually has this effect on the hierarchy diagram. Your output was designed to have only a single layer; now it will have two.

Adding Feature Types to an Existing Writer

Feature Types can be added manually to a writer using Writers>Add Feature Type on the menubar.

Note: At least one writer must exist in the translation hierarchy; else this option will be greyed out.

Selecting Add Feature Type places a feature type object on the workspace, and then opens the Feature Type dialog so you can edit the feature type's properties.

Similar to editing the schema, the Parameters tab can be used to define the new feature type’s name.

Feature Type names use format-specific terminology, so the label might be Feature Class, Layer, Sheet Name, Table Name, or whatever terminology is specific to the format of data you are writing:

After a feature type is added, the schema is defined in the User Attributes tab.

Adding Feature Types to a New Writer

When you are adding a new Writer, you can also control the feature types that are added to the workspace:

There are six options for adding feature types:

  • Automatic: Adds a new feature type with the attribute definition parameter set to automatic. This is the default.
  • Manual: Adds a new feature type with the attribute definition parameter set to manual.
  • Copy from Reader: Adds a new feature type with the attribute definition parameter set to manual, but predefined to the schema of an existing Reader feature type.
  • Import from Dataset: Adds a new feature type with the attribute definition parameter set to manual, but predefined to the schema of an external dataset (just like using the Import Feature Types tool).
  • Dynamic: Adds a new feature type with the attribute definition parameter set to dynamic.
  • None: Does not add any new feature type.

Copying Feature Types to a Writer

When adding a Writer it's possible to create a new feature type whose attribute schema is pre-defined to that of an existing Reader. However, if you already have a Writer, you can still carry out the same procedure of copying a Reader schema. This is simply done by selecting the required Reader feature types, right-clicking them, and using the option Duplicate (on Writer).

The command causes duplicates of the Reader feature types to be added to the writer, and source/destination feature types to be automatically connected.

At least one writer must exist in the translation hierarchy, or this option is disabled.