XML Content

The DTD, whether included as part of the XML file or external to the XML file is used to define content. The DTD is used to determine the elements allowed in the file and which elements can be contained in other elements. The DTD also describes the number of times specific elements may be contained in other elements. The document called "Document Type Definition (DTD)" on this website gives a more thorough explanation about how to read and construct a DTD. This document was written for SGML DTDs and the main difference lies in the fact that XML requires a beginning and ending tag for all elements. SGML does not have this requirement .

Element Declaration

Therefore in an SGML DTD an element tag for the <HR> element is:

<!ELEMENT HR - O EMPTY -- horizontal rule -->

If written for XML, the DTD would be:

<!ELEMENT HR EMPTY -- horizontal rule -->

The difference between the two examples is that the XML <HR> declaration does not define whether the element requires a closing tag as done with the "- O" text. This is because all elements in XML are required to have closing tags and therefore defining whether a closing tag is required is pointless.