Example: Apply multiple constraints to a single document-type shell using RNG
This section is non-normative.
In this scenario, the DITA architect wants to apply multiple constraints to a document-type shell.
Example
This section is non-normative.
Here is a list of the constraint modules and what they do:
| File name | What it constrains | Details | 
|---|---|---|
| example-TopicConstraint.mod | <topic> | 
          
            
  | 
        
| example-SectionConstraint.mod | <section> | 
          Makes @id required | 
        
| Not applicable | Highlighting domain | Reduces the highlighting domain elements to
              <b> and
            <i> | 
        
| Not applicable | <ph> | 
          Remove the <ph> element, allowing
            only domain extensions | 
        
The constraint modules that target the
          <topic> and <section
        > elements must be combined, since both elements are
        defined in topicMod.rng. The other constraints
        can be implemented directly in the document-type shell.
- 
          
The DITA architect creates a constraint module that combines the constraints from example-TopicConstraint.mod and example-SectionConstraint.mod:
<?xml version="1.0" encoding="UTF-8"?> <?xml-model href="urn:pubid:oasis:names:tc:dita:rng:vocabularyModuleDesc.rng" schematypens="http://relaxng.org/ns/structure/1.0"?> <grammar xmlns="http://relaxng.org/ns/structure/1.0" xmlns:dita="http://dita.oasis-open.org/architecture/2005/" xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"> <div> <a:documentation>CONTENT MODEL AND ATTRIBUTE LIST OVERRIDES</a:documentation> <include href="topicMod.rng"> <define name="section.attributes"> <attribute name="id"> <data type="NMTOKEN"/> </attribute> <ref name="conref-atts"/> <ref name="select-atts"/> <ref name="localization-atts"/> <optional> <attribute name="outputclass"/> </optional> </define> <define name="topic.content"> <ref name="title"/> <ref name="shortdesc"/> <optional> <ref name="prolog"/> </optional> <optional> <ref name="body"/> </optional> </define> </include> </div> </grammar> - 
          
In the document-type shell, they integrate the constraint module (and remove the inclusion statement for topicMod.rng):
<div> <a:documentation>ELEMENT-TYPE CONFIGURATION INTEGRATION</a:documentation> <include href="acme-SectionTopicContraintMod.rng"/> </div> - 
          
To constrain the highlight domain, they modify the include statement for the domain module:
<div> <a:documentation>MODULE INCLUSIONS</a:documentation> ... <include href="highlightDomain.rng"> <define name="line-through.element"> <notAllowed/> </define> <define name="overline.element"> <notAllowed/> </define> <define name="sub.element"> <notAllowed/> </define> <define name="sup.element"> <notAllowed/> </define> <define name="tt.element"> <notAllowed/> </define> <define name="u.element"> <notAllowed/> </define> </include> .. </div> - Finally, to disallow 
<ph>, they add the following statement to the constraint module:<define name="ph.element"> <notAllowed/> </define>