Tag definition

Properties of a stereotype are referred to as tag definitions (or metaproperties).

Figure 6.16. Stereotype Computer with tag definitions for vendor, CPU, and memory [UML-DIAGRAMS.ORG]

Stereotype Computer with tag definitions for vendor, CPU, and memory [UML-DIAGRAMS.ORG]

Tagged value

Stereotype is applied when it is used on use case diagrams, class diagrams, deployment diagrams, etc.

When a stereotype is applied to a model element, the values of its properties may be referred to as tagged values.

UML 1.x defined tagged value as one of UML extensibility mechanisms permitting arbitrary information (which could not be expressed by UML) to be attached to models. Tagged value is a keyword-value pair that may be attached to any kind of model element.

The keyword is called a tag. Each tag represents a particular kind of property applicable to one or many kinds of model elements. Both the tag and the value are usually encoded as strings though UML tool allow to use other data types for values.

Tagged value specification in UML 1.x has the form

name = value

where name is the name of a tag or metamodel attribute and value is an arbitrary string that denotes its value. For example,

{author="Joe Smith", deadline=31-March-1997, status=analysis}

Boolean tags frequently have the form isQuality, where quality is some condition that may be true or false. In these cases, the form "quality" may usually appear by itself, without a value and defaulting to true. For example, {abstract} is the same as {isAbstract=true}. To specify a value of false, omit the name completely. Tags of other types require explicit values.

Tagged value (as well as metamodel attribute) is displayed as a comma delimited sequence of properties inside a pair of curly braces "{" and "}" (see figure).

Figure 6.17. Stereotype Computer applied using "traditional" tag values notation [UML-DIAGRAMS.ORG]

Stereotype Computer applied using "traditional" tag values notation [UML-DIAGRAMS.ORG]

In UML 1.3 tagged values could extend a model element without requiring the presence of a stereotype. In UML 1.4, this capability, although still supported, was deprecated, to be used only for backward compatibility reasons.

Since UML 2.0, a tagged value can only be represented as an attribute defined on a stereotype. Therefore, a model element must be extended by a stereotype in order to be extended by tagged values. To support compatibility with the UML 1.3 some UML tools can automatically define a stereotype to which "unattached" attributes (tagged values) will be attached.

Tag values could be shown in class compartment under stereotype name. An additional compartment is required for each applied stereotype whose values are to be displayed. Each such compartment is headed by the name of the applied stereotype in guillemets.

Figure 6.18. Stereotype Computer applied with tag values in compartment [UML-DIAGRAMS.ORG]

Stereotype Computer applied with tag values in compartment [UML-DIAGRAMS.ORG]

Tag values could be shown in attached comment under stereotype name.

Figure 6.19. Stereotype Computer applied with tag values in comment note [UML-DIAGRAMS.ORG]

Stereotype Computer applied with tag values in comment note [UML-DIAGRAMS.ORG]

When displayed in compartments or in a comment symbol, each name-value pair should appear on a separate line.