Document type declaration

A markup declaration is used to identify the document class that the document belongs to. The document type declaration sits at the top of an XML document. The keyword 'DOCTYPE' is used to indicate a document type declaration:

<!DOCTYPE ...>

The example below shows a document type declaration in its simplest form. It merely identifies the name of the document element, which it precedes:

<!DOCTYPE myBook>
<myBook>
  ...
</myBook>

Note that if an XML declaration is present, it still appears first, before the document type declaration:

<?xml version="1.0" ... >
<!DOCTYPE myBook>

More complex variants are used to hold entity definitions (see Chapter 4) and contain the DTD (see Chapter 5). These variants use the square ...

Get XML Companion, The, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.