Use the Additional Content property to specify custom content for a desired element in addition to the standard one defined by the UML ownership. The custom content of an element is a collection of elements related to this element by some user-defined rule, such as some type of relationship. 


To customize the content of a DSL element


  1. Create a customization element for the DSL element or select an existing one.
  2. Create a derived property for this customization element. 
  3. Specify a rule for gathering the additional content of the DSL element by creating an expression for the derived property. 
  4. Define the derived property as a value of the Additional Content property. 
  5. Find the property in the general property group of the Specification window of the customization element, under the Content category.


The custom content of the element will then be visible in the following places:


Case Study

Let’s say we need UML Packages to display not only their owned elements, but also the elements related to the Packages by the Element Import relationship. In order to obtain this, we must specify the rule for gathering the custom content of the Package. Then we will analyze the contents of the customized Package in the Containment tree. 


To specify the rule for gathering the custom content of the Package


  1. Create a profile diagram and add a customization element name (e.g., PackageCustomization) to it.
  2. Define the Package metaclass as the customization target of the customization element.
  3. Create a derived property specification for the customization element, name it importedElements, and define the simple expression as shown in the following figure.
  4. In the general property group of the Specification window of the customization element, under the Content category, find the Additional Content property and click the cell of the property value.
  5. Define the importedElements derived property as a value of the Additional Content property.

Property

  • The Additional Content property can store a single value which can be only a derived property specification.
  • Select the derived property specification from either the same customization element or another one with more abstract customization target. In this case, for example, this could also be the customization element with the Element metaclass as a customization target. 

When you are done, the shape of the PackageCustomization element should look like the one depicted in the following figure. 

       6. Reopen the project.



To see how the Additional Content property affects the contents of the Package


  1. Create a new diagram and draw in it a package named, e.g., P.
  2. Draw two classes named A and B in the package.
  3. Outside the package, draw a class named C and connect it to the package with the Element Import relationship.
  4. Now take a look at the Containment tree. The package P contains both owned classes A and B as well as the class C, which is not owned, but related to the package P by the Import Element relationship.