Note that in this example, the word SYSTEM is used to specify that this DTD is located on the same system as the document itself. The word PUBLIC may also be specified in this position to indicate that the DTD is a publicly available document, and is followed by a reference to where that document can be found. Of course, greeting.dtd refers to the name of the file in which the DTD information can be found.
In this example, the XML file will be validated against the DTD. If the first file contained any other tags, this document would not be considered valid because only the greeting element has been defined by the DTD.
The commonly accepted extension for the DTD file is .dtd . The next lesson shows you how to embed declarations within the XML file.
An XML document is made up of text. It is a sequence of characters with a fixed length that adheres to certain constraints. It may or may not be a file. For instance, an XML document could be any of the following:
A CLOB field in an Oracle database
The result of a query against a database that combines several records from different tables
A data structure created in memory by a Java program
A data stream created on the fly by a CGI program written in Perl
Some combination of several different files, each of which is embedded in another
One part of a larger file containing several XML documents
However, nothing essential is lost if you think of an XML document as a file, as long as you keep in the back of your mind that it might not really be a file on a hard drive. XML documents are made up of storage units called entities. Each entity contains a well-formed document fragment. This is a piece of text that meets all of XML's wellformedness rules except for the one about there being a single root element. The various entities that make up a document will be stored in different files, databases, and other locations. The parser combines them all to form the complete document.