Internal and external references
A document type definition (DTD) is used to the proper way to build a particular document. DTDs are referenced in XML documents by the use of a document type declaration (DOCTYPE
) element. DTDs can be written out in full inside the XML document, or they can be referenced externally for the parser to download and process.
Internal DTDs can be found near the top of the XML document, in the DOCTYPE
tag:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE user [ <!ELEMENT user ANY> <!ENTITY company "Ellingson Mineral Company"> ]> <user> <name>Dade Murphy</name> <id>1</id> <email type="local">admin@localhost</email> <company>&company;</company> </user>
The preceding internal DTD defines the user
root element and an internal entity, company
, which is defined to hold the string value "Ellingson Mineral Company"
. Within the document itself, the company entity can be referenced...