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 bracket groups, because this markup declaration contains other declarations (to build entity and DTD definitions):

<!DOCTYPE myBook [
......
]>

It may also call-in declarations that are held in a separate data file. The keyword 'SYSTEM' precedes a quoted URL that identifies the file containing these declarations (a slightly more sophisticated variant of this feature uses the 'PUBLIC' keyword which creates an indirect reference to the remote resource):

<!DOCTYPE myBook SYSTEM "declarations.xml" [
......
]>

This declaration may be omitted if the document does not use entities, and is not associated with a DTD. In its simplest form it merely indicates the name of the root element, so adds no value to the document at all. In most real-world cases, the document type declaration only appears when a reference is needed to a DTD file:

<!DOCTYPE myBook SYSTEM "book.dtd" >

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.119.131.178