The PowerDesigner Generation Template Language (GTL) is a template-based language, which is used to generate text for the metaclasses defined in the PowerDesigner metamodel, and on any extensions that are defined in the model profile.
Each template is associated with a given metaclass (such as a CDM entity attribute, a PDM table, or an OOM operation). You can define as many templates as you want for each metaclass, and they will be available to all objects (instances) of the metaclass. For example, to examine the set of templates used to generate code for operations in a Java OOM, open the Java object language in the resource editor and expand the Profile\Operation\Templates category.
When you generate a model, PowerDesigner evaluates which metaclasses must have files generated, and creates a file for each instance of the metaclass, by applying the appropriate templates and resolving any variables.
GTL is object-oriented, and supports inheritance and polymorphism for reusability and maintainability. Macros provide generic programming structures for testing variables and iterating through collections, etc.
A GTL template can contain text, macros, and variables, and can reference:
Simple templates - which can contain text, variables, and conditional blocks, but cannot contain macros. For example:
%Visibility% %DataType% %Code%
When this template is evaluated, the three variables Visibility, DataType, and Code will be resolved to the values of these properties for the object.
Complex templates - which can contain any element from a simple template, and also macros. For example:
.if (%isInner% == false) and ((%Visibility% == +) or (%Visibility% == *)) [%sourceHeader%\n\n]\ [%definition%\n\n] .foreach_item(ChildDependencies) [%isSameFile%?%InfluentObject.definition%\n\n] .next [%sourceFooter%\n] .endif
This template begins with an .if macro which tests the values of the isInner and Visibility properties. Several variables are enclosed in square brackets, which ensures that the text enclosed with them (in this case, new line characters) will not be generated if the variable evaluates to void. The .foreach_item macro loops over all the members of the ChildDependencies collection.