Table of Contents

Search

  1. Preface
  2. Transformations
  3. Source transformation
  4. Target transformation
  5. Access Policy transformation
  6. B2B transformation
  7. Aggregator 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 Generator 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 Builder transformation example

Hierarchy Builder transformation example

You want to convert relational data to hierarchical data and write the data to a target file in a hierarchical format.
To use the Hierarchy Builder transformation to convert the data, complete the following steps:
  1. Create a hierarchical schema.
  2. Create a mapping.
  3. Configure the Hierarchy Builder transformation.
  4. Configure the target.
  5. Run the mapping.

Step 1. Create a hierarchical schema

You need to configure a hierarchical schema that uses a schema file to define the hierarchy of the output data.
The following example shows the schema hierarchy that you want to use:
<?xml version="1.0" encoding="UTF-8"?> <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="Employees"> <xs:complexType> <xs:sequence> <xs:element name="Name" type="xs:string" minOccurs="0"/> <xs:element name="Address" type="xs:string" minOccurs="0" maxOccurs="unbounded"/> <xs:element name="Employee" minOccurs="1" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="EmployeeID" type="xs:string" minOccurs="0"/> <xs:element name="Department" type="xs:string" minOccurs="0"/> <xs:element name="Subdivision" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="Building" type="xs:string" minOccurs="0"/> <xs:element name="Room" type="xs:string" minOccurs="0" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:schema>
The following example shows the first input file data that you want to use:
CompanyName,Address First National Bank,874 Louis Road Jackson Industry,13 Sydney Drive
The following example shows the second input file data that you want to use:
Name,EmployeeID,Department,Building,Room First National Bank,122,Credit,6,1532 First National Bank,261,Credit,6,2251 First National Bank,431,Credit,6,5312 Jackson Industry,3875,Manufacture,C,673 Jackson Industry,2837,Manufacture,B,211
Create the hierarchical schema in
Data Integration
with the schema hierarchy that you want to use.

Step 2. Create a mapping

To parse the input data, use a Hierarchy Builder transformation in a mapping to transform the data from the hierarchical input.
In the Mapping Designer, you add two source objects that are flat files that contain the paths to the data files that you want to parse. The following image shows one of the Source transformations:
The source object details show the the connection, type of source, and the input file.

Step 3. Configure the Hierarchy Builder transformation

You add an Hierarchy Builder transformation and use the name NewHierarchyBuilder. Configure it to use the hierarchical schema that you created.
You connect the source objects to the NewHierarchyBuilder transformation. To map the incoming data to the fields of the transformation, select the NewHierarchyBuilder transformation. In the
Incoming Fields
tab, ensure that there are no field name conflicts. The following image shows the input field selection:
The Field Mapping tab shows the incoming fields that you can map to the Structure Parser input fields.
To map the relational fields to the hierarchical output, in the
Field Mapping
tab, select primary and foreign keys. Then select which relational fields are linked to schema elements for the hierarchical output.
The following image shows the field mapping selection:

Step 4. Configure the target

Add a file target object for the fields.
The following image shows the final 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.

Step 5. Run the mapping

Run the mapping to write the data in a hierarchical format to the Target transformation.
The following example shows the hierarchical output:
<Employees> <Name>First National Bank</Name> <Address>874 Louis Road</Address> <Employee> <EmployeeID>122</EmployeeID> <Department>Credit</Department> <Subdivision> <Building>6</Building> <Room>1532</Room> </Subdivision> </Employee> <Employee> <EmployeeID>261</EmployeeID> <Department>Credit</Department> <Subdivision> <Building>6</Building> <Room>2251</Room> </Subdivision> </Employee> <Employee> <EmployeeID>431</EmployeeID> <Department>Credit</Department> <Subdivision> <Building>6</Building> <Room>5312</Room> </Subdivision> </Employee> </Employees> <Employees> <Name>Jackson Industry</Name> <Address>13 Sydney Drive</Address> <Employee> <EmployeeID>3875</EmployeeID> <Department>Manufacture</Department> <Subdivision> <Building>C</Building> <Room>673</Room> </Subdivision> </Employee> <Employee> <EmployeeID>2837</EmployeeID> <Department>Manufacture</Department> <Subdivision> <Building>B</Building> <Room>211</Room> </Subdivision> </Employee> </Employees>

0 COMMENTS

We’d like to hear from you!