If a DTD is used within or linked to an XML document, a quick way to check for errors in the DTD is to try loading an XML document file that uses it in Internet Explorer.
The following are an external DTD file with an error (a single missing close parentheses) and an XML file that links to and uses this DTD.
<!ELEMENT catalog (book+) >
<!ELEMENT book (author, title, genre, price, publish_date, description) >
<!ATTLIST book id ID #REQUIRED >
<!ELEMENT author (#PCDATA) >
<!-- The following line has the error -->
<!ELEMENT title (#PCDATA
>
<!ELEMENT genre (#PCDATA) >
<!ELEMENT price (#PCDATA) >
<!ELEMENT publish_date (#PCDATA) >
<!ELEMENT description (#PCDATA) >
XML File (books-using-errored.xml)
<?xml version="1.0"?> <!DOCTYPE catalog SYSTEM "errored.dtd"> <catalog> <book id="bk101"> <author>Gambardella, Matthew</author> <title>XML Developer's Guide</title> <genre>Computer</genre> <price>44.95</price> <publish_date>2000-10-01</publish_date> <description>An in-depth look at creating applications with XML.</description> </book> </catalog>
Results should appear in the browser window similar to the following, indicating an error in the DTD.
<P STYLE='line-height:15.0pt'><SPAN STYLE='font-size:13.0pt;font-family:Verdana'>The XML page cannot be displayed</SPAN></P> <P STYLE='line-height:11.0pt'><SPAN STYLE='font-size:8.0pt;font-family:Verdana'>Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later. </SPAN></P> <P STYLE='line-height:11.0pt'><B><SPAN STYLE='font-size:8.0pt;font-family:Verdana'>Mixed content model cannot contain this character. Error processing resource 'file:///C:/temp/books.dtd'. Line 6, Position 37 </SPAN></B></P> <P STYLE='line-height:12.0pt'><CODE><SPAN STYLE='color:blue'><!ELEMENT title          (#PCDATA ></SPAN></CODE></P>
If you correct the error in errored.dtd by adding the missing close parentheses to line 6, you can successfully reload the books-using-errored.xml file.