Template Transformer

Template Transformer generates XML, HTML, text and other data from a template. The Documentation Portal provides configuration parameters of this component.

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.

Parameters

Take a look at the configuration parameters of the trigger. Parameters supported by Double Braces expressions are marked with (DB).

Parameter
Description
Default value
Data type

Model Path

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

body

String

Preserve Original

If activated, the option preserves the original fields received in the component input.

True

Boolean

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.

N/A

String

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 that 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 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 a string. In case of error, the "error" property will be created at 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 conversions and transformations in the template inside this component. To know more about Freemaker and how to use it, click here.

Last updated