Question

1 reader to multiple writers based on external XML?

  • 14 November 2013
  • 7 replies
  • 1 view

Badge
Hello all,

 

 

I have the following database:

 

 

Table_source

 

ID,CATEGORY,TYPE,REMARK

 

1,TEST,TYPE 1,NO REMARK

 

 

What I need to do is export this to 2 XML files

 

Table_export_1

 

ID,CATEGORY

 

1,TEST

 

 

Table_export_2

 

ID,TYPE,REMARK

 

1,TYPE 1,NO REMARK

 

 

The problem is that I can't find how to do this, I've tried with a SchemaMapper, but I always get a 1:1 result instead of a 1:n result.

 

 

Can anyone help me out?

 

 

Thanks in advance.

7 replies

Badge
Ack, sorry messed up on the topic. 

 

 

It has be based on an external Excel or CSV, and the output should be multiple XML files.
Userlevel 2
Badge +17
Hi,

 

 

How about using two writers? Just branch the feature flow into two streams, and make each writer write required attributes only.

 

 

Takashi
Userlevel 4
Badge +13
Hi,

 

 

Yes Takashi's suggestion is the easiest and most efficient, its just a matter of removing/keeping the correspoinding attribues.

 

 

Itay
Badge
The thing is, the writers are dynamic. If I add a field in the mapping Excel, I want it to be mapped to the desired XML, and to be added as an attribute.
Userlevel 4
Badge +13
Have you tried adding the xls as a resource and use it in the writer dynamic schema definition?
Userlevel 2
Badge +17
The approaches I can think of are:

 

 

1. Create custom formats to extract schema subsets. Dynamic schema partial merge from 2 data sources http://fmepedia.safe.com/AnswersQuestionDetail?id=906a0000000cokTAAQ Extracting a schema subset for dynamic schemas http://fmepedia.safe.com/articles/How_To/Extracting-a-schema-subset-for-dynamic-schemas   2. Create tables defining schemas and use them as resources (similar to Itay's suggestion). Schema from Details Contained Within a Dataset (Example 3) in Dynamic Schema Examples http://fmepedia.safe.com/articles/Samples_and_Demos/Dynamic-Schema-Examples-FME2011   By the way, how do you determine which writer should be used to write the added attribute?
Badge

My idea was to use an Excel file with the mapping:

 

 

Source_feature,Target_feature,attribute,attribute_type

 

Table_source,Table_export_1,ID,fme_decimal(10,0)

 

Table_source,Table_export_1,CATEGORY,fme_varchar(30)

 

Table_source,Table_export_2,ID,fme_decimal(10,0)

 

Table_source,Table_export_2,TYPE,fme_varchar(30)

 

Table_source,Table_export_2,REMARK,fme_varchar(50)

 

 

Thus mapping the features and attributes. I don't have access to the target XML files, so I can't use them as a template. If the Excel changes, I'll receive a new one and I'll have to run the FME script again.

Reply