TemplateParserUnit
Group |
|
Function |
Creates a text file from a template text file with placeholders that are replaced with data from the target structure. |
Description
Introduction: Integration Units. Set the Content in the Content settings of a Response Route in phase 6 to Output of IU.
This Integration Unit creates a text file from a template text file with placeholders that are replaced with data from the target structure.
If no data is found for a placeholder, it is replaced with an empty string.
The encoding of the generated text file is always 8859_1.
Parameter Description
Parameter name |
Allowed values |
Default value |
Description |
Use format-field |
true, false |
false |
Deprecated setting. Please always leave on false. |
create CDDATA for xml |
true, false |
false |
If true, the text will be enclosed with an XML CDATA block when replacing placeholders. |
end tag |
|
--} |
The end tag of placeholders. |
start tag |
|
{-- |
The start tag of placeholders. |
template file encoding |
|
8859_1 |
The encoding with which the template file is read. |
template-file |
|
|
The path to the template file. |
Simple Placeholders
Given the following template file, the placeholder {--name--} is replaced with the value of the target structure field name.
{--<placeholdername=targetstructurefieldname>--}
My name is {--name--}.
Multidimensional Data
As you know, fields can be located in multi-dimensional data structures. I.e. the target structure can have several records, see (1), and the node in which a field occurs can also occur several times (iterations), see (2).
Picking out Specific Values
If you specify a placeholder as above, then such multidimensional data structures are simply ignored and the field value of the first record and the first iteration is used for the replacement of the placeholder, so here in this example the value Peter.
However, it is also possible to address specific values in such a multi-dimensional data structure, see the following template. The first index refers to the records and the second to the iterations. Both indices start at 0.
{--<placeholdername=targetstructurefieldname>:<recordnumber>|<iterationnumber>--}
My name is {--name:0|1--}.
My name is Michael.
Listing All Values
To output all values of a multidimensional data structure, a loop block must be used.
{--LOOP|<loopname>:<start>:<end>:<step>--}
{--/LOOP|<loopname>--}
The parameters have the following meaning.
loopname |
Freely assigned name of the loop. |
start |
Start value of the loop counter. Always enter 0 here. |
end |
Final value of the loop counter. Instead of an explicit value, the size of the multidimensional data structure can be referenced here. If you want to use the number of occurring names (in the first record) as the end value of the loop counter, then specify the value {name|0}. See also example below. The loop will then run as many times as there are names in the multidimensional data structure. |
step |
Number by which the loop counter is to be incremented after each pass of the loop. Always enter 1 here. |
To specify placeholders within the loop, proceed as follows. In principle, it works as above when picking certain data from a multidimensional data structure, but with a slight modification.
{--LOOP|<loopname>:<start>:<end>:<step>--}
{--<placeholdername=targetstructurefieldname>:<recordnumber>|<iterationnumber>--}
{--/LOOP|<loopname>--}
We use the placeholder {--name:0|myloop--} here. Our loop will run as many times as there are names in the multidimensional data structure in the first record. And in each pass we output the name of the first record (the index starts at 0, as we remember) and the iteration number corresponding to the current value of the loop counter.
{--LOOP|myloop:0:{name|0}:1--}
{--name:0|myloop--}
{--/LOOP|myloop--}
Peter
Michael
Doris
Check Blocks
The output of text can be made dependent on the presence or absence of values of a certain target structure field. Check blocks are used for this purpose.
{--CHECK|<blockname>:<checktype>|<reference>--}
Conditional text.
{--/CHECK|<blockname>--}
The parameters have the following meaning.
blockname |
Freely assigned name of the check block. |
checktype |
If exist is used, the specified text is output if values exist for the specified target structure field (see reference). If nonexist is used, the specified text is output if values do not exist for the specified target structure field (see reference). |
reference |
The target structure field to be checked. |
{--CHECK|myblock:exist|name--}
There are names available.
{--/CHECK|myblock--}
There are names available.