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('attribute{}.name')
feature.removeListAttribute('attribute{}.native_data_type')
feature.removeListAttribute('attribute{}.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
Setting up a workspace to deploy in production,staging and local
Dynamic 亚搏在线Workflows: Destination Schema Derived from Multiple Sources
Pass a List of Tables or Layers to an FME Reader using Python Scripted Parameters
Dynamic 亚搏在线Workflows: Destination Schema is Derived from an External Dataset
Dynamic 亚搏在线Workflows: Destination Schema is Derived from a Lookup Table
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
© 2019 亚搏在线Safe Software Inc |法律