Constraint module XSD coding requirements

Darwin Information Typing Architecture (DITA) Version 1.2

A given constraint definition module corresponds to exactly one topic, map, or domain vocabulary module.

Requirements for constraint definition modules

Topic and map type constraint modules should be named "qualifiertagnameConstraints.xsd", where qualifier is specific to the constraints module and characterizes it, e.g. "strict", "requiredTitle", etc. and tagname is the name of the element type to which the constraints apply, e.g. "topic", "p", "myNewTopicType", etc.

Domain constraint modules should be named "qualifierdomainDomainConstraints.xsd", where qualifier is specific to the constraints module and characterizes it, e.g. "strict", "requiredTitle", etc. and domain is the name of the domain to which the constraints apply, e.g. "hi-d", "pr-d", "mydomain-d", etc.

Because of restrictions on the redefine feature of XML Schema, it is sometimes necessary to use an intermediate level of redefinition, which requires a separate XSD document. In that case, the intermediate XSD document should be named "qualifierdomainDomainConstraintsInt.xsd".

For each extension element type in the base vocabulary module whose content model or attributes are to be constrained in the constraint module, there must be a xs:redefine element that defines the restricted content model for the base element. Attributes for an element type may be constrained as part of the redefinition of the complex type.

non-normative: When adding an xs:redefine element to an existing document type shell you must remove any xs:include elements that refer to the XSD module to which the redefine is applied. For example, to redefine groups defined in commonElementsMod.xsd you must remove any xs:include of commonElementsMod.xsd.
Figure. Example of a structural constraint module. The following code sample shows how the <topic> element may be constrained to create a stricter form of the element, in this case, disallowing the <body> element. This xs:redefine element would be placed in a file named noBodyTopicConstraint.xsd.
...
<xs:redefine schemaLocation="urn:oasis:names:tc:dita:xsd:topicMod.xsd:1.2">
  <xs:group name="topic.content">
    <xs:sequence>
      <xs:sequence>
        <xs:group ref="title"/>
        <xs:group ref="titlealts" minOccurs="0"/>
        <xs:choice minOccurs="1" >
          <xs:group ref="shortdesc" />
          <xs:group ref="abstract" />
        </xs:choice>
        <xs:group ref="prolog" minOccurs="0"/>
        <!--<xs:group ref="body" minOccurs="0"/>-->
        <xs:group ref="related-links" minOccurs="0"/>
        <xs:group ref="topic-info-types" minOccurs="0"
          maxOccurs="unbounded"/>
      </xs:sequence>
    </xs:sequence>
  </xs:group>
</xs:redefine>
...

For selective restriction there must be a group with a subset list of extension elements for a domain in a reusable constraints module. The group name should be named "qualifierdomain-c-tagname" where qualifier is a description for the constraint vocabulary constraint module file, domain is the name of the domain, map, or topic being constrained, and tagname is the name of the extension element being restricted.

Figure. Example of a domain constraint module. The following code sample shows how the highlight domain can be constrained to limit the elements that are available in the domain to only <b> and <i>. These declarations would be placed in a file named basicHighlightConstraint.xsd.
...
<xs:group name="basicHighlight-c-ph">
  <xs:choice>
    <xs:element ref="b"/>
    <xs:element ref="i"/>
  </xs:choice>
</xs:group>
...

Requirements for shell document types

Document type shell schemas that integrate constraint modules must reflect these requirements:
  • For content model constraints, must include the constraint module instead of the vocabulary module that it constrains.
  • For selective extension, must include the extension subset constraint module and use that group for domain or topic type extension.
  • Must declare the constraints in the domains attribute.
Figure. strictTopic.xsd (shell). The following code sample demonstrates the markup used to constrain the standard <topic> element. These declarations would be placed in a shell file named "strictTopic.xsd".
...
<xs:include schemaLocation="basicHighlightConstraint.xsd"/>
...
<xs:redefine schemaLocation="commonElementGrp.xsd">
  <xs:group name="ph">
    <!-- drop base <ph> as well as apply basic subset of highlight domain -->
    <xs:choice>
      <xs:group ref="basicHighlight-c-ph"/>
    </xs:choice>
  </xs:group>
  ...
</xs:redefine>

<xs:redefine schemaLocation="strictTopicConstraint.xsd">
  <xs:complexType name="topic.class">
    <xs:complexContent>
      <xs:extension base="topic.class">
        <!-- declare the constraint of topic and highlight vocabulary modules
             and compatibility of constrained highlight with subset of 
             topic constraints -->
        <xs:attribute name="domains" type="xs:string"
            default="(topic noBasePhrase-c)
                     (topic strictTopic-c)
                     (topic strictTopic-c hi-d basicHighlight-c)"/>
        ...
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  ...
</xs:redefine>
...