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

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.

Figure 1. 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. This xs:redefine element would be placed in a file named strictTopicConstraint.xsd.
...
<xs:redefine schemaLocation="topicMod.xsd">
  <!-- constrain content of <topic> element -->
  <xs:complexType name="topic.class">
    <xs:complexContent>
      <xs:restriction base="topic.content">
        <xs:sequence>
          <xs:group ref="title"/>
          <xs:group ref="titlealts" minOccurs="0"/>
          <!-- make required -->
          <xs:choice>
            <xs:group ref="shortdesc" />
            <xs:group ref="abstract" />
          </xs:choice>
          <xs:group ref="prolog" minOccurs="0"/>
          <xs:group ref="body" minOccurs="0"/>
          <!-- remove <related-links> -->
          <xs:group ref="topic-info-types" minOccurs="0" maxOccurs="unbounded"/>
        </xs:sequence>
      </xs:restriction>
    </xs:complexContent>
  </xs:complexType>
  ...
</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 2. 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 3. 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>
...

Return to main page.

DITA v1.2 CD 03
Copyright © OASIS Open 2005, 2010. All Rights Reserved.