The following scenario describes the creation of an XML file from a sorted flat file gathering a video collection.
Configuring the source file
Drop a tFileInputDelimited and a tAdvancedFileOutputXML from the Palette onto the design workspace.
Alternatively, if you configured a description for the input delimited file in the Metadata area of the Repository, then you can directly drag & drop the metadata entry onto the editor, to set up automatically the input flow.
Right-click on the input component and drag a row main link towards the tAdvancedFileOutputXML component to implement a connection.
Select the tFileInputDelimited component and display the Component settings tab located in the tab system at the bottom of the Studio.
Select the Property type, according to whether you stored the file description in the Repository or not. If you dragged & dropped the component directly from the Metadata, no changes to the setting should be needed.
If you didn't setup the file description in the Repository, then select Built-in and manually fill out the fields displayed on the Basic settings vertical tab.
The input file contains the following type of columns separated by semi-colons: id, name, category, year, language, director and cast.
In this simple use case, the Cast field gathers different values and the id increments when changing movie.
If needed, define the tFileDelimitedInput schema according to the file structure.
Once you checked that the schema of the input file meets your expectation, click on OK to validate.
Configuring the XML output and mapping
Then select the tAdvancedFileOutputXML component and click on the Component settings tab to configure the basic settings as well as the mapping. Note that a double-click on the component will open directly the mapping interface.
In the File Name field, browse to the file to be written if it exists or type in the path and file name that needs to be created for the output.
By default, the schema (file description) is automatically propagated from the input flow. But you can edit it if you need.
Then click on the three-dot button or double-click on the tAdvancedFileOutputXML component on the design workspace to open the dedicated mapping editor.
To the left of the interface, are listed the columns from the input file description.
To the right of the interface, set the XML tree panel to reflect the expected XML structure output.
You can create the structure node by node. For more information about the manual creation of an XML tree, see Defining the XML tree.
In this example, an XML template is used to populate the XML tree automatically.
Right-click on the root tag displaying by default and select Import XML tree at the end of the contextual menu options.
Browse to the XML file to be imported and click OK to validate the import operation.
You can import an XML tree from files in XML, XSD and DTD formats.
Then drag & drop each column name from the Schema List to the matching (or relevant) XML tree elements as described in Mapping XML data.
The mapping is shown as blue links between the left and right panels.
Finally, define the node status where the loop should take place. In this use case, the Cast being the changing element on which the iteration should operate, this element will be the loop element.
Right-click on the Cast element on the XML tree, and select Set as loop element.
To group by movie, this use case needs also a group element to be defined.
Right-click on the Movie parent node of the XML tree, and select Set as group element.
The newly defined node status show on the corresponding element lines.
Click OK to validate the configuration.
Press F6 to execute the Job.
The output XML file shows the structure as defined.