Well-formed document

A well-formed document in XML is a document that adheres to the syntax rules specified by the XML 1.0 specification in that it must satisfy both physical and logical structures."[1]

Requirements

At its base level well-formed documents require that:

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:

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."[2][3]

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,[4] 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[5] in the spirit of Postel's law ("Be conservative in what you send; be liberal in what you accept").[6][4]

Importance

The concept of a well-formed document allows for a better understanding of the fundamental construction of XML. It helps to clarify XML beyond the typical sense of it. For example, while most XML Document Type Definitions utilize left and right angle brackets as content delimiters, strictly speaking this is not a necessity (though a delimiter should be terse and concise). The left and right angle bracket codes are a convention, albeit clear and distinctive, not an absolute requirement.

The concept of well-formed document also allows for the comprehension of the abstract nature of XML. In reality, there is no such thing as XML. Rather, XML is a principle that represents a set of behaviors and practices. It is possible to discuss types of XML, as expressed within a Document Type Definition (DTD).

Well-formed documents also bring into focus the issue of valid versus correct XML. According to the W3 Organization, valid documents are those that validate against a DTD. The rules of validity mean that a document complies with the restraints stated within a DTD. Thus, tags or entities must be in conformity to the rules and relations established within a DTD. However, there is no control on whether a tag or entity is correct. Thus a first level head tag could be applied to a second level head object and be valid, while incorrect.

The emphasis on well-formed documents has developed within the publishing industry where the use of left and right angle bracket delimited information has become problematic. Emphasis on the well-formed document allows for the definition, delimiting, and nesting of content to be managed within programs that are not XML, per se, but exhibit the characteristics or potential for being well formed.

Validation tools

There are several tools available to determine if a given XML document is well formed. Some examples are:

References

  1. "XML: The Well-formed Document". The UK Web Design Company. Retrieved 11 August 2013.
  2. JavaCommerce Archived August 22, 2009, at the Wayback Machine.
  3. "There are no exceptions to Postel’s Law". Dive into Mark. Internet Archive. Archived from the original on May 10, 2013. Retrieved 11 August 2013.
  4. 1 2 "Dracon and Postel", 2003/08/19, Tim Bray
  5. "The history of draconian error handling in XML". Dive into Mark. Internet Archive. Archived from the original on August 18, 2013. Retrieved 11 August 2013.
  6. "Postel’s Law Has No Exceptions", August 18, 2003 Aaron Swartz

See also

This article is issued from Wikipedia - version of the Friday, May 06, 2016. The text is available under the Creative Commons Attribution/Share Alike but additional terms may apply for the media files.