DTD: Coding requirements for structural and element-domain modules
This section is non-normative.
This topic covers general coding requirements for defining element types in both structural and element-domain vocabulary modules.
Module files
A vocabulary module that defines a structural or element-domain specialization is composed of two files:
- Definition module file
- This (.mod) file declares the element names, content models, and attribute lists for the element types that are defined in the vocabulary module.
- Entity declaration file
- This (.ent) file declares the general and parameter entities that are used to integrate the vocabulary module into a document-type shell.
Element definitions
A structural or element-domain vocabulary module contains a declaration for each element type that is named by the module. While the XML standard allows content models to refer to undeclared element types, the DITA standard does not permit this. All element types or attribute lists that are named within a vocabulary module are declared in one of the following objects:
- The vocabulary module
- A base module of which the vocabulary module is a direct or indirect specialization
- (For structural modules) A required domain module
The following components make up a single element definition in a DITA DTD-based vocabulary module.
- Element name entities
-
For each element type, there is a parameter entity with a name that matches the element-type name. The value is the element-type name.
Example
This section is non-normative.
For example:
<!ENTITY % topichead "topichead">
The parameter entity provides a layer of abstraction when setting up content models. It can be redefined in a document-type shell in order to create domain extensions or implement element configuration (constraint and expansion).
Element name entities for a vocabulary module typically are grouped together at the top of the vocabulary module. They can occur in any order.
- Content-model parameter entity
-
For each element type, there is a parameter entity that defines the content model. The name of the parameter entity is
tagname.content
, and the value is the content model definition.Example
This section is non-normative.
For example:
<!ENTITY % topichead.content "((%topicmeta;)?, (%data.elements.incl; | %navref; | %topicref;)*) ">
- Attribute-list parameter entity
-
For each element type, there is a parameter entity that declares the attributes that are available on the element. The name of the parameter entity is
tagname.attributes
, and the value is a list of the attributes that are used by the element type (except for@class
).Example
This section is non-normative.
For example:
<!ENTITY % topichead.attributes "keys CDATA #IMPLIED %topicref-atts; %univ-atts;" >
Consistent use and naming of the
tagname.content
parameter entity enables the use of element-configuration modules (constraint and expansion) to redefine the content model. - Element declaration
-
For each element type, there is an element declaration that consists of a reference to the content-model parameter entity.
Example
This section is non-normative.
For example:
<!ELEMENT topichead %topichead.content;>
- Attribute list declaration
-
For each element type, there is an attribute-list declaration that consists of a reference to the attribute-list parameter entity.
Example
This section is non-normative.
For example:
<!ATTLIST topichead %topichead.attributes;>
- Specialization attribute declarations
-
A vocabulary module defines a
@class
attribute for every element that is declared in the module. The value of the attribute is constructed according to the rules in The class attribute rules and syntax.Example
This section is non-normative.
For example, the
ATTLIST
definition for the<topichead>
element (a specialization of the<topicref>
element in the base map type) includes the definition of the@class
attribute, as follows:<!ATTLIST topichead class CDATA "+ map/topicref mapgroup-d/topichead ">
Definition of the <topichead>
element
This section is non-normative.
The following code sample shows how the <topichead>
element is
defined in mapGroup.mod. Ellipses indicate where the code sample has
been snipped for brevity.
<!-- ============================================================= -->
<!-- ELEMENT NAME ENTITIES -->
<!-- ============================================================= -->
<!ENTITY % topichead "topichead" >
...
<!-- ============================================================= -->
<!-- ELEMENT DECLARATIONS -->
<!-- ============================================================= -->
<!-- LONG NAME: Topichead -->
<!ENTITY % topichead.content
"((%topicmeta;)?,
(%data.elements.incl; |
%navref; |
%topicref;)*)"
>
<!ENTITY % topichead.attributes
"keys
CDATA
#IMPLIED
%topicref-atts;
%univ-atts;"
>
<!ELEMENT topichead %topichead.content;>
<!ATTLIST topichead %topichead.attributes;>
...
<!-- ============================================================= -->
<!-- SPECIALIZATION ATTRIBUTE DECLARATIONS -->
<!-- ============================================================= -->
...
<!ATTLIST topichead class CDATA "+ map/topicref mapgroup-d/topichead ">
<!-- ================== End of DITA Map Group Domain ==================== -->