Document Body
March 29, 2002
The document body, or instance, is the bulk of the
information content of the document. Whereas across multiple
instances of a document of a given type (as identified by the
DOCTYPE ) the XML prolog will remain constant, the document body
changes with each document instance (in general). This is
because the prolog defines (either directly or indirectly) the
overall structure while the body contains the real instance-
specific data. Comparing this to data structures in computer
languages, the DTD referenced in the prolog is analogous to a
struct in the C language or a class definition in Java,
and the document body is analogous to a runtime instance of the
struct or class .
Because the document type declaration specifies the root
element, this must be the first element the parser encounters.
If any other element but the one identified by the
DOCTYPE line appears first, the document is immediately
invalid. Listing 3-1 shows a very simple XHTML 1.0 document. The
DOCTYPE is html (not xhtml), so
the document body begins with <html ....>and ends with
</html>.
Listing 3-1 Simply XHTML 1.0 Document with XML Prolog and
Document Body
<?xml version="1.0"encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional //EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"xml:lang="en"lang="en">
<head>
<title>XHTML 1.0</title>
</head>
<body>
<h1>Simple XHTML 1.0 Strict Example</h1>
<p>See the <a href=
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">DTD</a>.</p>
</body>
</html>
Document Type Declaration
XML Family of Specifications: A Practical Guide
Markup, Character Data, and Parsing
|