erwin generates DDL using template files, one for each of the Database Management Systems it supports. The template language used is known as TLX and consists of a few basic constructs which are built into macros, which are themselves used to build templates, which are stored in a Forward Engineering Template (FET) file. Each FET file is specific to a DBMS and is exposed to the user through an IDE accessible from the Forward Engineering Dialog.
Users can edit these templates to modify the DDL generated.
However, DDL is just plain text, so why not use these templates to generate other text, such as XML, HTML or application code?
In this instance, I created a template to take table and column metadata from an erwin model and translate it into Java classes to represent the entities, their attributes, and the relationships between them.
The idea is simple but also hugely scalable. You could translate as much or as little of the erwin model metadata into the Java model as required for your application – from just the names of the columns to UDPs – and even use auto-generated methods to store or retrieve data as if it was a database. Although this all runs within the JVM the current state of the model can be easily stored or retrieved, for example by using features from Java’s extensive XML handling libraries.
Such templates can be readily created, deleted and edited from within the Forward Generation feature of erwin itself. Everything is customisable. You might want to take an existing Java-generation template and change the way in which data type errors are reported, or you might want to store the entities, attributes and other metadata in some entirely different format, such as a series of hash tables.
Java is well known for its ability to interface with a vast array of different applications thanks to an ever-growing catalogue of APIs (both official and unofficial). As a result, TLX templates make erwin model metadata accessible to virtually any application.
Equally there is no reason why code could not be generated in your language of choice in a similar manner. TLX can also be used as a simple logging or metadata reporting tool.
Contact us to find out more about how TLX templates in erwin could be used to generate a model fitting your specification.