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