Sample configuration for a model-to-model transformation for models that contain cross-references

This sample shows two ways to manage cross-references when you transform a model.

Before you begin

Use the instructions in "Setup instructions for a model-to-model transformation for models that contain cross-references" to set up the sample.

Transforming cross-references when the referenced element is not transformed

About this task

Procedure

  1. In the runtime workbench, in the Package Explorer view, expand the source project, expand Models, expand Source1; then expand classes A and B. Each class has an attribute, and the type of the attribute is the other class in the same package.
  2. Expand the target project and double-click the transformation configuration file named transform source1 to target1.tc.
  3. In the transformation configuration editor, click Run.
  4. In the target project, expand Models, expand Target1; then expand interfaces IA and IB, which the transformation generated from classes A and B. Notice that the types of the attributes are set to the interface in the target model that corresponds to the class in the source model.
  5. In the source project, expand Source2. This folder contains a package with one class, named C, which has an attribute whose type is a class in the other input model, Class A in Source1 (package P1). This cross-reference is the subject of this sample.
  6. In the target project, double-click the transformation configuration file named transform source2 to target2.tc.
  7. In the transformation configuration editor, click Run.
  8. In the target project, expand Models, expand Target2 and expand interface IC, which the transformation generated from class C. The type of the attribute in the generated target model is the same as it was in the input model: Class A in Source1. This result occurs because the transformation that transforms Source2 to Target 2 has no information about the transformation of Source1 to Target1.

Results

If you are transforming multiple models, as in this example, and the models contain intermodel references that you want to update to the corresponding objects, you cannot transform the models sequentially. You must transform the models at the same time. The following section tells you how to do this.
Note: If the model that contains the referenced element is not supposed to be transformed, which means that the cross-reference is static, you do not need the instructions in the following section. You can just transform the model that contains the referencing element as you do typically. These instructions apply only when the target of the cross-reference is to be transformed.

Transforming cross-references when both the referenced element and the referencing element are transformed

About this task

Procedure

  1. In the Package Explorer view, expand the target project and double-click the transformation configuration file named transform source1 and source2 to target1 and target2.tc.
  2. In the transformation configuration editor, click the Source and Target tab. Notice that the source that is specified here is Source1.emx, and the target is Target1.emx, just as in the transformation named transform source1 to target1.tc.
  3. In the transformation configuration editor, click the Auxiliary Transformation Sources and Targets tab. The auxiliary source and target that are specified here are Source2.emx and Target2.emx. When you run the transformation, Source2.emx is transformed as well as Source1.emx.
  4. In the transformation configuration editor, click the Main tab; then click Run.
  5. Examine Target1. The contents are the same as they were after the previous transformation.
  6. Examine Target2. The attribute for IC in the generated interface is now set to IA, which is the interface in the target model that corresponds to the originally referenced class, A, in the source model.

Feedback