All Collections
Components
Template Transformer
Template Transformer

Know the component and how to use it.

Erick Rubiales avatar
Written by Erick Rubiales
Updated over a week ago

IMPORTANT: This documentation has been discontinued. Read the updated Template Transformer documentation on our new documentation portal.

Template Transformer generates XML, HTML, text and other data from a specified template. The component can receive data to dynamically fill the template from a JSON received in its input message.

Take a look at the configuration parameters of the component:

  • Model Path: path in which the input JSON finds the models to be used in the template (dotted notation).

  • Preserve Original: if activated, the option preserves the original fields received in the component input.

  • Body: the template (string) to be replaced and transformed during the execution time with the received data, via JSON, configured in the Model Path property.

Messages Flow

To understand better how to use the Template Transformer, click here to read our article with illustrated examples.

Request answer example to Template Transformer with error

{
"body": null,
"_error": "Can not construct instance of java.util.LinkedHashMap: no String-argument constructor/factory method to deserialize from String value ('')\n at [Source: N/A; line: -1, column: -1]",
"_body": ""
}

  • body: transformed template

  • _error: description of the error occurred in the deployment

  • _body: if the option Preserve Original is enabled, the property will be shown in the output containing the input JSON

Input

This component accepts to receive a JSON object in its input, using a language called Freemarker to make the transformations and generate the template. It will search the JSON to be used inside the Model Path configuration property.

Output

The structure will be equivalent to the one in the input, but with another model and another template representation as string. In case of error, the "error" property will be created in the same level as the original property.

The JSON dotted notation will look for the root element that is being processed by the pipeline and cross it according to the specifications given in the Model Path property.

Template Transformer in Action

In a Model Path representation containing a.b.c.d, "a" will be searched in the root element. Afterwards, it will be "b", then "c" and finally "d". If an array is found during the cross, then the algorithm will generate a cross path for each element of the array. The algorithm replaces all the occurrences of the defined path in Model Path.

without error

{
"body": "TRANSFORMED TEMPLATE"
"_body": {}
}

  • _body: if the option Preserve Original is enabled, the property will be shown in the output containing the input JSON

with error

{
"body": null,
"_error": "Can not construct instance of java.util.LinkedHashMap: no String-argument constructor/factory method to deserialize from String value ('')\n at [Source: N/A; line: -1, column: -1]",
"_body": ""
}

Technology

We use Freemarker to make our convertions and transformations in the template inside this component. To know more about Freemaker and how to use it, click here.

Did this answer your question?