Cross References

Return to Introduction  Previous page  Next page

Cross References are an important part of transformations.  They are used to:

·Find the transformed class to synchronize with
·Create connectors between transformed classes
·Specify a classifier of a type
·Determine where to transform to for future transformations.

Each cross reference has three different parts:

·A Namespace, corresponding to the transformation that generated the element
·A Name, which is a unique reference to something that can be generated in the above transformation
·A Source, which is the GUID of the element that this element was created from.

When writing the templates for a transformation, it is easiest to create the cross references using the TRANSFORM_REFERENCE macro that is defined for this purpose.  It has three optional parameters.

TRANSFORM_REFERENCE(<name>, <sourceGuid>, <namespace>)

Generates a reference that can be used in the ways described above.  It resembles the following.

XRef{namespace="<namespace>" name="<name>" source="<sourceGuid>"}


·If <name> is not specified it gets the name of the current template
·If <sourceGUID> is not specified it gets the GUID of the current class
·If <namespace> is not specified it gets the name of the current transformation.

Note: The only time that this should be specified is when creating a connector to a class created in a different transformation.

A good example of the use of cross references is in the DDL templates provided with Enterprise Architect. In the Class template a cross reference is created with the name table. Then up to two different connectors can be created, each of which must identify the two classes it connects using cross references while having its own unique cross reference.

Specifying Classifiers

Objects, attributes, operations and parameters can all reference another element in the model as their type.  When this type is created from a transformation you must use a cross reference to specify it, using the TRANSFORM_CLASSIFIER macro.

TRANSFORM_CLASSIFIER(<name>, <sourceGuid>, <namespace>)

Generates a cross reference within a classifier element., where the parameters are identical to the TRANSFORM_REFERENCE macro but the name Classifier is generated instead of XRef.

If the target classifier already exists in the model before the transformation, a TRANSFORM_CLASSIFIER is inappropriate and instead the GUID can be given directly to a classifier attribute.

Note: If a classifier is specified for any type it overrides the type specified.