E. Developing DTDs with defined and extended modules

Contents

This section is informative.

The primary purpose of defining XHTML modules and a general modularization methodology is to ease the development of document types that are based upon XHTML. These document types may extend XHTML by integrating additional capabilities (e.g., [SMIL]), or they may define a subset of XHTML for use in a specialized device. This section describes the techniques that document type designers must use in order to take advantage of the XML DTD implementation of this modularization architecture. It does this by applying the XHTML Modularization techniques in progressively more complex ways, culminating in the creation of a complete document type from disparate modules.

Note that in no case do these examples require the modification of the XHTML-provided module file entities themselves. The XHTML module file entities are completely parameterized, so that it is possible through separate module definitions and driver files to customize the definition and the content model of each element and each element's hierarchy.

Finally, remember that most users of XHTML are not expected to be DTD authors. DTD authors are generally people who are defining specialized markup that will improve the readability, simplify the rendering of a document, or ease machine-processing of documents, or they are client designers that need to define the specialized DTD for their specific client. Consider these cases:

E.1. Defining additional attributes

In some cases, an extension to XHTML can be as simple as additional attributes. Attributes can be added to an element just by specifying an additional ATTLIST for the element, for example:

<!ATTLIST %a.qname;
      %MyModule.pfx;myattr   CDATA        #IMPLIED
      %MyModule.xmlns.extras.attrib;
>

would add the "myattr" attribute, with an optional prefix defined by "%MyModule.pfx", with a value type of CDATA, to the "a" element. This works because XML permits the definition or extension of the attribute list for an element at any point in a DTD. For a discussion of qualified names and namespace prefixes, see Defining the Namespace of a Module.

Naturally, adding an attribute to a DTD does not mean that any new behavior is defined for arbitrary clients. However, a content developer could use an extra attribute to store information that is accessed by associated scripts via the Document Object Model (for example).

E.2. Defining additional elements

Defining additional elements is only slightly more complicated than defining additional attributes. Basically, DTD authors should write the element declaration for each element:

<!-- In the qname sub-module -->
<!ENTITY % MyModule.myelement.qname  "%MyModule.pfx;myelement" >
<!ENTITY % MyModule.myotherelement.qname  "%MyModule.pfx;myotherelement" >

<!-- In the declaration sub-module -->
<!ELEMENT %MyModule.myelement.qname; 
           ( #PCDATA | %MyModule.myotherelement.qname; )* >
<!ATTLIST %MyModule.myelement.qname;
          myattribute    CDATA    #IMPLIED
>

<!ELEMENT %MyModule.myotherelement.qname; EMPTY >

After the elements are defined, they need to be integrated into the content model. Strategies for integrating new elements or sets of elements into the content model are addressed in the next section.

E.3. Defining the content model for a collection of modules

Since the content model of XHTML modules is fully parameterized, DTD authors may modify the content model for every element in every module. The details of the DTD module interface are defined in Building DTD Modules. Basically there are two ways to approach this modification:

  1. Re-define the ".content" parameter entity for each element.
  2. Re-define one or more of the global content model entities (normally via the ".extras" parameter entity).

The strategy taken will depend upon the nature of the modules being combined and the nature of the elements being integrated. The remainder of this section describes techniques for integrating two different classes of modules.

E.3.1. Integrating a stand-alone module into XHTML

When a module (and remember, a module can be a collection of other modules) contains elements that only reference each other in their content model, it is said to be "internally complete". As such, the module can be used on its own; (for example, you could define a DTD that was just that module, and use one of its elements as the root element). Integrating such a module into XHTML is a three step process:

  1. Decide what element(s) can be thought of as the root(s) of the new module.
  2. Decide where these elements need to attach in the XHTML content tree.
  3. Then, for each attachment point in the content tree, add the root element(s) to the content definition for the XHTML elements.

Consider attaching the elements defined above. In that example, the element myelement is the root. To attach this element under the img element, and only the img element, of XHTML, the following would work:

<!ENTITY % img.content "( %MyModule.myelement.qname; )*">

A DTD defined with this content model would allow a document like the following fragment:

<img src="...">
<myml:myelement >This is content of a locally defined element</myml:myelement>
</img>

It is important to note that normally the img element has a content model of EMPTY. By adding myelement to that content model, we are really just replacing EMPTY with myelement. In the case of other elements that already have content models defined, the addition of an element would require the restating of the existing content model in addition to myelement.

E.3.2. Mixing a new module throughout the modules in XHTML

Extending the example above, to attach this module everywhere that the %Flow.mix content model group is permitted, would require something like the following:

<!ENTITY % Misc.extra
     "| %MyModule.myelement.qname;" >

Since the %Misc.extra content model class is used in the %Misc.class parameter entity, and that parameter entity is used throughout the XHTML modules, the new module would become available throughout an extended XHTML document type.

E.4. Creating a new DTD

So far the examples in this section have described the methods of extending XHTML and XHTML's content model. Once this is done, the next step is to collect the modules that comprise the DTD into a single DTD driver, incorporating the new definitions so that they override and augment the basic XHTML definitions as appropriate.

E.4.1. Creating a simple DTD

Using the trivial example above, it is possible to define a new DTD that uses and extends the XHTML modules pretty easily. First, define the new elements and their content model in a module:

You can download this version of this file from http://www.w3.org/TR/2010/REC-xhtml-modularization/DTD/examples/simpleml-model-1.mod. The latest version is available at http://www.w3.org/MarkUp/DTD/examples/simpleml-model-1.mod.

<!-- File: simpleml-model-1.mod -->

<!-- Declare a Parameter Entity (PE) that defines any external namespaces 
     that are used by this module -->

<!-- Set the PE that is used in every ATTLIST in this module 
     NS.prefixed.attrib is initialized in the xhtml-qname module, and
     SimpleML.ns.noprefix.attrib is initialized in the SimpleML DTD driver 
     file.-->
<!ENTITY % SimpleML.xmlns.attrib
  "%NS.decl.attrib;"
>

<!ENTITY % SimpleML.Common.attrib
  "%SimpleML.xmlns.attrib;
   id           ID           #IMPLIED"
>

<!ENTITY % SimpleML.element.qname "%SimpleML.pfx;element" >
<!ENTITY % SimpleML.otherelement.qname "%SimpleML.pfx;otherelement" >

<!ELEMENT %SimpleML.element.qname;
          ( #PCDATA | %SimpleML.otherelement.qname; )* >
<!ATTLIST %SimpleML.element.qname;
          myattribute   CDATA  #IMPLIED
          %SimpleML.Common.attrib;
>
<!ELEMENT %SimpleML.otherelement.qname; EMPTY >
<!ATTLIST %SimpleML.otherelement.qname;
          %SimpleML.Common.attrib;
>

<!ENTITY % SimpleML.img.myattr.qname "%SimpleML.pfx;myattr" >
<!ATTLIST %img.qname;
          %SimpleML.img.myattr.qname;  CDATA  #IMPLIED
>

<!-- Add our elements to the XHTML content model -->
<!ENTITY % Misc.class
     "| %SimpleML.element.qname;" >

<!-- Now bring in the XHTML Basic content model -->
<!ENTITY % xhtml-basic-model.mod
     PUBLIC "-//W3C//ENTITIES XHTML Basic 1.0 Document Model 1.0//EN"
            "http://www.w3.org/TR/xhtml-basic/xhtml-basic10-model-1.mod" >
%xhtml-basic-model.mod;

Next, define the DTD driver for the new language:

You can download this version of this file from http://www.w3.org/TR/2010/REC-xhtml-modularization/DTD/examples/simpleml-1_0.dtd. The latest version is available at http://www.w3.org/MarkUp/DTD/examples/simpleml-1_0.dtd.

<!-- file: simpleml-1_0.dtd -->

<!-- Bring in the XHTML datatypes -->
<!ENTITY % xhtml-datatypes.mod
     PUBLIC "-//W3C//ENTITIES XHTML Datatypes 1.0//EN"
            "http://www.w3.org/MarkUp/DTD/xhtml-datatypes-1.mod" >
%xhtml-datatypes.mod;

<!-- Declare the actual namespace of this module -->
<!ENTITY % SimpleML.xmlns "http://www.example.com/xmlns/simpleml1" >

<!-- By default, disable prefixing of new module -->
<!ENTITY % NS.prefixed "IGNORE" >
<!ENTITY % SimpleML.prefixed "%NS.prefixed;" > 

<!-- Default prefix for module elements and attributes -->
<!ENTITY % SimpleML.prefix "simpleml" >

<!-- If this module's namespace is prefixed -->
<![%SimpleML.prefixed;[
  <!ENTITY % SimpleML.pfx  "%SimpleML.prefix;:" >
]]>
<!ENTITY % SimpleML.pfx  "" >

<![%SimpleML.prefixed;[
  <!ENTITY % SimpleML.xmlns.extra.attrib 
       "xmlns:%SimpleML.prefix; %URI.datatype; #FIXED '%SimpleML.xmlns;'" >
]]>
<!ENTITY % SimpleML.xmlns.extra.attrib "" >

<!ENTITY % XHTML.xmlns.extra.attrib
       "%SimpleML.xmlns.extra.attrib;"
>
<!-- Set the content model for our language -->
<!ENTITY % xhtml-model.mod
     SYSTEM "simpleml-model-1.mod" >
<!-- Instantiate xhtml basic's DTD to do all the work -->
<!ENTITY % xhtml-basic.dtd
     PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN" 
            "http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd" >
%xhtml-basic.dtd;

When using this DTD, it is possible to enable the use of XML namespace prefixes. When so doing, the start of a document using this new DTD might look like:

You can download this version of this file from http://www.w3.org/TR/2010/REC-xhtml-modularization/DTD/examples/simple-prefixed.html. The latest version is available at http://www.w3.org/MarkUp/DTD/examples/simple-prefixed.html.

<!DOCTYPE html SYSTEM "simpleml-1_0.dtd" [
  <!ENTITY % SimpleML.prefixed "INCLUDE">
]>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:simpleml="http://www.example.com/xmlns/simpleml1" >
<head>
<title>An example using defaults</title>
</head>
<body>
<p>This is content in the XHTML namespace</p>
<simpleml:element>
  This is content in the SimpleML namespace.
  <simpleml:otherelement />
</simpleml:element>
<p><img src="missing" alt="Missing image" simpleml:myattr="value"/></p>
</body>
</html>

E.4.2. Creating a DTD by extending XHTML

Next, there is the situation where a complete, additional, and complex module is added to XHTML (or to a subset of XHTML). In essence, this is the same as in the trivial example above, the only difference being that the module being added is incorporated in the DTD by reference rather than explicitly including the new definitions in the DTD.

One such complex module is the DTD for [MATHML]. In order to combine MathML and XHTML into a single DTD, an author would just decide where MathML content should be legal in the document, and add the MathML root element to the content model at that point. First, define a content model module that instantiates the MathML DTD and connects it to the content model:

<!-- File: mathml-model.mod -->
<!ENTITY % XHTML1-math
     PUBLIC "-//W3C//DTD MathML 2.0//EN"
            "http://www.w3.org/TR/MathML2/dtd/mathml2.dtd" >
%XHTML1-math;

<!ENTITY % Inlspecial.extra 
     "%a.qname; | %img.qname; | %object.qname; | %map.qname; 
      | %Mathml.Math.qname;" >

Next, define a DTD driver that identifies our new content model module as the content model for the DTD, and hands off processing to the XHTML 1.1 driver (for example):

<!-- File: xhtml-mathml.dtd -->
<!ENTITY % xhtml-model.mod
      SYSTEM "mathml-model.mod" >
<!ENTITY % xhtml11.dtd
     PUBLIC "-//W3C//DTD XHTML 1.1//EN"
            "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" >
%xhtml11.dtd;

E.4.3. Creating a DTD by removing and replacing XHTML modules

Another way in which DTD authors may use XHTML modules is to define a DTD that is a subset of an XHTML family document type (because, for example, they are building devices or software that only supports a subset of XHTML). Doing this is only slightly more complex than the previous example. The basic steps to follow are:

  1. Take an XHTML family DTD as the basis of the new document type (we will use XHTML 1.1).
  2. Select the modules to remove from that DTD.
  3. Define a new DTD that "IGNOREs" the modules.
  4. Introduce some new modules.

For example, consider a device that uses XHTML modules, but without forms or tables. The DTD for such a device would look like this:

<!-- File: xhtml-simple.dtd -->
<!ENTITY % xhtml-form.module "IGNORE" >
<!ENTITY % xhtml-table.module "IGNORE" >
<!ENTITY % xhtml-table.module "IGNORE" >
<!-- Bring in the basic tables module -->
<!ENTITY % xhtml-basic-table.mod
     PUBLIC "-//W3C//ELEMENTS XHTML Basic Tables 1.0//EN"
       "http://www.w3.org/MarkUp/DTD/xhtml-basic-table-1.mod"
>
%xhtml-basic-table.mod;
<!ENTITY % xhtml11.mod
     PUBLIC "-//W3C//DTD XHTML 1.1//EN"
            "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" >
%xhtml11.mod;

Note that this does not actually modify the content model for the XHTML 1.1 DTD. However, since XML ignores elements in content models that are not defined, the form and table elements are dropped from the model automatically.

E.4.4. Creating a new DTD

Finally, some DTD authors may wish to start from scratch, using the XHTML Modularization framework as a toolkit for building a new markup language. This language must be made up of the minimal, required modules from XHTML. It may also contain other XHTML-defined modules or any other module that the author wishes to employ. In this example, we will take the XHTML required modules, add some XHTML-defined modules, and also add in the module we defined above.

The first step is to use the XHTML-provided template for a new qualified names module, modified to define the qualified names and namespace for our new elements.

You can download this version of this file from http://www.w3.org/TR/2010/REC-xhtml-modularization/DTD/examples/myml-qname-1.mod. The latest version is available at http://www.w3.org/MarkUp/DTD/examples/myml-qname-1.mod.

<!-- file: myml-qname-1.mod -->

<!-- Bring in the datatypes - we use the URI.datatype PE for declaring the
     xmlns attributes. -->
<!ENTITY % MyML-datatypes.mod
         PUBLIC "-//W3C//ENTITIES XHTML Datatypes 1.0//EN"
         "http://www.w3.org/MarkUp/DTD/xhtml-datatypes-1.mod" >
%MyML-datatypes.mod;

<!-- By default, disable prefixing of this module -->
<!ENTITY % NS.prefixed "IGNORE" >
<!ENTITY % MyML.prefixed "%NS.prefixed;" >

<!-- Declare the actual namespace of this module -->
<!ENTITY % MyML.xmlns "http://www.example.com/xmlns/myml" >

<!-- Declare the default prefix for this module -->
<!ENTITY % MyML.prefix "myml" >

<!-- If this module's namespace is prefixed -->
<![%MyML.prefixed;[
  <!ENTITY % MyML.pfx  "%MyML.prefix;:" >
]]>
<!ENTITY % MyML.pfx  "" >

<!-- This entity is ALWAYS prefixed, for use when adding our
     attributes to an element in another namespace -->
<!ENTITY % MyML.xmlns.attrib.prefixed
   "xmlns:%MyML.prefix;  %URI.datatype;  #FIXED '%MyML.xmlns;'"
>

<!-- Declare a Parameter Entity (PE) that defines any external namespaces 
     that are used by this module -->
<!ENTITY % MyML.xmlns.extra.attrib "" >

<!-- If we want to use xhtml namespace attributes on our elements, then
     we need a prefix for them; default to xhtml. -->
<!ENTITY % XHTML.prefix "xhtml" >

<!-- Declare a PE that defines the xmlns attributes for use by MyML. -->
<![%MyML.prefixed;[
<!ENTITY % MyML.xmlns.attrib
   "%MyML.xmlns.attrib.prefixed;
    %MyML.xmlns.extra.attrib;"
>
<!-- Make sure that the MyML namespace attributes are included on the XHTML
     attribute set -->
<!ENTITY % XHTML.xmlns.extra.attrib
    "xmlns:%XHTML.prefix;  %URI.datatype;  #FIXED 'http://www.w3.org/1999/xhtml'
    %MyML.xmlns.attrib;" >
]]>
<!-- if we are not prefixed, then our elements should have the default
     namespace AND the prefixed namespace is added to the XHTML set
     because our attributes can be referenced on those elements
-->
<!ENTITY % MyML.xmlns.attrib
   "xmlns   %URI.datatype;  #FIXED '%MyML.xmlns;'
    %MyML.xmlns.extra.attrib;"
>
<!ENTITY % XHTML.xmlns.extra.attrib
   "xmlns:%XHTML.prefix;  %URI.datatype;  #FIXED 'http://www.w3.org/1999/xhtml'
    %MyML.xmlns.attrib.prefixed;"
>
<!-- Now declare the element names -->

<!ENTITY % MyML.myelement.qname "%MyML.pfx;myelement" >
<!ENTITY % MyML.myotherelement.qname "%MyML.pfx;myotherelement" >

Next, define a module that defines the elements and attributes using the XHTML provided template.

You can download this version of this file from http://www.w3.org/TR/2010/REC-xhtml-modularization/DTD/examples/myml-elements-1.mod. The latest version is available at http://www.w3.org/MarkUp/DTD/examples/myml-elements-1.mod.

<!-- ...................................................................... -->
<!-- My Elements Module ................................................... -->
<!-- file: myml-elements-1_0.mod

     PUBLIC "-//MY COMPANY//ELEMENTS XHTML MyML Elements 1.0//EN"
     SYSTEM "http://example.com/DTDs/myml-elements-1_0.mod"

     xmlns:myml="http://example.com/DTDs/myml-1_0.dtd"
     ...................................................................... -->

<!-- My Elements Module

     myelement
     myotherelement

     This module has no purpose other than to provide structure for some
     PCDATA content.
-->

<!ELEMENT %MyML.myelement.qname;
     ( #PCDATA | %MyML.myotherelement.qname; )* >
<!ATTLIST %MyML.myelement.qname;
     myattribute    CDATA   #IMPLIED
     %MyML.xmlns.attrib;
     %XHTML.global.common.attrib;
>

<!ELEMENT %MyML.myotherelement.qname; EMPTY >
<!ATTLIST %MyML.myotherelement.qname;
     %MyML.xmlns.attrib;
     %XHTML.global.common.attrib;
>

<!ENTITY % MyML.img.myattr.qname "%MyML.prefix;:myattr" >
<!ATTLIST %img.qname;
      %MyML.img.myattr.qname;   CDATA  #IMPLIED
      %MyML.xmlns.attrib.prefixed;
>

<!-- end of myml-elements-1_0.mod -->

Now, build a content model description that hooks the new elements and attributes into the other XHTML elements. The following example is patterned after the XHTML Basic content model, but is a complete, free-standing content model module:

You can download this version of this file from http://www.w3.org/TR/2010/REC-xhtml-modularization/DTD/examples/myml-model-1.mod. The latest version is available at http://www.w3.org/MarkUp/DTD/examples/myml-model-1.mod.

<!-- ...................................................................... -->
<!-- MyML Model Module  ................................................... -->
<!-- file: myml-model-1.mod

     PUBLIC "-//MY COMPANY//ELEMENTS XHTML MyML Model 1.0//EN"
     SYSTEM "http://example.com/DTDs/myml-model-1_0.mod"

     xmlns:myml="http://www.example.com/xmlns/myml"
     ...................................................................... -->

<!-- Define the content model for Misc.extra -->
<!ENTITY % Misc.class
     "| %MyML.myelement.qname; ">

<!-- ....................  Inline Elements  ...................... -->

<!ENTITY % HeadOpts.mix  
     "( %meta.qname; )*" >

<!ENTITY % I18n.class "" >

<!ENTITY % InlStruct.class "%br.qname; | %span.qname;" >

<!ENTITY % InlPhras.class
     "| %em.qname; | %strong.qname; | %dfn.qname; | %code.qname; 
      | %samp.qname; | %kbd.qname; | %var.qname; | %cite.qname; 
      | %abbr.qname; | %acronym.qname; | %q.qname;" >

<!ENTITY % InlPres.class
     "" >

<!ENTITY % Anchor.class "| %a.qname;" >

<!ENTITY % InlSpecial.class "| %img.qname; " >

<!ENTITY % Inline.extra "" >

<!-- %Inline.class; includes all inline elements,
     used as a component in mixes
-->
<!ENTITY % Inline.class
     "%InlStruct.class;
      %InlPhras.class;
      %InlPres.class;
      %Anchor.class;
      %InlSpecial.class;"
>

<!-- %InlNoAnchor.class; includes all non-anchor inlines,
     used as a component in mixes
-->
<!ENTITY % InlNoAnchor.class
     "%InlStruct.class;
      %InlPhras.class;
      %InlPres.class;
      %InlSpecial.class;"
>

<!-- %InlNoAnchor.mix; includes all non-anchor inlines
-->
<!ENTITY % InlNoAnchor.mix
     "%InlNoAnchor.class;
      %Misc.class;"
>

<!-- %Inline.mix; includes all inline elements, including %Misc.class;
-->
<!ENTITY % Inline.mix
     "%Inline.class;
      %Misc.class;"
>

<!-- .....................  Block Elements  ...................... -->

<!ENTITY % Heading.class 
     "%h1.qname; | %h2.qname; | %h3.qname; 
      | %h4.qname; | %h5.qname; | %h6.qname;" >

<!ENTITY % List.class "%ul.qname; | %ol.qname; | %dl.qname;" >

<!ENTITY % BlkStruct.class "%p.qname; | %div.qname;" >

<!ENTITY % BlkPhras.class 
     "| %pre.qname; | %blockquote.qname; | %address.qname;" >

<!ENTITY % BlkPres.class "" >

<!ENTITY % Block.extra "" >

<!-- %Block.class; includes all block elements,
     used as an component in mixes
-->
<!ENTITY % Block.class
     "%BlkStruct.class;
      %BlkPhras.class;
      %BlkPres.class;
      %Block.extra;"
>

<!-- %Block.mix; includes all block elements plus %Misc.class;
-->
<!ENTITY % Block.mix
     "%Heading.class;
      | %List.class;
      | %Block.class;
      %Misc.class;"
>

<!-- ................  All Content Elements  .................. -->

<!-- %Flow.mix; includes all text content, block and inline
-->
<!ENTITY % Flow.mix
     "%Heading.class;
      | %List.class;
      | %Block.class;
      | %Inline.class;
      %Misc.class;"
>

<!-- special content model for pre element -->
<!ENTITY % pre.content
    "( #PCDATA
     | %Inline.class; )*"
>

<!-- end of myml-model-1.mod -->

Finally, use the XHTML-provided template for a new DTD, modified as appropriate for our new markup language:

You can download this version of this file from http://www.w3.org/TR/2010/REC-xhtml-modularization/DTD/examples/myml-1_0.dtd. The latest version is available at http://www.w3.org/MarkUp/DTD/examples/myml-1_0.dtd.

<!-- ....................................................................... -->
<!-- MYML DTD  ............................................................. -->
<!-- file: myml-1_0.dtd -->

<!-- This is the DTD driver for myml 1.0.

     Please use this formal public identifier to identify it:

         "-//MY COMPANY//DTD XHTML MYML 1.0//EN"

     And this namespace for myml-unique elements:

         xmlns:myml="http://www.example.com/xmlns/myml"
-->
<!ENTITY % XHTML.version  "-//MY COMPANY//DTD XHTML MYML 1.0//EN" >

<!-- reserved for use with document profiles -->
<!ENTITY % XHTML.profile  "" >

<!-- Tell the framework to use our qualified names module as an extra qname
driver -->
<!ENTITY % xhtml-qname-extra.mod
     SYSTEM "myml-qname-1.mod" >

<!-- Define the Content Model for the framework to use -->
<!ENTITY % xhtml-model.mod
     SYSTEM "myml-model-1.mod" >

<!-- Disable bidirectional text support -->
<!ENTITY % XHTML.bidi  "IGNORE" >

<!-- Bring in the XHTML Framework -->
<!ENTITY % xhtml-framework.mod
     PUBLIC "-//W3C//ENTITIES XHTML Modular Framework 1.0//EN"
            "http://www.w3.org/MarkUp/DTD/xhtml-framework-1.mod" >
%xhtml-framework.mod;

<!-- Basic Text Module (Required)  ............................... -->
<!ENTITY % xhtml-text.mod
     PUBLIC "-//W3C//ELEMENTS XHTML Basic Text 1.0//EN"
            "http://www.w3.org/MarkUp/DTD/xhtml-text-1.mod" >
%xhtml-text.mod;

<!-- Hypertext Module (required) ................................. -->
<!ENTITY % xhtml-hypertext.mod
     PUBLIC "-//W3C//ELEMENTS XHTML Hypertext 1.0//EN"
            "http://www.w3.org/MarkUp/DTD/xhtml-hypertext-1.mod" >
%xhtml-hypertext.mod;

<!-- Lists Module (required)  .................................... -->
<!ENTITY % xhtml-list.mod
     PUBLIC "-//W3C//ELEMENTS XHTML Lists 1.0//EN"
            "http://www.w3.org/MarkUp/DTD/xhtml-list-1.mod" >
%xhtml-list.mod;

<!-- My Elements Module   ........................................ -->
<!ENTITY % MyML-elements.mod
     SYSTEM "myml-elements-1.mod" >
%MyML-elements.mod;

<!-- XHTML Images module  ........................................ -->
<!ENTITY % xhtml-image.mod
     PUBLIC "-//W3C//ELEMENTS XHTML Images 1.0//EN"
            "http://www.w3.org/MarkUp/DTD/xhtml-image-1.mod" >
%xhtml-image.mod;

<!-- Document Metainformation Module  ............................ -->
<!ENTITY % xhtml-meta.mod
     PUBLIC "-//W3C//ELEMENTS XHTML Metainformation 1.0//EN"
            "http://www.w3.org/MarkUp/DTD/xhtml-meta-1.mod" >
%xhtml-meta.mod;

<!-- Document Structure Module (required)  ....................... -->
<!ENTITY % xhtml-struct.mod
     PUBLIC "-//W3C//ELEMENTS XHTML Document Structure 1.0//EN"
            "http://www.w3.org/MarkUp/DTD/xhtml-struct-1.mod" >
%xhtml-struct.mod;

E.5. Using the new DTD

Once a new DTD has been developed, it can be used in any document. Using the DTD is as simple as just referencing it in the DOCTYPE declaration of a document:

You can download this version of this file from http://www.w3.org/TR/2010/REC-xhtml-modularization/DTD/examples/myml-noprefix.xhtml. The latest version is available at http://www.w3.org/MarkUp/DTD/examples/myml-noprefix.xhtml.

<!DOCTYPE html SYSTEM "myml-1_0.dtd" >
<html xmlns="http://www.w3.org/1999/xhtml" 
      xmlns:xhtml="http://www.w3.org/1999/xhtml" 
      xmlns:myml="http://www.example.com/xmlns/myml" >
<head>
<title>An example using defaults</title>
</head>
<body>
<p>This is content in the XHTML namespace</p>
<myelement xhtml:id="myid" xhtml:class="localElement">
  This is content in the SimpleML namespace.
  <myotherelement />
</myelement>
<p><img src="missing" alt="Missing image" myml:myattr="value"/></p>
</body>
</html>

The document can also use the elements outside of the XHTML namespace by prefixing them:

You can download this version of this file from http://www.w3.org/TR/2010/REC-xhtml-modularization/DTD/examples/myml-prefixed.xhtml. The latest version is available at http://www.w3.org/MarkUp/DTD/examples/myml-prefixed.xhtml.

<!DOCTYPE html SYSTEM "myml-1_0.dtd" [
  <!ENTITY % MyML.prefixed "INCLUDE" >
]>
<html xmlns="http://www.w3.org/1999/xhtml" 
      xmlns:xhtml="http://www.w3.org/1999/xhtml" 
      xmlns:myml="http://www.example.com/xmlns/myml" >
<head>
<title>An example using defaults</title>
</head>
<body>
<p>This is content in the XHTML namespace</p>
<myml:myelement xhtml:id="myid" xhtml:class="localElement">
  This is content in the myml namespace.
  <myml:myotherelement />
</myml:myelement>
<p><img src="missing" alt="Missing image" myml:myattr="value" /></p>
</body>
</html>