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"> <Book> <name>Learn XML</name> <author>Pritesh</author> <type>Scripting</type> <pages>100</pages> </Book>
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)>