- 92 -
&executive_summary;
&discussion;
&conclusion;
See the elegance of it all? Each of these sections (executive_summary, discussion,
conclusion) can be treated separately and all joined together by the parser. They
keyword SYSTEM tells the parser that the item in quotation marks is an URI (universal
resource indicator), which is a pointer to the location of the file.
External Parameter Entity Declaration
External Parameter Entity Declarations are great for sharing DTD components among
many XML DTDs. The idea is this: If you have common elements/entities/attributes, why
bother declaring the same thing each time?
Following is an example of how to share DTD components. Let’s say we’re working with
a bookstore environment. In our current document, we have a contact database that
contains information on the person’s name, address, and telephone number. Let’s also
say that we’ve previously used a particular structure for address and name information
and that, in the interest of consistency, we’d like these fields to maintain the same
structure. Here’s an example of what our main XML document, including internal DTD,
could look like:
<
!DOCTYPE
contacts [
<
!ELEMENT
contacts (contact)*>
<
!ELEMENT
contact (name, address, telephone)>
<
!ENTITY %
name SYSTEM "name.dtd">
<
!ENTITY %
address SYSTEM "address.dtd">
<
!ELEMENT
telephone (
#PCDATA
)>
]>
Faraz
Hoodbhoy
Karachi, Pakistan
(555)123 4567
You probably noticed that first_name and last_name elements are explicitly declared in
the internal DTD. For this snippet to work, we need to have external DTD files name.dtd
and address.dtd. Here’s what name.dtd could look like:
address.dtd probably looks like this:
Again, the parser follows the references/pointers to different locations, pieces together a
- 93 -
comprehensive DTD in memory, and then checks whether the document is in
compliance.
Table 3.9 summarizes the types of Entity declarations and their use.