Home MORPH Syntax Attributes/Parameters
  Sponsored by Magnetar Games Main Specification Forum Syntax

MORPH Syntax

Attributes and Parameters

Attributes are properties of Object Classes. Parameters are properties of Interactions. Attributes and parameters are fundamentally identical, although Parameters are usually assigned a value only once and are never altered for the lifetime of the Interaction object, and thus can be considered static.

In MORPH, all attributes and parameters (herein referred to simply as "attributes") that a DSL defines are declared using xs:attributeGroup and xs:group elements as direct children of the schema (that is, they are global elements). This allows them to be validated correctly in the instance document.

xs:attributeGroup is used for attributes of most types. However some datatypes, such as records and arrays, are represented using elements. Because of XML Schema constraints, attributes of these datatypes must be contained in xs:group elements instead. Aside from this small difference, the functionality of the two groups is constructionally identical. Herein, both types of such groups are referred to collectively as "groups."

Inheritance

Inheritance of objects is indicated by nesting groups within each other. Each group should include a "ref" to its immediate parent's group. There is no need to specify the entire parent tree; including the immediate parent will automatically include all parents higher in the tree.

HLA declares a root object named HLAobjectRoot. The root object is not directly represented in the DSL, but may be given attributes in the root group. All objects which inheriet from the root object should include a "ref" to the root object's attribute group.

Linking Attributes to Objects

Currently, attributes and parameters are linked to their objects and interactions by class name. The structure of this design is as such:

An xs:attributeGroup would have the name: "ClassNameAttrs" for attributes, and "ClassNameParams" for parameters. So for example, an object named "Unit" would have an xs:attributeGroup called "UnitAttrs" or "UnitParams."

A xs:group would have the name: "ClassNameGroupAttrs" for attributes, and "ClassNameGroupParams" for parameters. So for example, a class named "Unit" would have an xs:group called "UnitGroupAttrs" or "UnitGroupParams."

Validation

For purposes of schema validation, all object and interaction attributes and parameters are assigned to XML Schema enumerations. These are internal only and do not impact on the model. The organization of the enumerations is decided by the DSL. A DSL may decide, for example, to group all instance attributes (those which change from one instance to the next) separately from class attributes (those which are fixed to the Prototype). This would create groups such as:

<xs:simpleType name="UnitAttrsGlobalEnum">

<xs:restriction base="xs:string">
<xs:enumeration value="MaxHealth"/>
<xs:enumeration value="MaxEnergy"/>
</xs:restriction>
</xs:simpleType>

<xs:simpleType name="UnitAttrsInstanceEnum">

<xs:restriction base="xs:string">
<xs:enumeration value="Health"/>
<xs:enumeration value="Energy"/>
</xs:restriction>
</xs:simpleType>

Example

Here is an example of how groups might be declared in an RTS DSL.

<xs:attributeGroup name="HLAobjectRootAttrs">

<xs:attribute name="MaxHealth" type="HLAinteger16BE"/>
<xs:attribute name="Health" type="HLAinteger16BE"/>
</xs:attributeGroup>

<xs:attributeGroup name="UnitAttrs">

<xs:attributeGroup ref="HLAobjectRootAttrs"/>
<xs:attribute name="MaxEnergy" type="HLAinteger16BE"/>
<xs:attribute name="Energy" type="HLAinteger16BE"/>
</xs:attributeGroup>

<xs:attributeGroup name="StructureAttrs">

<xs:attributeGroup ref="UnitAttrs"/>
<xs:attribute name="Armor" type="HLAinteger16BE"/>
</xs:attributeGroup>

<xs:group name="UnitGroupAttrs">

<xs:attribute name="Stats" type="RecordType"/>
</xs:group>

In this example, the class Unit inherits from the root object, and shows this by including a reference to "HLAobjectRootAttrs." Likewise, Structure inherits from Unit and thus includes "UnitAttrs." Also, Unit has an attribute of a record type, therefore including a "UnitGroupAttrs" group. Since there are no record types declared in the root object, there is no "ref," although one could have been included.