From RunaWFE

Revision as of 19:26, 26 May 2014 by Natkinnat (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Generating documents based on docx template

Version 4.4.1

© 2015-2020, "Process Technologies" Ltd, this document is available under GNU FDL license. RUNA WFE is an open source system distributed under a LGPL license (

Source code moved from to


# Overview handler is used to generate document from template.

This handler can run in strict mode or not. In case of strict mode any error in template or if template requires variable that is missing from process an error will be propagated. Strict mode can be set via checkbox in handler configuration.

Note. Characters (semicolons and sequence ' as ') in variable names in templates are known to cause errors.

# Settings

See configuration guide. Properties docx.placeholder.start, docx.placeholder.end define control statements syntax. Default values are "${" and "}".

# Replacements

Expression of the form

will be replaced by variable variable in the format defined in Developer Studio.

Note. To begin a new line variable must contain \r\n sequence.

# Container Element Replacements

Elements of container type can be accessed with square brackets [].

Integer (or long) value or variable can be used as list element index.

String value or variable can be used as map key.



# Executor Field Replacement

Fields output can be done in a usual way. For example to output full name from the variable processStarter of Executor type:


Note. In early versions 4.0.6- it was possible to set another type for variable replacement in configuration. This feature is available in backward compatibility mode 4.2.0-, but in this case the current features are not available. If there's such setting with type specification present in configuration then handler automatically switches to backward compatibility mode.

# Images

In a usual way a pointer ${image1} in template can be replaced by file variable with image.

Note. If file variable contains not an image (or if image format is unknown) there will be an error while processing template.

# Iterators

The following iterators are used while working with containers:

  • indexes for index iteration (starting with 0)
  • items for values iteration
  • keys for maps, iteration by keys
  • values for maps, iteration by values

# Tables

Note. In early versions 4.0.6- tables were configurated in configurators. This feature is available in backward compatibility mode 4.2.0-, but in this case current features are not available. If table is configurated in configuration then handler automatically switches to backward compatibility mode.

You can create table only with fixed number of columns in template. Note that table style stays the same after replacements. Table rows can be created automatically from maps or lists. In order to do so put one of the following in each table row cell:


, where

ITERATOR is the name of iterator type; if not set then default iterators items, values are used for the corresponding container types.

VARIABLE is the name of container variable of map or list type

SELECTOR is field or attribute specification of iterator current variable, if not present then variable value is used

It's necessary to fill the first row with the some of the following in order for the rest of the rows to be filled with containers elements.

Variants of first row cells:

${items:userList as fullName}
${values:mapWithGroups as name}

In case of maps linked by key sorting is carried out by keys. Say we have map1 and map2 with keys1=keys2 (linked maps) and we want to create a table with 3 columns with all elements from those maps. Then first row, first cell is ${keys:map1}; second cell is ${values:map1}; third cell is ${values:map2}.

Note4.1.0-. Syntax was ${ITERATOR:VARIABLE SELECTOR}

# User Types

Point is used to separate name of variable of user type from its attribute to designate value of user type variable attribute for replacement.



# Programming Capabilities

# Loops βeta

Loop is defined by 3 elements: loop start, loop body and loop end.

Loop start is of the following form:


, where

ITERATOR is iterator type

VARIABLE is container variable name(of map or list type)

ITERATOR_VARIABLE is variable name with the current iteration variable, the value depends on iterator type

Loop body can contain only text. Current iteration variable is accessed in a usual replacement way.

Note. Tables are not permitted in loop body.

Note. Inner loops are not permitted in loop body.

Note. Loop body if copied do not preserve all its attributes, for example background color.


Loop end is of the following form:


, where

ITERATOR is iterator type name that must correspond with loop start iterator type

Note. Loop start and loop end strings must be on their own lines and those lines must not contain anything besides them.


${items:list as value}
${indexes:list as index}
 value = ${list[index]} for element ${index}
${keys:map as key}
 ${key} = ${map[key]}
${values:map as value}

# Decisions planning

${if (map.size() == 0)}
 map empty
${if (map.size() > 100)}
 map is considerably filled 
${if else}
 input data
Personal tools