DTD Reference: Internal

An XML document can reference a DTD internally or externally. When specified internally, a DTD is placed within the XML document directly after the prolog. An internal DTD is enclosed within a DOCTYPE element, as shown in the following example:

    <!DOCTYPE root_element
    [ ...DTD definition goes here... ]>

The code snippet on the right displays a complete XML document, which contains an internal DTD. In the code snippet, the DOCTYPE element is followed by the root element, Messages.

<?xml version="1.0" encoding="UTF-8"?>
<!-- An example of a DTD-->
    <!DOCTYPE Messages [
    <!ELEMENT mail (to, from, subject, text)>
    <!ELEMENT to (#PCDATA)>
    <!ELEMENT from (#PCDATA)>
    <!ELEMENT subject (#PCDATA)>
    <!ELEMENT text (#PCDATA)>]>

    <Messages>
        <mail>
             <to>you@yourAddress.com</to>
             <from>me@myAddress.com</from>
             <subject>Car lights on</subject>
             <text>Owner of vehicle
             with license plate 454-561,
             your lights are on!</text>
        </mail>
    </Messages>

Click the Next button to continue.