The following example shows the input file data that you want to use:
<itm:root xmlns:itm="http://www.itemfield.com"> <!--Zero or more repetitions:--> <itm:Emp_Details EmpAttribute="string"> <itm:employee> <itm:Employeeid>1</itm:Employeeid> <itm:Name> <itm:Firstname>Gina</itm:Firstname> <itm:Lastname>Aniston</itm:Lastname> </itm:Name> <!--1 or more repetitions:--> <itm:Dependents>anyType</itm:Dependents> </itm:employee> <!--Optional:--> <itm:address> <itm:Addressid>2</itm:Addressid> <itm:Employeeid>1</itm:Employeeid> <itm:Line1>Long Tech Park</itm:Line1> <itm:Line2>Industrial Zone</itm:Line2> <itm:City>Wichita</itm:City> <itm:State>KA</itm:State> <itm:Zipcode>773301</itm:Zipcode> <itm:Fromdate>2011-09-29</itm:Fromdate> </itm:address> </itm:Emp_Details> </itm:root>
Create the hierarchical schema in Data Integration with the schema hierarchy that you want to use.
To parse the input data, use a Hierarchy Parser transformation in a mapping to transform the data from the hierarchical input. In the Mapping Designer, you add a source object that is flat file that contains the path to the data that you want to parse.
The following image shows the selected Source transformation:
You add an Hierarchy Parser transformation and use the name NewHierarchyParser. Configure it to use the hierarchical schema that you created.
You connect the source object to the NewHierarchyParser transformation. To map the incoming data to the fields of the transformation, select the NewHierarchyParser transformation. In the Input Field Selection tab, map the selected incoming field from the source transformation to the NewHierarchyParser hierarchical schema input field.
To map the data to relational fields, in the Field Mapping tab, select which schema elements are reflected as relational fields to the output.
The following image shows the field mapping selection:
Add a file target object for the fields.
The following image shows the mapping:
Run the mapping to write the data in a relational format to the Target transformation.
The following example shows the relational output: