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. Chunking transformation
  9. Cleanse transformation
  10. Data Masking transformation
  11. Data Services transformation
  12. Deduplicate transformation
  13. Expression transformation
  14. Filter transformation
  15. Hierarchy Builder transformation
  16. Hierarchy Parser transformation
  17. Hierarchy Processor transformation
  18. Input transformation
  19. Java transformation
  20. Java transformation API reference
  21. Joiner transformation
  22. Labeler transformation
  23. Lookup transformation
  24. Machine Learning transformation
  25. Mapplet transformation
  26. Normalizer transformation
  27. Output transformation
  28. Parse transformation
  29. Python transformation
  30. Rank transformation
  31. Router transformation
  32. Rule Specification transformation
  33. Sequence transformation
  34. Sorter transformation
  35. SQL transformation
  36. Structure Parser transformation
  37. Transaction Control transformation
  38. Union transformation
  39. Vector Embedding transformation
  40. Velocity transformation
  41. Verifier transformation
  42. 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

Back to Top

0 COMMENTS

We’d like to hear from you!