[Top] [Prev] [Next]
Introduction
The following pages provide an example of how an application can be modelled using XML and
the model transformed into application artifacts (ie. programs, database tables,
stored procedures, web pages) using XSLT.
The inspiration for this stylesheet came from a remarkable application generation product
called OmniBuilder. One of the challenges with
code generation is to insert pieces
of code in-between other pieces. A recent approach was to build an XML tree so that
the "features" (OmniBuilder calls them "design patterns" and they look a lot like
"aspects") could be inserted. XSLT has been used before to generate code, but this
stylesheet is novel because the stylesheet doesn't just transform the model...it adds
code not found in the model. The beauty of OmniBuilder is that it doesn't just take a
UML model and build classes...instead it models Entities and builds tables, stored procedures,
web forms, classes, or anything else. The really original thing about it is the ability to
define "features". It's like being able to take a UML model, annotate it, and have the
annotations reflected in the code. A good example of a feature you might have seen before
is the way that you can specify an "Identity" column in SQL Server. A lot of behavior gets
implemented when you do that.
The model is a description of the application and includes both general and specific elements of
the application. The model is the source of the code generation. The model used in the example
has an XML form.
The features specified in an application have to be translated into the application artifacts.
For each feature, there is an implementation that contributes its code fragments to the
artifact. In the example, the features are implemented through XSLT stylesheets.
This is a program that creates the application artifacts from the model. The engine used in
the example is the Apache XALAN XSLT processor.
The framework is the environment where the generated artifacts will be used. Typically,
a library and coding standards will already be established before any code is generated that
will direct how the artifacts will be used with existing components. For example, security,
error handling, and logging code will not be generated. Instead, the generated code will call
framework functions that are already developed. In the example, some assumptions are implicit
in the generated code, but the data-access class will run as a stand-alone class.