###### 2.1.4.4.2 Constraint module XSD coding requirements

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 "qualifier tagnameConstraints.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 "qualifier domainDomainConstraints.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 "qualifier domainDomainConstraintsInt.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.

Note: 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 2-11 Example of a structural constraint module

    ...
    <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 "qualifier domain-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 2-12 Example of a domain constraint module

    ...
    <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 2-13 strictTopic.xsd (shell)

    ...
    <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>
    ...

Previous Topic: 2.1.4.4.1 Constraint module DTD coding requirements

Next Topic: 2.1.4.4.3 Conref and generalization for constraint modules

Parent Topic: 2.1.4.4 Constraints

Sibling Topics:

2.1.4.4.1 Constraint module DTD coding requirements

2.1.4.4.3 Conref and generalization for constraint modules

2.1.4.4.4 Examples of constraint declaration modules