DTDs may be embedded in the XML files they prescribe rules for.
Example 8.1. Embedded DTD
<?xml version="1.0" standalone="yes"?>
<!DOCTYPE emails [
<!ELEMENT emails (email*)>
<!ELEMENT email (to+,from,subject,message)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT subject (#PCDATA)>
<!ELEMENT message (#PCDATA)>
]>
<emails>
<email>
<to>Mum</to>
<from>Porky</from>
<subject>Greetings</subject>
<message>Hello Mums, could you PLEASE send some more money</message>
</email>
</emails>
It is my strong belief, however that you are better off
writing them as external files connected to their XML docs
much the same way we use external css, or
js in XHTML docs.
In order to use a DTD write:
Example 8.2. External DTD
<?xml version="1.0" standalone="no"?>
<!DOCTYPE letter SYSTEM "letter.dtd">
<emails>
<email>
<to>Mum</to>
<from>Porky</from>
<subject>Greetings</subject>
<message>Hello Mums, could you PLEASE send some more money</message>
</email>
</emails>
in case you wrote the DTD yourself, and you store it locally relative to the affected XML document. Yout may put it on the the net and address it by a URI:
<?xml version="1.0" standalone="no"?>
<!DOCTYPE letter SYSTEM
"http://deformation.org/blabla/dtds/letter.dtd">