my-server
← Wiki

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".

Requirements

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 <code>&lt;</code> and <code>&amp;</code> 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 <code>!"#$%&'()*+,/;<=>?@[\]^`