At its base level well-formed documents require that: • Content be defined. • Content be delimited with a beginning and end tag • Content be properly nested (parents within roots, children within parents) To be a well-formed document, rules must be established about the declaration and treatment of entities.
Tags are
case sensitive, with attributes delimited with quotation marks. Empty elements have rules established. Overlapping tags invalidate a document. Ideally, a well-formed document conforms to the design goals of XML. Other key syntax rules provided in the specification include: • It contains only properly encoded legal Unicode characters. • None of the special syntax characters such as < and & appear except when performing their markup-delineation roles. • The begin, end, and empty-element tags that delimit the elements are correctly nested, with none missing and none overlapping. • The element tags are case-sensitive; the beginning and end tags must match exactly. Tag names cannot contain any of the characters !"#$%&'()*+,/;?@[\]^`{|}~, nor a space character, and cannot start with -, ., or a numeric digit. • There is a single "root" element that contains all the other elements. A valid XML document is defined in the XML specification as a well-formed XML document which also conforms to the rules of a
Document Type Definition (DTD). According to JavaCommerce.com XML tutorial, "Well formed XML documents simply markup pages with descriptive tags. You don't need to describe or explain what these tags mean. In other words a well formed XML document does not need a DTD, but it must conform to the XML syntax rules. If all tags in a document are correctly formed and follow XML guidelines, then a document is considered as well formed." An XML processor that encounters a violation of the well-formedness rules is required to report such errors and to cease normal processing. This policy, occasionally referred to as
draconian, stands in notable contrast to the behavior of programs that process
HTML, which are designed to produce a reasonable result even in the presence of severe markup errors in the spirit of
Postel's law ("Be conservative in what you send; be liberal in what you accept"). ==Importance==