bold option to mean a different font, another could take it to mean a larger font, and an-
other could use it as an instruction to underline the text or display it in a different color.
Or the bold option could be ignored altogether. The only thing XML knows about the
attribute is the syntax required to include it with a tag.
If you have worked with HTML, you can see the similarities in the syntax of HTML
and XML. They are similar enough that it is possible to write an XML document and
use only tag names known to a particular Web browser and then have that Web
browser read the document and impose its interpretations on the tags and options and
result in a displayed page. A displayable XML document is written often enough that
a document of this type has a special name; it is called XHTML. There is more infor-
mation about XHTML later in this chapter.
XML is a nonprocedural computer language, as opposed to a procedural language such
as Java. A procedural language is one that consists of lists of instruction that are ex-
pected to be obeyed one by one, usually in order from top to bottom. A nonprocedural
language is one that expects all of its instructions to be executed as if they were all
being executed simultaneously and, if necessary, to react to one another to create an
overall state or set of states. An example of nonprocedural processing is a spreadsheet
in which all the cells in the sheet that contain equations have their values calculated at
once, creating a static state of constant values displayed in the cells. This same sort of
thing happens in a Web browser where the HTML tags define the state (layout, colors,
text, pictures, fonts, and so on) that determines the appearance of a Web page.
DTD
DTD stands for Document Type Definition. Although DTD is normally treated sepa-
rately from XML tags, has a different syntax, and serves a different purpose, it is very
much a part of the XML language. The DTD section of an XML document is used to de-
fine the names and syntax of the elements that can be used in the document. There are
several steps involved in the creation and application of a DTD definition, and Chap-
ter 2 contains explanations of those steps along with a number of examples. Its source
can be included inline inside an XML document, or it can be stored in a separate docu-
ment from the XML text and tags. Because its purpose is to specify the correct format
of a marked up document, DTD is most useful if it is made available to several docu-
ments and is most often stored in a file separate from any XML document, which en-
ables it to be accessed from any number of XML documents. For the sake of simplicity,
however, most of the examples in this book have a simple DTD included as part of the
XML document.
DTD enables you to further refine the syntactical requirements of a set of XML
markup rules. In a DTD you can specify the allowed and disallowed content of each tag
that is to appear in an XML document. That takes at least a third of Chapter 2. DTD has
its limitations, but there are many different things that can be done by using it. You can
specify which elements are allowed to appear inside other elements as well as which el-
ements are required and where they are required. You can specify which attributes are
valid for each tag and even specify the set of possible values for each one. You can
Introduction to XML with JAXP
5
3851 P-01 1/28/02 10:32 AM Page 5