Separating the DTD into an External File

In keeping with the general rule of moving things into separate files whenever possible, Listing 5.10 shows a separate file for the DTD.

Listing 5.10 First Example of a Standalone DTD File
 1: <?xml version="1.0"?>
 2: <!-- This file is an external DTD that will be imported into
    another file. -->
 3: <!ELEMENT E-MAIL (TO+,FROM,CC*,BCC*,SUBJECT?,BODY?)>
 4: <!ELEMENT TO (#PCDATA)>
 5: <!ELEMENT FROM (#PCDATA)>
 6: <!ELEMENT CC (#PCDATA)>
 7: <!ELEMENT BCC (#PCDATA)>
 8: <!ELEMENT SUBJECT (#PCDATA)>
 9: <!ELEMENT BODY (#PCDATA)>
10:
11: <!ENTITY BCCPREFIX "A nice ">

Listing 5.11 imports the program from Listing 5.10.

Listing 5.11 Importing a DTD File into an XML File
 1: <?xml version="1.0"?> 2: <!-- This file ...

Get Sams Teach Yourself XML in 24 Hours now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.