span8
span4
span8
span4
1. Create a new workspace. Add a schema reader and point it to your schema source.
2. Create a new Published Parameter with the name TO_KEEP and the prompt "Fields to Keep"
3. Connect the source schema feature to a ParameterFetcher. Set the Parameter Name to TO_KEEP and the Target Attribute to _to_keep.
4. Connect the ParameterFetcher to a PythonCaller. Set the Python symbol to keep_defs and add the following Python source code:
from pyfme import *
def keep_defs(feature):
att_name_list = feature.getListAttribute('attribute{}.name')
att_ntype_list = feature.getListAttribute('attribute{}.native_data_type')
att_ftype_list = feature.getListAttribute('attribute{}.fme_data_type')
keep_values = feature.getStringAttribute('_to_keep')
keep_list = keep_values.split(',')
if att_name_list != None:
feature.removeListAttribute(“属性{}.name')
feature.removeListAttribute(“属性{}.native_data_type')
feature.removeListAttribute(“属性{}.fme_data_type')
count = 0
for i in range(len(att_name_list)):
if (att_name_list[i] in keep_list):
feature.setStringAttribute(('attribute{'+str(count)+'}.name'),att_name_list[i])
feature.setStringAttribute(('attribute{'+str(count)+'}.native_data_type'),att_ntype_list[i])
feature.setStringAttribute(('attribute{'+str(count)+'}.fme_data_type'),att_ftype_list[i])
count = count + 1
if (att_name_list[i] == 'fme_geometry{0}'):
feature.setStringAttribute('fme_geometry{0}',att_ftype_list[i])
5. Connect the PythonCaller to an AttributeRemover and remove the attribute _to_keep.
6. Add an FFS writer and create an output feature called "schema". Connect the AttributeRemover to the schema output and save the workspace as a Custom Format with the name SCHEMASUBSET.
You can now add the format SCHEMASUBSET as a schema source in workspace resources. Only the attributes listed in the Fields to Keep parameter will be used to generate a dynamic schema.
Dynamic Workflows: Advanced Example - Modifying the Schema Feature
Pass a List of Tables or Layers to an FME Reader using Python Scripted Parameters
Dynamic Workflows: Destination Schema Derived from Multiple Sources
Setting up a workspace to deploy in production, staging and local
Dynamic Workflows: Basics of Dynamics
Dynamic Workflows: Destination Schema Contains Different Feature Type Names
Dynamic Workflows: Destination Schema as a Mirror Image of the Source Dataset
Dynamic Workflows: Destination Schema is Derived from a Schema Feature
© 2020 Safe Software Inc |Legal