Table of Contents

Search

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