|Lesson 7||Referencing DTD declarations |
|Objective||Reference DTD Declarations in XML|
Reference DTD Declarations in XML
Every XML file that uses a DTD must have a document type declaration
which is used to declare the DTD. That is, the structure and syntax of a given DTD is defined using a document type declaration. A document type declaration has thefollowing general syntax:
<!DOCTYPE root element name [DTD]>
This syntax may vary depending on whether the document type declaration points to an internal DTD, as indicated using the syntax above, or an external DTD.
Using a document type declaration to reference an external DTD will be presented later in the course.
The standalone attribute
attribute may be added to the
declaration to indicate whether the <!DOCTYPE> declaration should point to
- internal or
If all the DTD information will be enclosed within the XML document, you can specify that the
attribute's value is
. If the XML document should be referencing an external DTD, the value of this attribute should be
The following tag indicates that the DTD information should appear in the XML document itself:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
If the DTD will exist in a separate file, you would use the following XML declaration instead:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
Both the internal and external DTD examples require a
<!DOCTYPE> declaration in some form.
The <!DOCTYPE> declaration should be on the line just below the <?xml?> declaration to avoid errors when the document is parsed.
In the next lesson, I will discuss how to create a DTD file to work with a separate XML files.
Document Type Declaration :
The document type declaration names the document type being used and links to or includes its definition, the DTD. The <!DOCTYPE > declaration should be on the line just below the <?xml?> declaration.