Applying the DTD

DTDs may be embedded in the XML files they prescribe rules for.

Example 40.2. Embedded DTD
<?xml version="1.0"?>
<!DOCTYPE content [
 <!ELEMENT content ANY>
]>
<content>Hello world!</content>

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 it:

Example 40.3. External DTD
<?xml version="1.0"?>
<!ELEMENT para ANY>

Example 40.4. Document with External DTD

and then use it

<?xml version="1.0"?>
<!DOCTYPE para SYSTEM "hello.dtd">
<para>Hello world!</para>

in case you wrote the DTD yourself, and you store it locally relative to the affected XML document. You 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">