XML File Destination¶
Centerprise XML/JSON File Destination provides the functionality to write data to an XML or JSON File when the data source is hierarchical.
Use Case Scenario¶
In order to understand the application of the XML/JSON File Destination in a hierarchical format, we will take help of a use case to see how it works.
In this case two source objects will be used with a transformation that will become a hierarchical source that can then be written to an XML/JSON Destination file.
Two Database Source tables; Customers and Orders sample tables will be used as the source objects, and will be joined through the TreeJoin Transformation to create a hierarchical format through its collection object properties. There is a detailed article to further understand how the Treejoin Transformation works.
Here, the Customers and Orders sample tables have been joined in collection nodes through the Treejoin Transformation to put them in a hierarchical structure format, which has then been mapped to the XmlJsonDest object.
This case study will be referred to understand how the XML/JSON Destination object works.
Configuring the XML/JSON File Destination Object¶
- To get an XML/JSON File Destination object from the Toolbox, go to Toolbox > Destinations > XML/JSON File Destination. If you’re unable to see the toolbox, go to View > Toolbox or press Ctrl + Alt + X.
- Drag-and-drop the XML/JSON File Destination object onto the designer.
The dragged destination object is empty right now. This is because the object has not been configured yet.
For the XML/JSON File Destination object to work, it needs to be provided with a data source.
Place the XML/JSON File Destination object right next to the data source object.
Note: In this case we’ll be using the use case discussed earlier, taking the Treejoin as the source for data to write to the XML/JSON File Destination.
Creating a Schema File¶
In order to write to an XML/JSON file destination, an XML Schema file is needed of the source layout.
To create an XML schema file, right click on the source object (Treejoin transformation in this case), a context menu will appear, select the option Generate XML Schema for layout.
It will now open a new dialog box where it will ask for a location path to save the XML Schema file. Give the File Name for the schema file and click Save.
The schema file has been created on the location that was specified. To view the file, go to the file location and open the file in Centerprise.
- The opened file would look like the one below:
To configure the XML/JSON File Destination object, right-click on the header and select Properties from the context menu.
A dialog box will open - Destination XML File screen. Specify the File Locations; File Path and Schema File for the XmlJsonDest object.
The destination file will now be saved to the file location provided. Click OK, to map the destination object to the source object before further configuration.
The XmlJsonDest object will now have the layout of the source object (Treejoin Transformation in this case).
To map the source object to the destination object, the following ways can be used for mapping:
By dragging and dropping the parent node of the source object (TreeJoin node in the TreeJoin table) onto the child node of the destination object (TreeJoin node in the XmlJsonDest object) for automatic mapping.
By manually mapping the source parent node (TreeJoin in the TreeJoin table) by dragging it to the respective destination child node (TreeJoin in the XmlJsonDest object).
The fields are now mapped.
Once the file locations have been specified and the mappings have been done, further properties can be defined.
- The next screen after the Destination XML File Screen is the XML Layout screen.
- The screen shows the XML layout for the XmlJsonDest object. The collection nodes for the object can be seen on this screen with their fields.
Click Next a new screen -Config Parameters will open, which allows to further configure and define parameters for the XML/JSON Destination.
Parameters can provide easier deployment of flows by eliminating hardcoded values and provide an easier way of changing multiple configurations with a simple value change.
Note: Parameters left blank will use their default values assigned on the properties page.
Click Next a new screen -General Options will open. On this screen:
Comments can be added.
General Options are given, which relate to processing of records in the destination file.
The XmlJsonDest object has been successfully configured and the destination file can now be created by running the dataflow.