Binding controlled values to an attribute

The controlled values defined in a subject scheme map can be bound to an attribute or an element and attribute pair. This affects the expected behavior for processors and authoring tools.

The <enumerationdef> element binds the set of controlled values to an attribute. Valid attribute values are those that are defined in the set of controlled values. Invalid attribute values are those that are not defined in the set of controlled values. If an enumeration specifies an empty <subjectdef> element that does not reference a set of controlled values, no value is valid for the attribute. An enumeration can also specify an optional default value by using the <defaultSubject> element.

If an enumeration is bound, processors SHOULD validate attribute values against the controlled values that are defined in the subject scheme map. For authoring tools, this validation prevents users from entering misspelled or undefined values. Recovery from validation errors is implementation specific.

The default attribute values that are specified in a subject scheme map apply only if a value is not otherwise specified in the DITA source or as a default value by the XML grammar.

Example: Binding a list of controlled values to the @audience attribute

This section is non-normative.

The following code sample illustrates the use of the <subjectdef> element to define controlled values for types of users. It also binds the controlled values to the @audience attribute:

<subjectScheme>
  <!-- DEFINE TYPES OF USERS -->
  <subjectdef keys="users">
    <subjectdef keys="therapist"/>
    <subjectdef keys="oncologist"/>
    <subjectdef keys="physicist"/>
    <subjectdef keys="radiologist"/>
  </subjectdef>
  <!-- BIND THE SUBJECT TO THE @AUDIENCE ATTRIBUTE
       This restricts the @audience attribute to the following
       values: therapist, oncologist, physicist, radiologist -->
  <enumerationdef>
    <attributedef name="audience"/>
    <subjectdef keyref="users"/>
  </enumerationdef>
</subjectScheme>

When the above subject scheme map is used, the only valid values for the @audience attribute are "therapist", "oncologist", "physicist", and "radiologist". Note that "users" is not a valid value for the @audience attribute, as it merely identifies the parent or container subject.

Example: Binding an attribute to an empty set

This section is non-normative.

The following code sample specifies that there are no valid values for the @outputclass attribute:

<subjectScheme>
  <enumerationdef>
    <attributedef name="outputclass"/>
    <subjectdef/>
  </enumerationdef>
</subjectScheme>

Authors will not be able to specify the @outputclass attribute on an element.