Vous êtes sur la page 1sur 9

XI - File Content Conversion

By Punit J, YASH PI Competency Team, Yash Technologies

Description: File Content Conversion is used to convert non-XML file (flat file) to XML file and vice-versa.
In this blog, we will see how to convert flat file to XML file when file structure is bit complex. For example,
when same columns shows different information in different rows.

Business Case: Let’s take an example with file shown below. The file contains employee details. First
row contains Header information of Employee (Employee ID and Name), Second and Third row contains
his weekly details (Week No, Working Hours in the Week and Wage for the Week), there can be n
number of rows for weekly details and Last row contains Employee Monthly Summary (Total hours
worked and Total Wage).

Screen shot

Find below the step-by-step procedure to achieve this scenario:

Development on Integration Repository side.

1. Create Data Type.


Here I have added a filed Key in all the records, we will discuss about this field while configuring Sender
File Adapter.

2. Create Message Type.


3) Create Message Interface for Sender and Receiver. In this scenario I am using same Message Type
for both Sender and Receiver as we are converting flat file to XML file.

4) Create Message Mapping.


Here we don’t have to map the field ‘Key’.

5. Create Interface Mapping.


Developments on Integration Directory.

1. Configuration of Sender File Adapter

Here specify Message Protocol as ‘File Content Conversion’.

Document Name and Namespace correspond to the message type from the Integration Repository.

Recordset Name defines the root node under which rest of the XML will be created.

Recordset Structure defines the name and occurrence of each sub-node in Recordset Structure. In
this example we have only one occurrence of sub-node Emp_Header and Emp_Summary and
unbounded occurrences of sub-node Emp_Weekly_Det.

Key Field Name and Key Field Type helps in differentiating different substructures. In this case Key
=1 implies Emp_Header node, Key = 2 implies Emp_Weekly_Det node and Key = 3 implies
Emp_Summary node.

Additional Parameters are given below.


 <node>.fieldFixedLengths – comma-separated ordered list of field lengths in the particular node
 <node>.endSeparator – identifies end of record
 <node>.fieldNames – comma-separated ordered list of field names in the particular node
 <node>.keyFieldValue – Value of the key field
 <node>.keyFieldInStructure – ‘ignore’ (without quotes) indicates that the Key field should not be
generated in the resulting XML whereas ‘add’ (without quotes) indicates that it should be added.

2. Configure Receiving File Adapter


3. Configure Receiver Agreement

4. Configure Sender Agreement.

5. Configure Interface Determination.


6. Configure Receiver Determination.

On Executing the Scenario we will get the output file in XML Format.