HTML and CSS Reference
In-Depth Information
15.3. Understanding XML DTDs
To use a markup language defined with XML, you should be able to read
and understand the elements and entities found in its XML DTD. But don't
be put off: while XML DTDs are verbose, filled with obscure punctuation,
and designed primarily for computer consumption, they are actually easy
to understand once you get past all the syntactic sugar. Remember, your
brain is better at languages than any computer.
As we said previously, an XML DTD is a collection of XML entity and
element declarations and comments. Entities are name/value pairs that
make the DTD easier to read and understand, and elements are the ac-
tual markup tags defined by the DTD, such as HTML's <p> and <h1> tags.
The DTD also describes the content and grammar for each tag in the
language. Along with the element declarations, you'll also find attribute
declarations that define the attributes authors may use with the tags
defined by the element declarations.
There is no required order, although the careful DTD author arranges
declarations in such a way that humans can easily find and understand
them, computers notwithstanding. The beloved DTD author includes lots
of comments, too, that explain the declarations and how they can be
used to create a document. Throughout this chapter, we use examples
taken from the XHTML 1.0 DTD, which you can find in its entirety at the
W3C web site. Although it is lengthy, you'll find this DTD to be well writ-
ten, complete, and, with a little practice, easy to understand.
XML also provides for conditional sections within a DTD, allowing groups
of declarations to be optionally included or excluded by the DTD parser.
This is useful when a DTD actually defines several versions of a markup
language; the desired version can be derived by including or excluding
appropriate sections. The XHTML 1.0 DTD, for example, defines both the
"regular" version of HTML and a version that supports frames. By allow-
ing the parser to include only the appropriate sections of the DTD, the
rules for the <html> tag can change to support either a <body> tag or a
<frameset> tag, as needed.
Search WWH ::

Custom Search