DTD External Declaration

External DTD Declaration :

If we wrote a DTD file then we must wrap it in DOCTYPE definition with the following syntax –

<!DOCTYPE root-element SYSTEM "filename">

The XML file will be like this –

<?xml version="1.0"?>
<!DOCTYPE Book SYSTEM "book.dtd">
   <name>Learn XML</name>

Now we have written all the DTD statements inside the another file and included that file inside the XML document. book.dtd file will be like this –

<!ELEMENT Book   (name,author,type,pages)>
<!ELEMENT name   (#PCDATA)>
<!ELEMENT author (#PCDATA)>
<!ELEMENT type   (#PCDATA)>
<!ELEMENT pages  (#PCDATA)>