Question

Using SchemaMapper to Map Data into an Existing Schema

  • 23 November 2012
  • 6 replies
  • 37 views

Userlevel 4
Badge +13
Hi,

 

I'm able to figure out how to map a single feature coming from one schema to an existing feature of another schema using the Schema Mapper tranformer.  The problem that I'm having is how to map the rest of the features using the same SchemaMapper transformer without having to create one for each feature that are within the two schemas. Here is schematic of what i'm trying to do.  Note that the Out feature already exist in the output schema. 

 

 

RoadL  ------------------------>  |                                |-------------------------> RoadL_Out

 

RiverL --------------------------> | SchemaMapper  |-------------------------> RiverL_Out

 

SandA  ------------------------>  |                                |------------------------->  SandL_Out

 

 

What's happening for me is that the total number of features from the incoming schema are being inserted into each of the output features.  That is, if the total number of the road (200), river (700) and sand (100) feature is 1000, then the transformer tries to write 1000 roads, 1000 rivers and 1000 sand features.

 

 

Many thanks,

 

Sam

 

 

                         

6 replies

Badge +21
And you have looked into the examples at: http://evangelism.safe.com/fmeevangelist41/ and also followed the two links at the bottom?

 

 

It seems you havent specified Feature-mapping, only attribute-mapping. But it is difficult to see unless you attach your SchemaMapper and Mapping-file
Userlevel 4
Badge +13
Thanks Sig,

 

 

 

Having you point me to a few otherbexamples that I hadn't seen yet, I noticed that although I had included the feature mapping (that you were inquiring about) I did not have the feature filter after my SchemaMapper transformer. Once I included the feature filter, it all worked. 

 

 

Since I have your undevided  attention, would you happen to know how to handle/map NULL attribute values?  For example, how would I set up the spreadsheet that the SchemaMapper points to the mapping of a NULL attribute value for HYC to a value of 1 for the outgoing HYC_OUT attribute?

 

 

Again many thanks for your quick response. 

 

 

Sam
Badge +21
In general Schemamapping is one of the difficult things, but also most usefull in FME! So practicing it alot is well worth it!

 

 

So you want something like this?:

 

 

 

InputFeature:

 

Attribute: HYC = NULL

 

 

OutputFeature:

 

Attribute: HYC_OUT = 1 (if HYC = NULL in input)

 

 

If you always want to add a Default Value (when no value is present) you can add a colum.

 

 

More information is here (if you havent read already), just search for "default value" and it should give you additional info : http://evangelism.safe.com/fmeevangelist46/

 

 

 

 

 

Userlevel 4
Badge +13
Hi Sig,

 

 

Here is an extra of my mapping spreadsheet.  

 

 

Source_Attribute    Source_Value    Target_Attribute   Target_Value    

 

TUC                                  4                          TYP                 3    

 

TUC                                  2                           TYP               41    

 

TUC                                 NOT  IN (4,2)         TYP                -999999

 

                                        OR  IN (0,3)

 

                                        OR  IS NULL                    

 

 

From my few tests, I found that the transformer accepts the values referenced in the NOT IN operator, but ignores everything after.  

 

 

Thanks again,

 

Sam
Re: "how to handle/map NULL attribute values?"

 

You could place an "NullAttributeReplacer" transformer ahead of the schema-mapper, and set the null values to something that you know would never appear in your data, like "__Null__" or somthing like that. Then enter that value in your schema-mapper file with the resulting mapped value that you would like it to place instead. I could send you an example if you still need more details.
Userlevel 4
Badge +13
Thanks Vic, no need to send an example yet. I think I can figure it out from what you told me.  

 

Cheers,

 

Sam

Reply