Chapter 4 Managing Profiles


Creating a template

The Template category contains template items. You can access any information in the model using variables. This information can be simple attributes (for example the name of a class or the data type of an attribute) or a collection of objects (for example list of attributes of a class) depending on the metaclass where you have defined the template.

You can use the PowerDesigner metamodel, together with the help file pdvbs10.chm to visualize metaclass interactions. This should also help you select the appropriate metaclass where to define a template.

You use the GTL to define a template. Templates are used in the generated files: during generation, each template is evaluated and replaced by its actual value in the generated file.

For more information on the GTL syntax, see the "Generation Reference Guide" chapter.

Templates can be created in the Shared category when they apply to all metaclasses. They can also be created at the metaclass level or for a given stereotype or criterion.

New syntax

In the previous versions of PowerDesigner, you could bind the use of a particular template to the existence of a stereotype using the following syntax:

template name <<stereotype>>

In the current version of PowerDesigner, you create a template in a given stereotype to make sure this template is used only on metaclass instances with the stereotype.

Browse tool (F12)

You can use the Browse tool to find all templates of the same name. To do so, open a template, position the cursor on a template name in-between % characters, and click Browse (or F12). This opens a Result window that displays all templates prefixed by their metaclass name. You can double-click a template in the result window to locate its definition in the resource editor.

Steps To create a template:

  1. Right-click a metaclass in the Profile category and select New→Template.

    or

    Right-click a stereotype or a criterion in a metaclass and select New→Template.

    A new template is created under the corresponding category.
  2. Type a clear name in the Name box. It is recommended not to use spaces in the template name.
  3. <optional but very useful> Type a comment in the Comment box in order to explain the use of the template.
  4. Type the template body using GTL in the central box.

 


Copyright (C) 2005. Sybase Inc. All rights reserved.