tWriteXMLField
of the output XML file.
tWriteXMLField Standard properties
These properties are used to configure tWriteXMLField running in the Standard Job framework.
The Standard
tWriteXMLField component belongs to the XML family.
The component in this framework is available in all Talend
products.
Basic settings
Output Column |
Select the destination field in the output component where you |
Configure XML Tree |
Opens the interface that supports the creation of the XML |
Schema and Edit |
A schema is a row description, it defines the number of fields that will be processed Click Edit
|
 |
Built-in: You create the schema |
 |
Repository: You already created |
Sync columns |
Click to synchronize the output file schema with the input file |
Group by |
Define the aggregation set, the columns you want to use to regroup |
Advanced settings
Remove the XML declaration |
Select this check box if you do not want to include the XML |
Create empty element if needed |
This check box is selected by default. If the Related Column in the XML tree editor has |
Expand Empty Element if needed(for dom4j) |
Select this option to allow a null element to appear in the form Note: To use this option, you must select the Dom4J generation mode.
Available when Create empty element if needed is selected. |
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 the Dom4J generation mode.
|
Advanced separator (for number) |
Select this check box if you want to modify the separators used by
Thousands separator: enter between
Decimal separator: enter between |
Generation mode |
Select the appropriate generation mode according to your memory
|
Encoding |
Select the encoding type in the list or select Custom and define it manually. This field |
tStatCatcher Statistics |
Select this check box to gather the Job processing metadata at a |
Global Variables
Global Variables |
ERROR_MESSAGE: the error message generated by the
NB_LINE: the number of rows read by an input component or 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 |
This component can be used as intermediate step in a data |
Extracting the structure of an XML file and inserting it into the fields of
a database table
and finally outputs the structure to the fields of a database table.
Procedure
-
Drop the following components from the Palette onto the design workspace: tFileInputXml, tWriteXMLField,
and tMysqlOutput.Connect the three components using Main
links. -
Double-click tFileInputXml to open its
Basic settings view and define its
properties. -
If you have already stored the input schema in the Repository tree view, select Repository first from the Property
Type list and then from the Schema list to display the Repository
Content dialog box where you can select the relevant metadata.For more information about storing schema metadata in
the Repository tree view, see
Talend Studio User
Guide. -
If you have not stored the input schema locally, select Built-in in the Property Type
and Schema fields and fill in the fields that
follow manually. For more information about tFileInputXML properties, see tFileInputXML.If you have selected Built-in, click the
three-dot button next to the Edit schema field
to open a dialog box where you can manually define the structure of your
file. -
In the Look Xpath query field, enter the node
of the structure where the loop is based. In this example, the loop is based on
the customer node. Column
in the Mapping table will be automatically
populated with the defined file content.In the Xpath query column, enter between
inverted commas the node of the XML file that holds the data corresponding to
each of the Column fields. -
In the design workspace, click tWriteXMLField
and then in the Component view,
click Basic settings to open the relevant view
where you can define the component properties. -
Click the three-dot button next to the Edit
schema field to open a dialog box where you can add a line by
clicking the plus button. -
Click in the line and enter the name of the output column where you want to
write the XML content, CustomerDetails in this example.Define the type and length in the corresponding fields,
String and 255in this example.Click Ok to validate your output schema and
close the dialog box.In the Basic settings view and from the
Output Column list, select the column you
already defined where you want to write the XML content. -
Click the three-dot button next to Configure Xml
Tree to open the interface that helps to create the XML
structure. -
In the Link Target area, click
rootTag and rename it as
CustomerDetails.In the Linker source area, drop
CustomerName and CustomerAddress
to CustomerDetails. A dialog box displays asking what type
of operation you want to do.Select Create as sub-element of target node
to create a sub-element of the CustomerDetails node.Right-click CustomerName and select from the contextual
menu Set As Loop Element.Click OK to validate the XML structure you
defined. -
Double-click tMysqlOutput to open its
Basic settings view and define its
properties. -
If you have already stored the schema in the DB
Connection node in the Repository tree view, select Repository from the Schema list
to display the Repository Content dialog box
where you can select the relevant metadata.For more information about storing schema metadata in
the Repository tree view, see
Talend Studio User
Guide.If you have not stored the schema locally, select Built-in in the Property Type
and Schema fields and enter the database
connection and data structure information manually. For more information about
tMysqlOutput properties, see tMysqlOutput.In the Table field, enter the name of the
database table to be created, where you want to write the extracted XML
data.From the Action on table list, select
Create table to create the defined
table.From the Action on data list, select Insert
to write the data.Click Sync columns to retrieve the schema
from the preceding component. You can click the three-dot button next to
Edit schema to view the schema. -
Save your Job and click F6 to execute it.
tWriteXMLField fills every field of the
CustomerDetails column with the XML structure of the input
file: the XML processing instruction <?xml version=""1.0""
, the first node that separates each client
encoding=""ISO-8859-15""?>
<CustomerDetails>
and finally customer information
<CustomerAddress>
and <CustomerName>
.