You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
34<br />
Types of Document Type Definition<br />
<strong>XML</strong> Demystifi ed<br />
There are two types of document type definitions (DTD): an internal DTD and an<br />
external DTD. An internal DTD appears at the beginning of the <strong>XML</strong> document<br />
within the DOCTYPE tag, which we illustrate in the next example.<br />
Internal DTD is perfect for when only one <strong>XML</strong> document will use the DTD<br />
because the DTD is distributed in the same file as the <strong>XML</strong> document. Some<br />
developers also use an internal DTD for small documents where the DTD is unlikely<br />
to change and, especially, for those documents that will only be distributed within<br />
their organization.<br />
Avoid using an internal DTD if many <strong>XML</strong> documents share the same DTD<br />
because it isn’t economical to replicate the DTD in every <strong>XML</strong> document. Further-<br />
more, you’ll need to hunt down each of those documents whenever you want to<br />
change the DTD.<br />
Notice that the following example uses an internal DTD to define a customer for<br />
the <strong>XML</strong> document. This DTD contains a number of parent-child relationships (see<br />
Chapter 2), as you can tell from reading the definition of the customer tag.<br />
The customer tag is a parent than contains seven child elements. These are name,<br />
title, company, address, phone, email, and account_number. Three of those child<br />
elements are also parents to their own child elements.<br />
For example, name has first_name and last_name as child elements. Address has<br />
street_1, street_2, city, state, and zip as child elements. And phone has business,<br />
cell, home, and fax as child elements.<br />
The DTD ends with ]>. The <strong>XML</strong> document begins on the next line, where tags<br />
defined in the DTD identify data within the <strong>XML</strong> document.<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />