In external DTD elements are declared outside the XML file. They are accessed by specifying the system attributes which may be either the legal .dtd file or a valid URL. To reference it as external DTD, the standalone attribute in the XML declaration must be set as no.
An XML that describes a note that contains property to, from and the message is given below.
<?xml version="1.0" encoding="UTF-8" standalone="no" ?> <!DOCTYPE note SYSTEM "note.dtd"> <note> <to>Mr.X</to> <from>Mr.Y</from> <message>Stack Overflow is awesome</message> </note>
External DTD for the above XML, note.dtd is given below
<!DOCTYPE note [ <!ELEMENT note (to,from,message> <!ELEMENT to (#PCDATA)> <!ELEMENT from (#PCDATA)> <!ELEMENT message (#PCDATA)> ]>