csv to xml transformer

CSV to XML Transformer

Version: 17.07

Supported Since: 17.01

What is a CSV to XML Transformer?

A CSV to XML Transformer is a processing element which transforms a CSV message payload to an XML payload. This transformation is done based on a generic set of rules and hence this processing element is most suitable for simple transformations. For complex transformations based on custom rules, Adroitlogic Data Mapping Tool is recommended.

In order to use this processing element, you must first select the Message Transformation dependency from the processor list when you are creating an empty Ultra project. If you have already created a project, you can add this dependency via Component Registry. From Tools menu, select Ultra Studio → Component Registry and from the Processors list, select the Message Transformation dependency.

csv xml outports

Out Ports

Next

The message will be sent to this outport if the payload transformation is completed successfully

On Exception

The message will be sent to this outport if the processing element failed to transform the payload due to some reason

Parameters

Root element name *

Basic

This parameter will be used as the name of the root element of XML output.

Row element name *

Basic

This parameter will be used as the name of the element that encloses the elements of each row. For example refer the following sample CSV content.

id,"first name","last name","email",country
1,Jean,Murray,jmurray0@dailymail.co.uk,China
2,Mary,Sims,msims1@1688.com,China

Notice that in the following converted XML output, data for each row is enclosed inside a tag named row_element, which is the value of this parameter.

<?xml version="1.0" encoding="UTF-8"?>
<root_element xmlns="">
    <row_element>
        <id>1</id>
        <first_name>Jean</first_name>
        <last_name>Murray</last_name>
        <email>jmurray0@dailymail.co.uk</email>
        <country>China</country>
    </row_element>
    <row_element>
        <id>2</id>
        <first_name>Mary</first_name>
        <last_name>Sims</last_name>
        <email>msims1@1688.com</email>
        <country>China</country>
    </row_element>
</root_element>

Namespace prefix

Basic

Optional namespace prefix to be used for the XML output.

Namespace URI

Basic

Optional namespace URI for the XML output. If a value for the namespace prefix is specified, it is mandatory to specify a value for this parameter as well.

Allow single column *

Basic

Specifies whether to allow transforming single column CSV files. If this is set to true, the transformer will attempt to transform even the payloads that has been recognized to have only one CSV column. Otherwise the transformer will fail at such kind of payloads. The default value of this parameter is set to false.

Setting this parameter to true will make the transformer to attempt to convert non-CSV payloads as well. Therefore this value should not be set to true unless the user is really expecting single column CSV payloads.

Sample Use Case

In the following use case, the requirement is to read a message with a CSV payload from a SFTP server, convert the message payload to XML and then deliver it to another SFTP endpoint.

csv to xml flow
csv to xml config

In this flow, the "Processor" outport of SFTP ingress connector is connected to the inport of the CSV to XML Transformer so that the SFTP message received by the connector is handed over to the transformer next. If the processing element is able to transform the payload from CSV to XML successfully, the message with the transformed payload is handed over to the SFTP egress connector, as the "Next" outport of the CSV to XML Transformer is connected to it.

In the case of transformation failure, a log will be generated and then the message flow will complete in an exceptional state, as the "On Exception" outport of the CSV to XML Transformer is connected to a Logger processing element, followed by an Exceptional Flow End element.

In this topic
In this topic
Contact Us