TGML Properties and Attributes

In the underlying class library, public data members are exposed as properties. Each TGML element attribute has a corresponding property in the TGML class that implements the TGML element.

Default Values

Most of the object properties have a default value. Element attributes that are omitted in the TGML document are considered to be undefined. An undefined attribute will result in assigning a default value to the corresponding property, unless the value is inherited from a parent element.

Attribute Inheritance

TGML supports attribute inheritance similar to the SVG and XAML attribute inheritance.

The attribute inheritance means that a child element inherits (gets) the attribute value from an ancestor element if the attribute value is omitted and if the attribute has been specified for an ancestor (any of the parents).

In the example below, Line will inherit the Stroke value from the Group. StrokeWidth is not defined either, but since it is not specified at the parent level, StrokeWidth will be assigned the default StrokeWidth value.

Copy
<Group Stroke="FF0000">
    <Line X1="10.00" Y1="10.00" X2="100.00" Y2="100.00"/>
</Group>

Custom Attributes

The implementation of attribute inheritance also enables the user to specify custom attributes, since an element will accept attributes that are actually unknown for the element. For example, in the attribute inheritance example, Stroke was specified, and accepted at the group level, despite the Group does not have a Stroke attribute.

Custom attributes can, for example, be used to create "local" variables. The custom attribute can be bound to a signal, or animated, as any other attribute of an element and it can be accessed from scripts in the graphics.

Error Notifications

TGML does not specify any error or warning notifications. However, the TGML implementation (e.g. Graphics Services) and the viewer and editor applications should notify the user about any error conditions.

Implicit Syntax

TGML uses an implicit syntax. The object model implementation is not exposed in the serialized TGML.

The following example defines a group containing a line. The TGML code does not reveal how the containment is implemented in Group. The Group implementation includes for example a child list that is the actual container, but such information is not serialized.

Copy
<Group>
    <Line X1="50.00" Y1="100.00" X2="150.00" Y2="200.00" Fill="#FF0000" Stroke="#000000"/>
</Group>

Undefined (non-specified) attributes values are not serialized, to avoid breaking the attribute inheritance.