🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
TaggedValues
This page was created by Hans.karlsen on 2017-07-03. Last edited by Wikiadmin on 2026-07-29.

Tagged values (also called TVs) let you attach metadata to any model element in MDriven Designer when UML has no standard property for the information you need.

A tagged value is a named value stored with the model element. MDriven Framework features can read particular tagged values to control behavior, and you can use tagged values to retain application-specific metadata at the model level.

For example, a model may contain metadata that is emitted as a .NET attribute:

[UmlTaggedValue("Kasper.BusinessDeleteValue", "OkEvenIfNotEmpty")]

In this example, Kasper.BusinessDeleteValue is the tag name and OkEvenIfNotEmpty is its value. The meaning comes from the code or MDriven feature that reads that tag; a tag name alone does not define behavior.

When to use tagged values

Use a tagged value when the information belongs to a model element but is not represented by a UML property.

Examples include:

Scope and meaning

Tagged values are part of the UML extension mechanism. In MDriven, they are available on all model elements.

The element that holds the tag is important. A tag on a class describes that class; a tag on an attribute or association end describes that feature. When you define a tag, document both its name and the element type on which it is expected.

Location Example use How it is consumed
Class or other type Store a presentation-unit identifier such as Eco.PresentationUnit. Read the tag from the type at runtime with OCL.
ViewModel column Set DataIsLink for a string shown as a hyperlink. Turnkey Web-UI interprets the tag when it renders the column.
Attribute or association end Store metadata for one named feature. Query the feature-specific tag with the OCL feature operator described in Documentation:OCLOperators taggedValueOnFeature.

Read tagged values in OCL

When you build a system with the model alone, including WECPOF, you can read model metadata at runtime without writing code.

For a tag on a type, use TaggedValue. This example gets the Eco.PresentationUnit value from the type of the first G instance:

G.allinstances->first.oclType.TaggedValue('Eco.PresentationUnit')

For a tag placed on an attribute or association end, use the feature-specific operator rather than TaggedValue. Follow Documentation:Getting taggedvalues in runtime without code and Documentation:OCLOperators taggedValueOnFeature for the applicable expression and argument order.

Keep tag names intentional

A tagged value is metadata, not executable logic by itself. Use a clear, stable name and make the reader explicit.

  1. Choose the model element that owns the metadata.
  2. Add the tag name and value to that element.
  3. Identify the MDriven feature, OCL expression, or generated-code convention that reads it.
  4. Keep the tag name consistent wherever that reader expects it.

For example, setting DataIsImageUrl on a ViewModel column is meaningful because Turnkey Web-UI recognizes that tag. Setting the same tag on an unrelated class does not make a column render as an image.

Related tag mechanisms

Tagged values store metadata on model elements. They are different from tag extensions and TagExpander markup, which address other ways to include or expand information in an application.

See also