Format of the Template

Templates are normal text files in Open Document Format (ODF). The usual ending for such a file is .odt. In the following, we assume that this file was created with OpenOffice 2.0. Certain placeholders (tags, blocks, and commands) can be used in the text, headers, and footers of the template to describe how the ODTCreatorUnit has to create the document. These placeholders are either replaced by the content of a field or they limit blocks, which are repeated for each occurrence of a corresponding node. In addition, there are special commands for additional control.

Tags:

All tags are opened with {-- and closed with --}:

{--Tag--}

Whitespaces between the field names, block names, commands and the enclosing brackets are not allowed.

{--Correct--}
{-- Incorrect --}

If a tag is unknown (e.g. because the used field does not exist), the default output instead of the field value is a ?. The unit parameter unknown tags replacement allows defining alternative characters.

Blocks:

Blocks are, similar to XML, closed with a slash /. All tags enclosing blocks always have to stand at the beginning of a line only containing that tag. Those lines are removed after the processing of the template.

This {--Block--} is totally
wrong. {--/Block--}

{--Block--}
This is correct.
{--/Block--}

Blocks have to correspond to nodes in the data structure. The content of a block is repeated as often as the respective node (once per data set of that node).

A node or a field can always just be addressed in a block referring to a directly superordinate node. In the following example the node ItemHead can only be addressed in the block Item, but not in the block Invoice. If a block is unknown (e.g. because the corresponding node does not exist), the whole node will not be displayed.

The outmost block of a template always has to correspond to the node set as root node (if the option create multiple files is used). This does not have to be the outmost node. On the other hand, if root node and create multiple files are not used, the outmost block indeed has to correspond to the outmost node of the destination tree. If there are several nodes on the highest level, all of them can be addressed.

Commands:

Commands always begin with odtcreator, followed by a colon and the command itself. After that, optional parameters, separated by colons, can follow. Commands can also form blocks. In this case, the closing tag /odtcreator:<command> is sufficient and additional statements are ignored.

For example:

{--odtcreator:if:equal:Salutation:Mr--}
Content of the block
{--/odtcreator:if:this is ignored:this as well:this too--}

Following a practical example for a better understanding. The data of several invoices shall be converted into separate invoice documents.