TemplateParserUnit

Class name

com.ebd.hub.datawizard.iu.TemplateParserUnit


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 a Response using the output of this Integration Unit must be set to "ISO-8859-1".

Parameters


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.

output-file-encoding


8859_1

The encoding of the created file. Important note: The encoding of the Response must still be set to "ISO-8859-1" no matter what encoding is set here.

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.


Formal
{--<placeholdername=targetstructurefieldname>--}
template_file_1.txt
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).


images/download/attachments/155418870/1396-version-1-modificationdate-1698042291527-api-v2.png

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.


Formal
{--<placeholdername=targetstructurefieldname>:<recordnumber>|<iterationnumber>--}
template_file_2.txt
My name is {--name:0|1--}.
Ausgabe
My name is Michael.

Listing all values


To output all values of a multidimensional data structure, a loop block must be used.


Formal
{--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.


Formal
{--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.


template_file_3.txt
{--LOOP|myloop:0:{name|0}:1--}
{--name:0|myloop--}
{--/LOOP|myloop--}
Ausgabe
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.


Formal
{--CHECK|<blockname>:<checktype>|<reference>--}
Conditional text.
{--/CHECK|<blockname>--}


The parameters have the following meaning.


blockname

Freely assigned name of the check block.

checktype

exist - The specified text is output if the specified target structure field (see reference) exists in the target tree.

nonexist - The specified text is output if the specified target structure field (see reference) does not exists in the target tree.

empty - The specified text is output if the specified target structure field (see reference) exists in the target tree and is empty (length = 0).

nonempty - The specified text is output if the specified target structure field (see reference) exists in the target tree and is not empty (length > 0, blanks count).

blank - The specified text is output if the specified target structure field (see reference) exists in the target tree and is empty (length = 0) or consists exclusively of blanks.

nonblank - The specified text is output if the specified target structure field (see reference) exists in the target tree and is not empty (length > 0) and does not consist exclusively of blanks.

reference

The target structure field to be checked.


template_file_4.txt
{--CHECK|myblock:exist|name--}
There are names available.
{--/CHECK|myblock--}
Ausgabe
There are names available.