IMHO
In meta model, a stereotype (e.g. named as A)'s attribute will become its instance's (stereotyped by A) tagged value. The instance of A is a classifier (e.g. named as B). Then instance of B is an object, its slot can dynamically play the role as B's attribute; but can not change B's tagged value.
For example,
1. In meta model, create a stereotype "Car" with an attribute "transmissionKind", value can be enumerated as "auto" or "manual".
2. On Class diagram, create three classes:
<<Car>>AutoCar, whose tag "transmissionKind" is set as "auto";
<<Car>>ManualCar, whose tag "transmissionKind" is set as "manual";
<<Car>>CVTManualCar, whose tag "transmissionKind" is set as "manual"; add another tag "CVT", whose value is true (or "manualType", whose value is "CVT"; whatsoever...)
3. All AutoCar, ManualCar and CVTManualCar were added following attributes:
leftFront: Wheel
leftRear: Wheel
rightFront: Wheel
rightRear: Wheel
transmission: Transmission4. Now if I create an object "MyCar", typed by "CVTManualCar", then
It will definitely be a "CVT manual" car, no chance to be an "auto" car, no chance to be other type of manual car.
But I have the right to change wheels:
Michelin / leftFront: Wheel
Funlop / leftRear: Wheel
FireStone / rightFront: Wheel
HomeMade / rightRear: Wheel
And have the right to choose a CVT Manual Transmission
Shimano / transmission: Transmission5. When do code generation, something like:
class CVTManualCar
{
Wheel* leftFront;
Wheel* leftRear;
Wheel* rightFront;
Wheel* rightRear;
Transmission* transmission;}
Pardon, how to use the "transmissionKind" tag? It can be used in the code generation template like this way (pseudo):
%if tag.transmissionKind.value == "auto"%
AutoTransmisson* transmission;
%else if tag.transmissionKind.value == "manual"%
ManualTransmission* transmission;
% if tag.CVT.value == "true"%
CVTManualTransmission* transmission;
% end if%
%end if%
Note: class "Transmission" is generalized by "AutoTransmisson" and "ManualTransmission", which is further generalized by "CVTManualTransmission".
Maybe it is an ugly design, but it demonstrated how tag value are used in code generation.
Quote what KP said
"Attributes are part of what you are modeling; tagged values are part of how you are modeling." 