These examples illustrate how to use the igpp.docgen tool which is a document generator based on Apache Velocity. The tool can process template documents written in the Velocity Template Language (VTL). It can read PDS3 labels, text files containing keyword=value pairs, and spreadsheets in CSV or TAB format. The content of a processed file are assigned to varaibles in separate Velocity contexts and can be referenced individually in the Velocity template file. The output format can be plain text or well formatted PDS3 or XML.

Brief Introduction to Velocity

Apache Velocity is a template processing engine that provides a template language for specifying where and how variables are to occur in a generated document. In the igpp.docgen implementation, Velocity variables are assigned to a "context" and can be reference with the syntax of leading "$" character followed by a variable name (VTL Identifier). For example, the variable "name" in the "list" context would be referenced as:

$list.name

Within Velocity a variable is an object and may have methods (functions) which can used. igpp.docgen has pre-defined variables which can used to process user defined varaibles. They are:

How to use these variables is described in the advanced examples.

First we'll begin with simple examples.

Using Keyword=Value Lists

With igpp.docgen values can be set using a Keyword=Value syntax. This can be done both on the command-line and as a collection of value lists in a file.

See Example

Using CSV Tables

Support for CSV and TAB delimited tables is part of igpp.docgen. In a CSV table any line beginning with a "#" is considered a comment and ignored by the parser. The first non-commented line is used to determine the names for each field and how many fields to expect in each record. The igpp.docgen parser creates an array of records in the generated context. Each record contains a named value which matches the name of the fields and is assigned the value found in the record.

See Examples

Using PDS3 Labels

PDS3 is a metadata standard used to describe data in the planetary domain. It is primarily used by NASA Planetary Data System. The metadata is expressed using keyword=value pairs in a structured arraignment. igpp.docgen can parse PDS3 labels and provide access to the metadata using nested maps.

See Examples

Using CDF files

The Common Data Format (CDF) is a widely used format for storing data. It is a "self-documented" format which contains both metadata and data. Information is stored in a CDF file as attributes and variables. igpp.docgen can parse CDF files and make available both the explicit and implicit metadata that describes the content of the CDF file. available.

See Examples

Using JSON files

Javascript Object Notation (JSON) is an open-standard file format that is commonly used for lightweight data-interchange. igpp.docgen supports single valued elements, objects and arrays, but limits the nesting of array to two-levels. That is, an array of arrays, but not an array of arrays in an array. JSON allows each value in an array to be of a different data type. However, igpp.docgen requires all array values be of the same type, so igpp.docgen coerces all array values to be a string type.

See Examples