Chapter 9 Generation Reference Guide (GTL)


Defining Generation Template Language

It is possible to define your own generation preferences in an object language (.XOL file) or an extended model definition (.XEM file) and to customize the generation process by using the Generation Template Language (GTL).

GTL stands for Generation Template Language, it is a PowerDesigner template-based language for text generation. This language gives you flexibility and complete control over the output as generation logic is fully contained in the editable object language or extended model definition. Moreover, it allows you to easily plug-in additional code generation for your own purposes.

Process overview

GTL helps you generate pieces of text for any object (called metaclass) in a model. This generation can be helpful to generate code, generate reports (extract textual information from the model) or produce external exchange format like XMI.

You can generate one file per metaclass (for example a class in an OOM, or a table in a PDM), but you can also generate a piece of text for one metaclass that will be included in a more global file generated for another object.

This piece of text is called a template. It is made of plain text, mixed with variables that consist of information coming from the model itself.

You can access any information in the model using variables. This information can be simple attributes (for example name of a class, data type of an attribute, etc...) or collection of objects (for example list of attributes of a class). The GTL lets you also test variables, and use some macros for specific layout purpose.

The generation process evaluates which metaclass has some files to be generated and based on this, creates one file for each object in the model that belongs to this metaclass. During generation, each template and variable is evaluated and replaced by its actual value in the generated file.

Metaclass documentation

PowerDesigner ships with a metamodel published in an Object Oriented Model (metamodel.oom) that illustrates how metaclasses interact in the software. All objects in the PowerDesigner metamodel have a name and a code. They correspond to the public name of the metadata. An HTML help file (pdvbs11.chm) is also provided to allow you to find out which properties and methods can be used to drill down to a PowerDesigner object.

Supported concepts

The Generation Template Language supports object-oriented concepts such as inheritance and polymorphism thus enabling reusability and improved maintainability. It also offers conditional, iterative and text formatting macros for specifying template logic. Macros provide generic programming structures for testing variables (example: .if) and for iterating through the dependent items of an object (example: .foreach.).

Java for examples

In this chapter, most examples proceed from the Java language. However, the mechanism explained in this section also applies to all object languages and all extended model definitions.

 


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