Skip to main content

Well-formed XML Documents

An XML document can be well-formed. All this means is that the basic rules of XML syntax are obeyed, namely:

  • All elements are enclosed within < > characters.

  • Every element has an opening tag, <tagname>, and a closing tag, </tagname> (these can be combined as <tagname/> for elements with no content).

  • Elements are nested properly; the innermost tags are closed, then the next outer layer, and so on.

  • Attribute values are enclosed within quotation (" ") marks.

  • The <, >, and & characters are represented as the entities, “&lt;”,“&gt;” and “&amp;”. An entity is like an XML macro—when a document is processed entities are replaced with their defined value.

The concept of well-formedness is very important in XML processing; if you know that a document is well-formed then writing code that works directly against the XML representation is much simpler because you do not have to worry about special cases.

The tools used by Caché to import XML documents check for well-formedness so you do not have to worry about this when creating a Caché XML application.

Note that a well-formed document is not necessarily a correct document; a well-formed document could still contain semantically incorrect information.

FeedbackOpens in a new tab