Example Templates
A First Template
As you can see in the exemplary data, two invoices should be generated. One for Mr Peter Miller and one for Mrs Mary Brown. To achieve that, we set the parameters create multiple files to true and root node for multiple files to Invoice. For starters, we only display the header information and the address. Our template is an .odt file with the following content:
This already shows us the most important elements of such a template: Blocks and field placeholders.
Everything in between the elements {--Invoice--} and {--/Invoice--}, for example, is a block. This means that all the fields and further blocks between those two tags correspond to the node Invoice. If create multiple files were set to false, only one document, containing the header information and address of every invoice, would be created.
Two further blocks are opened in the block Invoice. One for the header information and one for the address. The tags for those blocks are named exactly like the nodes containing the corresponding fields: Header and Address. All the field placeholders within those blocks are replaced with the values of the corresponding fields, i.e. fields with the exact same name. So {--OrderNumber--} or {--Title--} for example. The lines with Postcode and City show that any desired formatting is possible. The values replacing the placeholders will have the same formatting.
So far, our invoice for Mr Miller looks like this:
Template_2_EN.odt (This is not a template. It is a result of a processed template.)
An Extended Template
Now we need a salutation, which will be straightforward:
Next, we want to list all the items of the invoice. This shall be done in a table. First, we show the simple version:
The Integration Unit repeats the content of the table (the header row is not repeated) for each Item and fills the placeholders with the field values of the respective subnode ItemHeader. As you can see, blocks can be put in table cells as well, but opening and closing tags also have to be in lines only containing those tags. However, that is not very readable. So why do we not refer the table directly to the node ItemHeader? Unfortunately, that is not possible, since a node can always just be addressed in a block referring to a directly superordinate node, as mentioned earlier, and the superordinate node of IteamHeader is Item and not Invoice.
But we have a solution for that. Instead of the command table we use table deep:
This version searches deep down in the subnodes of Invoice for occurrences of the node ItemHeader and repeats the table contents for those nodes.
Now all that is missing is the total sum over all items: