Create a doc template

In previous steps, we created an MDWorkbench project and inspected the structure of model information we need to handle. Now we are ready to create a generation program using a doc template.

A doc template is a Microsoft WordŽ file (xml or docx) or an Open Document file (odt) which specifies the information to generate in a given file as well as the name of the file.

To create a doc template:

  1. Click File > New > Doc Template.
  2. Type com.sodius.mdw.samples.tutorial/src in the Source folder field.
  3. Type tutorial.doc in the Package field.
  4. Type DocSample in the Name field.
  5. Select Microsoft Word 2003 in the authoring tools list.

  6. Click Finish.

A file DocSample.dt.xml is created in the folder com.sodius.mdw.samples.tutorial/src/tutorial/doc and is opened in Microsoft WordŽ.

[#parameters][/#parameters]
[#file]result.xml[/#file]
generated text

The doc template DocSample is defined in the package tutorial.doc and generates the static text generated text in the file result.xml.

We want to generate a Microsoft WordŽ document based on a UML input model. So we need to add a UML model parameter to the doc template:

[#parameters]in model : uml21[/#parameters]
[#file]result.xml[/#file]
generated text

Add the code "in model : uml21" and click File > Save.

Note: To visually distinguish static text (e.g. "generated text") from expressions (e.g. "in model : uml21"), you may select an expression and apply the Word style MDW_Expression. (this style is automatically created by the doc template wizard).

uml21 is the metamodel identifier of the UML 2.1 metamodel, model is the name of the parameter, and in tells MDWorkbench this input UML model is expected to be loaded (from an XMI file for example).

Related concepts
Metamodel
Doc template

Related reference
DocGen
parameters tag
file tag