Add a table

Now we want to generate a table with a line for each attribute defined on a UML Class:

  1. Open the model product21.xmi.
  2. Select the type Class.
  3. Select the Class Order and show its children.

You can see the attributes are linked to their class with the reference attribute. The doc template has to iterate on the attribute list and add a line in a table:

  1. Click Table > Insert > Table... to create a new table with two columns and two rows.
  2. Type "Name" in the first cell and "Type" in the second cell.
  3. Select the first row and right-click Borders and Shading.
  4. In the Shading tab, select for example the color Gray-15%.
  5. Click OK.
This is an example with Microsoft WordŽ, it's a quite similar sequence with other authoring tools.

At this stage, the template should look like this:

...
Classes
[#foreach class in model.getInstances("Class")] Class
${class.name}

Description
[#foreach comment in class.ownedComment] ${comment.body}[/#foreach]
[#if class.isAbstract]
This is an abstract class[/#if]
Attributes
NameType
  
[/#foreach]

We want to add a foreach tag that embraces the whole line, so that a line creation is part of the foreach iteration.

...
Attributes
NameType
[#foreach attr in class.attribute] ${attr.name} [/#foreach]
[/#foreach]

Save the doc template, relaunch the generation and open the file result.xml:

...
Class Order
Description
An order of a product by a customer

Attributes
NameType
date 
items 
product