span8
span4
span8
span4
Note: If you are using FME 2015.1 or below,please see:Destination Schema Derived from List Attributes (2015.0 and below)
This type of 亚搏在线workflow creates an attribute schema within a workspace using List Attributes.List Attributes are FME's way of allowing multiple values within a single attribute.Writers in Dynamic mode check the first feature of each incoming Feature Type for the presence of a specific list attribute.If this list is found on the first feature,then it is used to generate the output schema for the Writer.
In this example,a workspace is created to handle city park information.The requirement is to translate any city park dataset into a new MapInfo tab file with a new schema.This new schema should only consist of park name information while everything else is to be removed.If a standard dynamic workspace was utilized,the output schema would mirror the input dataset,which is not what is needed in this case.
As of FME 2015.1,the FeatureReader can now generate this list using a special ‘Schema' output port.As well,the AttributePivoter transformer,SchemaSetter transformer and a special Reader named "Schema (any format)" can all create the Schema list.
Note:It is highly recommended that you use these tools to generate the schema for you.See the advanced examples below.
To explain this concept,the following is a simplified example.The example will show the different components of the schema feature using simple attribute transformers to create it from scratch.
A simple attribute{} list:
The list elements are formatted as follows:
List Name:
Each element within the list has 2 components:
For example: attribute{}.name and attribute{}.fme_data_type
Valid FME data types include:
Type | Fields |
Character | fme_varchar(width),fme_char(width),fme_char |
Integer | fme_uint8,fme_int16,fme_uint16,fme_int32,fme_uint32,fme_int64,fme_uint64 |
Numeric | fme_decimal(width,decimal),fme_real32,fme_real64 |
Date-Time | fme_datetime,fme_time,fme_date |
Other | fme_buffer,fme_boolean |
Using Format Specific Data Types
If you wish to use format specific data types for the attributes (i.e.non FME data types),include two more attributes:
Attribute | Description |
fme_format_short_name | Format for which that type belongs,using theshort format name. |
attribute{0}.native_data_type | Format specific data type. |
Example:
fme_format_short_name = "GEODATABASE_FILE"attribute{0}.name = "myAttribute"attribute{0}.fme_data_type = "fme_buffer"attribute{0}.native_data_type = "guid"
The outcome will be a new Geodatabase FeatureClass containing an attribute ‘myAttribute' of data type "guid".
Adding Geometry:if you are working with a format that requires a specific geometry for each feature type (Shape,Geodatabase) then you need to define the geometry type.This is done with the
Attribute | Description |
fme_geometry{} |
Format for which Geometry belongs,you can define more than one geometry if needed. |
For example:
fme_geometry{0}.fme_point
would define a point geometry feature class for Geodatabase
Note:When generating your own list as shown above,you should merge it onto your data so that the writer gets both the schema and the data when the first feature enters it.
1.Add Reader to a blank workspace
2.Define a new schema
Using an AttributeCreator,define the new schema.
Attribute Name | Value |
attribute{0}.name | PARK_NAME |
attribute{0}.fme_data_type | fme_varchar(20) |
attribute{1}.name | NAME_ALT |
attribute{1}.fme_data_type | fme_varchar(20) |
3.Setup schema mapping
Add an AttributeManager and change the names of the three attributes to match the database schema.
4.Add a Dynamic Writer
Add a writer to the workspace
Once the writer is added to the workspace,connect it to the AttributeCreator and open up the parameters.Change the Schema Source to be "Schema From Schema Feature".
Run the workspace and inspect the results.
In the following example,a spatial query is performed on data that is being read into a workspace by the FeatureReader.The output schema is specified by using List Attributes that are generated by the FeatureReader transformer itself.In these scenario's,List Attributes are the best option is to define your schema as this information is not known until the workspace is run.As of FME 2015.1,the FeatureReader contains a schema output port for this purpose.
See this article for a full example:Extracting data within a clipping polygon
This article takes a deeper look at the schema feature and how to edit it within a workspace.
See:Modifying the Schema Feature
Geometry Error:
If there is a Geometry Not Specified error when using this technique,try setting the attribute: fme_geometry{0} =
Avoiding Dropped Features - FeatureReader:
If using the FeatureReader to create a schema feature,please note that the transformer adds a special attribute and value:
fme_schema_handling = ‘schema only'
This attribute tells the writer to use that feature as a schema and then remove it from the output.This can be an issue if you do anymerging of data and schemain the workspace as the data merged with this schema feature would be dropped when written.For example,if you merge a schema feature so that it gets added to all the features in the workspace.
To ensure this doesn't occur,remove the fme_schema_handling attribute entirely so that the first merged data feature is not dropped by the writer.
@brianat亚搏在线safeWhen using this 亚搏在线workflow,I run into a couple issues where FME colors all the imported attributes red:
1.For the first values in the list pair,I populated an Excel spreadsheet with values like below,so that I don't have to manually type them in to the AttributeCreator:
fme attribute name new attr name | fme attribute name new attr value | fme data type attr name | fme data type attr value |
attribute{2}.name | API_10 | attribute{2}.fme_data_type | fme_varchar(10) |
attribute{20}.name | FORMATION_AT_TD_NAME | attribute{20}.fme_data_type | fme_varchar(60) |
2.For the second values in the list pair,I
However,for this second item in the pair,FME Workbench also colors all the values red.
To resolve,I click in each attribute name's cell inside AttributeCreator,then click Enter,and the issue is resolved.
Hope this is easy enough to understand and helps someone!
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 Contains Different Feature Type Names
Dynamic 亚搏在线Workflows: Destination Schema as a Mirror Image of the Source Dataset
Tutorial: Dynamic 亚搏在线Workflows
Dynamic 亚搏在线Workflows (2015.0 and below): Destination Schema is Derived from List Attributes
© 2019 亚搏在线Safe Software Inc |Legal