tAdvancedFileOutputXML
Writes an XML file with separated data values according to an XML tree
structure.
tAdvancedFileOutputXML outputs data to an XML type of
file and offers an interface to deal with loop and group by elements if needed.
tAdvancedFileOutputXML Standard properties
These properties are used to configure tAdvancedFileOutputXML running in the Standard Job framework.
The Standard
tAdvancedFileOutputXML component belongs to the File and the XML families.
The component in this framework is available in all Talend
products.
Basic settings
Property type |
Either Built-in or Repository. |
 |
Built-in: No property data stored |
 |
Repository: Select the Repository |
Use Output Stream |
Select this check box process the data flow of interest. Once you The data flow to be processed must be added to the flow in order This variable could be already pre-defined in your Studio or In order to avoid the inconvenience of hand writing, you could For further information about how to use a stream, see Reading data from a remote file in streaming mode. |
File name |
Name or path to the output file and/or the variable to be used. This field becomes unavailable once you have selected the For further information about how to define and use a variable in |
Configure XML tree |
Opens the dedicated interface to help you set the XML mapping. For |
Schema and Edit |
A schema is a row description, it defines the number of fields Click Edit
|
 |
Built-in: The schema will be |
 |
Repository: The schema already |
Sync columns |
Click to synchronize the output file schema with the input file |
Append the source xml file |
Select this check box to add the new lines at the end of your |
Generate compact file |
Select this check box to generate a file that does not have any |
Include DTD or XSL |
Select this check box to to add the DOCTYPE declaration, |
Advanced settings
Split output in several files |
If the XML file output is big, you can split the file every |
Trim data |
This check box is activated when you are using the dom4j |
Create directory only if not exists |
This check box is selected by default. It creates a directory to |
Create empty element if needed |
This box is selected by default. If no column is associated to an |
Create attribute even if its value is NULL |
Select this check box to generate XML tag attribute for the |
Create attribute even if it is unmapped |
Select this check box to generate XML tag attribute for the |
Create associated XSD file |
If one of the XML elements is defined as a Namespace element, this Note:
To use this option, you must select Dom4J as the generation mode. |
Add Document type as node |
Select this check box to add column(s) of the Document type as node(s) instead of This check box appears only when the generation mode is set to |
Advanced separator (for number) |
Select this check box to change the expected data
Thousands separator: define the
Decimal separator: define the |
Generation mode |
Select the appropriate generation mode according to your memory
Once you select Append the source xml |
Encoding |
Select the encoding from the list or select Custom and define it |
Don’t generate empty file |
Select the check box to avoid the generation of an empty |
tStatCatcher Statistics |
Select the check box to collect the log data at a Job level as |
Global Variables
Global Variables |
ERROR_MESSAGE: the error message generated by the
NB_LINE: the number of rows processed. This is an After A Flow variable functions during the execution of a component while an After variable To fill up a field or expression with a variable, press Ctrl + For further information about variables, see |
Usage
Usage rule |
Use this component to write an XML file with data passed on from |
Defining the XML tree
Double-click on the tAdvancedFileOutputXML
component to open the dedicated interface or click on the three-dot button on the
Basic settings vertical tab of the Component Settings tab.
To the left of the mapping interface, under Schema
List, all of the columns retrieved from the incoming data flow are
listed (only if an input flow is connected to the tAdvancedFileOutputXML component).
To the right of the interface, define the XML structure you want to obtain as
output.
You can easily import the XML structure or create it manually, then map the input
schema columns onto each corresponding element of the XML tree.
Importing the XML tree
-
Rename the root tag that displays by
default on the XML tree panel, by
clicking on it once. - Right-click on the root tag to display the contextual menu.
-
On the menu, select Import XML
tree. -
Browse to the file to import and click OK.
-
You can import an XML tree from files in XML, XSD and
DTD formats. -
When importing an XML tree structure from an XSD
file, you can choose an element as the root of your XML tree.
The XML Tree column is hence automatically
filled out with the correct elements. -
- If you need to add or remove an element or sub-elements, right-click the relevant element of the tree to display the contextual menu.
-
Select Delete to remove the
selection from the tree or select the relevant option among: Add sub-element, Add
attribute, Add namespace
to enrich the tree.
Creating the XML tree manually
manually.
-
Rename the root tag that displays by
default on the XML tree panel, by
clicking on it once. - Right-click on the root tag to display the contextual menu.
-
On the menu, select Add sub-element to create the first element of the
structure. -
If you need to add an attribute or a child element to any element or
remove any element, right-click the left of the corresponding element name to display the contextual
menu. -
Right-click to the left of the element name to display the contextual
menu. -
On the menu, select the relevant option among: Add sub-element, Add
attribute, Add namespace
or Delete.
Mapping XML data
Once your XML tree is ready, you can map each input column with the relevant XML
tree element or sub-element to fill out the Related
Column.
-
Click on one of the Schema column
name. - Drag it onto the relevant sub-element to the right.
- Release to implement the actual mapping.
- If you need to disconnect any mapping on any element of the XML tree, select the element and right-click to the left of the element name to display the contextual menu.
- Select Disconnect linker.
Defining the node status
define the loop element and if required the group element.
Define a loop element
- Select the relevant element on the XML tree.
-
Right-click to the left of the element name to display the contextual
menu. - Select Set as Loop Element.
The Node Status column shows
the newly added status.
There can only be one loop element at a
time.
Define a group element
When using a group element, the rows should sorted, in order to be able to
group by the selected node.
To define an element as group element:
- Select the relevant element on the XML tree.
-
Right-click to the left of the element name to display the contextual
menu. - Select Set as Group Element.
The Node Status column shows the newly added
status and any group status required are automatically defined, if
needed.
Click OK once the mapping is complete to
validate the definition and continue the job configuration where needed.
Creating an XML file using a loop
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.Note: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.