Chapter 15. Metadata
A metadata usage is a kind of annotating element that allows for the definition of structured metadata with modeler-specified attributes. This may be used, for example, to add tool-specific information to a model that can be relevant to the function of various kinds of tooling that may use or process a model, or domain-specific information relevant to a certain project or organization. A metadata usage is defined by a single metadata definition. If the definition has no nested features itself, then the metadata usage simply acts as a user-defined syntactic tag on the annotated element. If the definition does have features, then the metadata usage must provide value bindings for all of them, specifying metadata for the annotated element. [7.27.1]
After making a metadata definition with attributes, like so:
metadata def ApprovalAnnotation { attribute approved : Boolean; attribute approver : String; }
it can be used for annotating elements with the help of the keyword about:
metadata ApprovalAnnotation about Design { approved = true; approver = "John Smith"; }
or by including it in the element to be annotated:
part def Design { @ApprovalAnnotation { approved = true; approver = "John Smith"; } }
Notice that the symbol @ is a shorthand for the keyword metadata.
Semantic Annotations with User-Defined Keywords
If a metadata definition specializes the KerML metaclass SemanticMetadata (from the Metaobjects model in the Kernel Semantic Library), then any annotated elements must be types (e.g., definitions or usages), and the inherited feature baseType must be bound to a KerML::Type, which is a generalization of SysML::Definition and SysML::Usage.
For instance, for the following occurrence type definition
occurrence def Event { attribute occTime : TimeValue; }
we could define a semantic metadata (or annotation) element EventType and then annotate an event type definition like so:
metadata def EventType :> SemanticMetadata { :>> baseType = Event meta SysML::Definition; } occurrence def Arrival { @EventType; item arrivedCustomer : Customer; }
The annotated definition of Arrival implicitly subclassifies the metadata element's base type Event and is, consequently, equivalent to
occurrence def Arrival specializes Event { item arrivedCustomer : Customer; }
For making semantic annotations more readable, user-defined keywords can be declared in the semantic metadata definition like so:
metadata def <EventType> EventType :> SemanticMetadata { :>> baseType = Event meta SysML::Definition; }
and then used (prefixed by the symbol #) like so:
#EventType def Arrival { item arrivedCustomer : Customer; }
Feature (or usage) declarations can be semantically annotated in a similar way.