Commenting a DTD
DTDs can get long and involved in complex XML documents. You can use standard XML comments in DTDs, just as you can throughout the body of an XML document, to clarify what you're doing. Here's an example of comments in a DTD:
<!DOCTYPE document [ <!--Create the document element first --> <!ELEMENT document (employee)*> <!--Each employee needs a name, hire date, and projects --> <!ELEMENT employee (name, hiredate, projects)> <!-- Should we reverse the order of these two? --> <!ELEMENT name (lastname, firstname)> <!ELEMENT lastname (#PCDATA)> <!ELEMENT firstname (#PCDATA)> <!--Use standard date format for the hiredate element --> <!ELEMENT hiredate (#PCDATA)> <!ELEMENT projects (project)*> <!ELEMENT project (product, id, price)> <!--Product name should match catalog 8547382 --> <!ELEMENT product (#PCDATA)> <!ELEMENT id (#PCDATA)> <!ELEMENT price (#PCDATA)> ]>
As in any standard XML document, comments in a DTD are stripped out of the DTD by the XML processor. Some XML processors pass those comments on to us, but some don't.