Transformation to Source Code
Go Up to Introductory Modeling Concepts
UML modeling enables you to generate source code based on a language-neutral design project.
About transformation to source code
You can generate source code from the Class Diagrams of your UML 1.5 or UML 2.0 design project and add this source code to a project in one of the supported languages. The target implementation project must already exist in the same project group.
The UML modeling feature can generate different names for your model elements in the source code. For example, you can have
ClassItem in your source code for the
Class1 element in your model.
This feature is especially useful, if your model names are not English. You can use names in Japanese and other languages on your diagrams, but keep names in Latin alphabet in your code.
If you enable this feature, the file codegen_map.xml is created in the model support folder of the source design project. You can edit it with any XML or text editor. This file contains a mapping table, where each entry (model element) has two names: one for the source design project (attribute
name), and another one for the destination implementation project (attribute
alias). There are several sections in this file: Class, Attribute, Operation, and Package for UML 1.5 projects, and Class and Package for UML 2.0 projects. Attributes name must be unique for all entries in a section.
You can optionally create an XML file with the same name and structure in a folder of any package.
If you transform your project to source code and the name mapping feature is enabled, the software searches for the codegen_map.xml file for each model element. If the file is absent for a current package, the software searches in a parent package, and so on.
Note: If you add a new element to your model later and then transform the project to source code, the software adds a new entry for this item to the corresponding codegen_map.xml file. The existing entries are not changed.