The Text2XML component transforms data from any flat file format to XML format. This component accepts data in Text (Delimited, Positional or both) format and transforms it into the required XML format.
Configuration and Testing
Managed Connection Factory
Figure 1: Managed Connection Factory Panel
Attributes
Flat Format Schema content
Flat Format Schema Content (TFL file), which describes the conversion rules has to be specified here. The TFL schema file can be provided using 'Flat Format Schema Content editor' which opens up on clicking ellipsis button against this property.
Figure 2: Flat Format Schema Content editor
Connection Pool Params
Please refer Connection Pool Params section in Common Configurations page.
Interaction Configuration
Figure 3: Interaction Configurations Panel
Attributes
Enable dos2unix conversion?
This property should be used when CRLF (0D0A) should be converted to LF (0A) before processing the input message. New line is treated as CRLF (0D0A) in Windows and LF (0A) in Unix.
If the TFL file contains delimiter as new line character and whether the flat file is generated in Windows or Unix is not known, this property should be set to 'yes'. If this property is set to 'yes', the component converts all CRLF's to LF's in the input flat file and TFL file and then it applies the conversion rules specified in the TFL file.
The transformation may be tested by clicking the Test button in the Interaction Configuration panel. Sample message is generated depending on the Flat Format schema provided in the Managed Connection Factory panel.
First Line as Field Names?
Enable this to consider the first line as the name of fields.
File Encoding
Figure 4: File Encoding standard options
The encoding to be used while reading the file.
- ASCII
A coding standard used to represent plain text. It is based on English Alphabetical order.
- Cp1252
This is a character encoding for the Latin alphabet.
- EUC_KR
- EUC_JP
- EUC_CN
EUC_TW
EUC_KR, EUC_JP, EUC_CN, EUC_TW are multi-byte character encoding systems used for Korean, Japanese, Simplified Chinese, and Traditional Chinese languages respectively.ISO8859_1
ISO 8859-1, more formally cited as ISO/IEC 8859-1 is part 1 of ISO/IEC 8859, a standard character encoding of the Latin alphabet.- SJIS
A character encoding for the Japanese language. - UTF8
A variable-length character encoding for Unicode - UTF-16
This too is a variable-length character encoding for Unicode. The encoding form maps each character to a sequence of 16-bit words.
Read input from file?
Choose this option to read input from a file instead of the component input port.
Figure 5: Read input from file property options
Source Directoryname
Directory where the input file is located.
Source Filename
Name of the input file.
Write output to file?
Writes the output XML to the specified file in the target directory.
Figure 6: Write output to file property options
isFilenameFromHeader
If enabled, the target filename and target directory values will be taken from the header of the input message.
Target Directoryname
Directory where output file needs to be stored.
Target Filename
Name with which the output file needs to be saved.
Action if Same file exists
The action that must be taken if the target directory already has a file with the same name as the file that has to be uploaded. The behavior will be dependent on the selection as shown below:
OVERWRITE
The file to be uploaded overwrites the one in the target directory.RENAME
The name of the file that is being uploaded is changed based on the properties given below:
Figure 7: Action if Same file exists property options- Append date-time format postfix: When existing files in the Target directory are not to be overwritten, FTPPut provides the flexibility of uploading the content into a new file whose name is in the format <NameOfExistingFile_CurrentDateTime>. The format in which the date and time are to be appended should be specified as a value for this property.
Example: If the date-time format is specified as MMddyyyyHHmmssss for the file Sample.txt, the target file created would be Sample_0305200811300013.txt. - Append counter: Enabling this property appends a counter along with the Date and Time to target file name when the target file is not to be overwritten.
Example: A sample file name could be Sample_0305200811300013_0.txt.
- Append date-time format postfix: When existing files in the Target directory are not to be overwritten, FTPPut provides the flexibility of uploading the content into a new file whose name is in the format <NameOfExistingFile_CurrentDateTime>. The format in which the date and time are to be appended should be specified as a value for this property.
Expert Properties
These are the attributes meant for advanced users.
Figure 8: Interaction configuration panel with the Expert Properties highlighted
Elements to Encrypt
Select the elements to encrypt in output. Elements in the Input Message will be decrypted and those in Output Message will be encrypted.
Scheduler Configurations
Please refer to the respective section in Common Configurations page.
Transport Configurations
Please refer the respective section in Common Configurations page.
Error Handling
Please refer the sections Request Processing Error, Connection Error and Invalid Request Error in the Error Handling section of Common Configurations page for details.
Testing
Schema
Sample CSV File Format Schema is shown in the figure below.
Figure 9: Sample CSV File Format Schema
The structure of the schema is shown in the figure below. Sample schema contains Employee records and each record contains EmployeeName, EmployeeID and EmployeeAge fields. This sample schema has Record Delimiter CRLF and Field Delimiter comma (,).
Figure 10: Structure of Sample CSV File Format Schema
Sample Input
Sample Input contains CSV formatted Employee Records, which are separated by a new line character and the fields are separated by commas. Sample Input is shown in the figure below.
Figure 11: Sample Input
Output
Ouput generated for the sample input is shown in the figure below. The output XML structure is the same as the structure of CSV File Format Schema.
Figure 12: Sample Output
Functional Demonstration
Scenario 1
The scenario demonstrates the transformation of comma-separated values into XML.
Configure the Text2XML component as described in Configuration and Testing section and use Feeder and Display components to send sample input and check response respectively. CSV File Format Schema is used in this scenario.
Figure 13: Demonstrating Scenario 1 with sample input and output
Use Case Scenario
In Bond Trading sample event process, Text2XML component is used to convert the data from CSV format to XML format.
The event process demonstrating this scenario is bundled with the installer. Documentation of the scenario and instructions to run the flow can be found in the Help tab of the flow in eStudio.
Useful Tips
Please refer Flat File Schema Editor section for the documentation related to creating the Text Format Layout (TFL) files.