span8
span4
span8
span4
As mentioned in theprevious article,any Reader dataset – in any format – can be used as the source for the outgoing schema.The key thing to remember is that the dynamic writer needs to be able to find that schema definition,by name,for this 亚搏在线workflow to work.
So what happens when you are using a brand new name to write out your data?
In this situation,you need to use a special parameter inside the writer's feature type called 'Schema Definition Name'.This parameter informs the writer of the correct name to use when searching the source for a matching schema.
Here are a few reasons why you may encounter this:
In the following example,a project has been setup in order to provide updated city schema in the form of a database.This database has been predefined but contains generic feature type names.In order to create a dynamic 亚搏在线workflow and write out the data with the schema from this database,the database must be added to the workspace as a workspace resource.We will then change the output dataset names to include the city as a prefix (i.e Vancouver_BusStops).
The SpatiaLite Database containing our schema:
1.Add the Source Dataset
Open FME to a new workspace and from the Readers menu select "Add Reader".
2.Add the Destination Dataset
From the Writers menu select "Add Writer".
3.Add the Database as a Resource
Load the database into the workspace as a Reader Resource using this function:
Once the database is added,an entry is placed in the Navigator window:
4.Create the New Table Name Attribute
We will be concatenating the existing feature type names with the city name: "Vancouver".To do this add a StringCocatenator and fill out the details as below:
5.Schema Mapping
Make sure the workspace contains the correct mappings to match the new attribute schema contained by the database.In this example,the AttributeManager transformer is used to provide this.Use the table below to create your attribute map.Connect the AttributeManager to the StringCocatenator,and then connect the AttributeManager Output port to the Dynamic Writer.
Input Attribute | Output Attribute |
PRIMARYINDEX | PID |
class | ROAD_CLASS |
featureID | FEATUREID |
numberOfLanes | ROAD_LANES |
routeNumber | ROUTE_NUM |
routeType | ROUTE_TYPE |
type | ROAD_TYPE |
name | PARK_NAME |
name_alt | NAME_ALT |
STOPABBR | STOP_ABBR |
STOPNAME | STOP_NAME |
6.Set the Schema Definition in the Writer Feature Type
Open the Dynamic Writer feature type and set the table name to your attribute containing your new names.In the image below,the SpatiaLite database has been entered as the 'Schema Source'.Use the original fme_feature_type attribute for the 'Schema Definition Name' setting so that the Writer can find the table names inside the SpatiaLite database (If you don't do this,the writer will look for your concatenated name in the database and be unable to find the correct feature types):
7.Run the Workspace
Run and then check the output datasets have the correct schema.
最终的想法
At this stage,any future updates can be added to this 亚搏在线workflow without changing the existing workspace layout.As well,changes can be made to the database schema outside of the FME environment and the workspace can handle the new schema automatically.
Note: In the above example,if the database schema did change,a user would need to correct the AttributeManager transformer to provide the correct attribute mapping.however,using a SchemaMapper transformer in this scenario would provide an external method to handle any mapping issues,making workspace changes unnecessary.For complex 亚搏在线workflows,this is a perfect way to alleviate maintenance issues in the future.This is discussed further inAdvanced Technique - Using the SchemaMapper.
Full SchemaMapper tutorial can be found here:SchemaMapper Transformer Tutorial
Dynamic 亚搏在线Workflows: Advanced Example - Modifying the Schema Feature
Dynamic 亚搏在线Workflows: Destination Schema Derived from Multiple Sources
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 as a Mirror Image of the Source Dataset
Tutorial: Dynamic 亚搏在线Workflows
Dynamic 亚搏在线Workflows: Destination Schema is Derived from a Schema Feature
© 2019 亚搏在线Safe Software Inc |Legal