2.5.5.6.1 Example: Redefine the content model for the <topic> element

In this scenario, an information architect for Acme, Incorporated wants to redefine the content model for the topic document type. She wants to omit the <abstract> element and make the <shortdesc> element required; she also wants to omit the <related-links> element and disallow topic nesting.

  1. She creates a .mod file using the following naming conventions: qualiferTagnameConstraint.mod, where qualifer is a string the describes the constraint, and Tagname is the element type name with an initial capital. Her contraint module is named acme-TopicConstraint.mod.
  2. She adds the following content to acme-TopicConstraint.mod:
    <!-- ============================================================= -->
    <!--                    CONSTRAINED TOPIC ENTITIES                 -->
    <!-- ============================================================= -->
    
    <!-- Declares the entity for the constraint module and defines     -->
    <!-- its contribution to the @domains attribute.                   -->
    
    <!ENTITY topic-constraints     
      "(topic basic-Topic-c)"
    >
    
    <!-- Declares the entities referenced in the constrained content  -->
    <!-- model.                                                       -->
    
    <!ENTITY % title            "title">
    <!ENTITY % titlealts        "titlealts">
    <!ENTITY % shortdesc        "shortdesc">
    <!ENTITY % prolog           "prolog">
    <!ENTITY % body             "body">
    
    <!-- Defines the constrained content model for <topic>.            -->
    
    <!ENTITY % topic.content
                           "((%title;), 
                             (%titlealts;)?,
                             (%shortdesc;), 
                             (%prolog;)?, 
                             (%body;)?)"
    >
  3. She then integrates the constraint module into her document-type shell for topic by adding the following section above the "TOPIC ELEMENT INTEGRATION" comment:
    <!-- ============================================================= -->
    <!--                    CONTENT CONSTRAINT INTEGRATION             -->
    <!-- ============================================================= -->
    
    <!ENTITY % topic-constraints-c-def  
      PUBLIC "-//ACME//ELEMENTS DITA Topic Constraint//EN" 
      "acme-TopicConstraint.mod">
    %topic-constraints-c-def;
  4. She then adds the constraint to the list of domains and constraints that need to be included in the value of the @domains attribute for <topic>:
    <!-- ============================================================= -->
    <!--                    DOMAINS ATTRIBUTE OVERRIDE                 -->
    <!-- ============================================================= -->
    
    <!ENTITY included-domains 
                              "&hi-d-att; 
                               &ut-d-att; 
                               &indexing-d-att;
                               &topic-constraints;
      "
    >
  5. After updating the catalog.xml file to include the new constraints file, her work is done.

Return to main page.