Scenario

Create a narrative which describes a project.


Our data is a list of values that contain information about a project. We want to create a narrative (free text) description of the project.

Our data table is in list (keyword=value) format and looks like:

# Example table data.
id,project,version
apple,Appleseed,version-1
orange,OrangeBlossom,version-2

We will store this in a file called attributes.lst.

Our velocity template looks like:

Hello from the $list.project project.
I'm currently at version $list.version. I come in $list.colors.size()
colors. They are:
#foreach ($item in $list.colors)
   $item
#end

We will store this in a file called example-narrative.vm.

The template is like a form letter with placeholders in the text where we want the values of the parameters to be placed. Our list of parameters will be in a context called "list" (which is established on the command line - see below).

Running igpp.docgen with the command:

$ java -jar igpp.docgen list:attributes.lst example-narrative.vm -f plain

Instructs igpp.docgen to parse the file "narrative.lst" and place the results in a context named "list". Since the extension on "narrative.lst" is ".lst" igpp.docgen will parse the file as a set of keyword=value parameter assignments, creating a parameter for each non-commented line in the file The option "-f plain" tells igpp.docgen to treat the output as plain text. The default for igpp.docgen is to treat the output as XML and to generate well formatted XML (not what we want in this example).

Running this command will generate a plain text that looks like:

Hello from the igpp.docgen project.
I'm currently at version 1. I come in 3
colors. They are:
   red
   green
   blue