Constraint modules enable information architects to restrict the content models or attributes of OASIS-defined DITA grammars. A constraint is a simplification of an XML grammar such that any instance that conforms to the constrained grammar also will conform to the original grammar.
A constraint module can perform the following functions:
For example, a constraint for
<topic>
can require <shortdesc>
, can remove
<abstract>
, and can require that the first child of
<body>
be <p>
. A constraint cannot allow
<shortdesc>
to follow <prolog>
, because the
content model for <topic>
requires that <shortdesc>
precedes
<prolog>
.
Constraint modules can restrict the attributes that are available on an element. They also can limit the set of permissible values for an attribute.
For example, a constraint for <note>
can limit
the set of allowed values for the @type
attribute to "note" and "tip". It also
can omit the @othertype
attribute, since it is needed only when the value of
the @type
attribute is "other".
Constraint modules can restrict the set of extension elements that are provided in a domain. They also can restrict the content models for the extension elements.
For example, a constraint on the programming domain can reduce the
list of included extension elements to <codeph>
and
<codeblock>
.
For example, a constraint module can replace the <ph>
element with the domain-provided elements, making <ph>
unavailable.