The Well-Formed Document
March 29, 1999
|
As was discussed in part one, XML allows you to generate an
infinite number of custom tags sets for your documents.
However, though you are free to be as innovative as you want
with the XML tag sets that you create, you must follow the
constraints of the XML tag set generation standards exactly.
In other words, your XML documents must be "well-formed".
Well-formedness has an exact meaning in XML. Specifically, a
well-formed document adheres to the syntax rules specified by
the XML 1.0 specification. In this month's tutorial, we will
look at those rules in depth.
|
"HTML 4.0
has about three hundred
1 different tags.
Most of these have half a dozen possible attributes for
several thousand variations. Because
XML
is more powerful
than HTML, you may think XML would have even more tags, but
you'd be wrong....XML predefines almost no tags." -
Elliotte Rusty Harold
As we have said before, XML is a tool used to generate markup
languages in general rather than a specific markup language.
Thus, rather than pre-defining a set of tags, XML defines a
methodology for tag creation. Once defined, tags are mixed
with plain text in order to form an "XML document".
|
It is worth mentioning that the word "document" can be a
little misleading because although XML markup can certainly
be contained in a file, (as the word document would imply),
it can also be sent as a data stream, a database result set,
or be dynamically-generated by one application and sent to
another. More correctly, an XML document can be thought of
as a "data object", but for simplicity, document will work
just fine.
|
However, though you are free to be as innovative as you want
with the tag sets you create, you must follow the constraints
of the XML tag set generation standards exactly. When an XML
document is presented to an XML-processor, in order for the
XML processor to understand how to process it, the XML must
follow the XML standard. Specifically, the document must be
"well-formed". If the document is not well-formed the processor
will stop, complaining about a "fatal error".
Well-formedness has an exact meaning in XML. Specifically, a
well-formed document adheres to the syntax rules specified by
the XML 1.0 specification in that it must satisfy both physical
and logical structures.
|
Why get so caught up in syntax? Well, the creators of XML had
a tough problem to solve. They had to create a system in which
documents could be created that could be read either
by people or by machines. Writing a language for people is
one thing...people can figure their way through ambiguity.
Machines, on the other hand, can only work if the rules are
clear and the rules are followed. Making your XML document
well-formed means that it meets the minimum requirement of
being readable by the dumbest of computers.
|
Editors Note:
There are in fact only
about 90 tags; Mr Harold was exaggerating for effect.
Introduction to XML For Web Developers
Introduction to XML For Web Developers | Table of Contents
XML Document Structure
|