Table of Contents

Search

  1. Preface
  2. Transformations
  3. Source transformation
  4. Target transformation
  5. Access Policy transformation
  6. Aggregator transformation
  7. B2B transformation
  8. Cleanse transformation
  9. Data Masking transformation
  10. Data Services transformation
  11. Deduplicate transformation
  12. Expression transformation
  13. Filter transformation
  14. Hierarchy Builder transformation
  15. Hierarchy Parser transformation
  16. Hierarchy Processor transformation
  17. Input transformation
  18. Java transformation
  19. Java transformation API reference
  20. Joiner transformation
  21. Labeler transformation
  22. Lookup transformation
  23. Machine Learning transformation
  24. Mapplet transformation
  25. Normalizer transformation
  26. Output transformation
  27. Parse transformation
  28. Python transformation
  29. Rank transformation
  30. Router transformation
  31. Rule Specification transformation
  32. Sequence transformation
  33. Sorter transformation
  34. SQL transformation
  35. Structure Parser transformation
  36. Transaction Control transformation
  37. Union transformation
  38. Velocity transformation
  39. Verifier transformation
  40. Web Services transformation

Transformations

Transformations

Hierarchy Parser transformation example

Hierarchy Parser transformation example

You want to convert hierarchical data to relational data and write the data to a target file in a relational format.
You need to configure a hierarchical schema that uses a schema file to define the hierarchy of the input data.
The following example shows the schema hierarchy that you want to use:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.itemfield.com" targetNamespace="http://www.itemfield.com" elementFormDefault="qualified"> <xs:element name="root"> <xs:complexType> <xs:sequence> <xs:element name="Emp_Details" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="employee"> <xs:complexType> <xs:sequence> <xs:element name="Employeeid" type="xs:short"/> <xs:element name="Name"> <xs:complexType> <xs:sequence> <xs:element name="Firstname" type="xs:string"/> <xs:element name="Lastname" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="Dependents" minOccurs="1" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="address" minOccurs="0"> <xs:complexType> <xs:sequence> <xs:element name="Addressid" type="xs:byte"/> <xs:element name="Employeeid" type="xs:short"/> <xs:element name="Line1" type="xs:string"/> <xs:element name="Line2" type="xs:string"/> <xs:element name="City" type="xs:string"/> <xs:element name="State" type="xs:string"/> <xs:element name="Zipcode" type="xs:int"/> <xs:element name="Fromdate" type="xs:date"/> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> <xs:attribute name="EmpAttribute" type="xs:string"/> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:schema>
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:
The source object details show the the connection, type of source, and the input file.
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:
The Field Mapping tab shows the incoming fields that you can map to the Structure Parser input fields.
Add a file target object for the fields.
The following image shows the mapping:
The mapping shows the data flow from the SourceLogFile source to a Structure Parser transformation with name LogParser. The Structure Parser transformations is linked to the TargetFile target.
Run the mapping to write the data in a relational format to the Target transformation.
The following example shows the relational output:
EmpAttribute
Employeeid
Firstname
Lastname
Addressid
Employeeid1
Line1
Line2
string
1
Gina
Aniston
2
1
Long Tech Park
Industrial Zone
City
State
Zipcode
Fromdate
Wichita
KA
773301
9/29/2008 12:00:00 AM

0 COMMENTS

We’d like to hear from you!