Quackit Logo

Combined DTD

You can use both an internal DTD and an external one at the same time. This could be useful if you need to adhere to a common DTD, but also need to define your own definitions locally.

Example

This is an example of using both an external DTD and an internal one for the same XML document. The external DTD resides in "tutorials.dtd" and is called first in the DOCTYPE declaration. The internal DTD follows the external one but still resides within the DOCTYPE declaration:

Here, I've added a new element called "summary". This element must be present under the "tutorial" element. Because this element hasn't been defined in the external DTD, I need to define it internally. Once again, we're setting the "standalone" attribute to "no" because we rely on an external resource.

<?xml version="1.0" standalone="no"?>
<!DOCTYPE tutorials SYSTEM "tutorials.dtd" [
<!ELEMENT tutorial (summary)>
<!ELEMENT summary (#PCDATA)>
]>
<tutorials>
  <tutorial>
    <name>XML Tutorial</name>
    <url>http://www.quackit.com/xml/tutorial</url>
    <summary>Best XML tutorial on the web!</summary>
  </tutorial>
  <tutorial>
    <name>HTML Tutorial</name>
    <url>http://www.quackit.com/html/tutorial</url>
    <summary>Best HTML tutorial on the web!</summary>
  </tutorial>
</tutorials>

Enjoy this website?

  1. Link to this page (copy/paste into your own website or blog):
  2. Add this page to your favorite social bookmarks sites:
                     
  3. Add this page to your Favorites

Oh, and thank you for supporting Quackit!