Chapter 9 Generation Reference Guide (GTL)


Defining template overloading

You may have different definitions of the same template that apply in different conditions. If it is the case, the template is only defined for objects that satisfy the actual condition (templates are always dynamically bound). The overloading feature can be used as a powerful switching mechanism: you can sort items in alphabetic order to provide more readability when gathering different versions of the same template. It also provides more readability because it avoids long .if conditions.

At translation-time, the translation engine evaluates each condition successively until it finds one that is verified. When it does, it takes the corresponding template definition. If no condition is satisfied, the unconditioned template, if defined, is used as default (see syntax1 in the following figure).

Conditions must be mutually exclusive to guarantee deterministic behavior.

Templates may be defined under criteria or stereotypes as well, in which case the corresponding conditions are combined.

For more information on criteria and stereotypes, see "Defining a criterion" and "Defining a stereotype" in the "Managing profiles" chapter.

Example


For more information on <simple-condition>, see the "if macro" section.

 


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