1. Computing & Technology

Discuss in my forum

well-formed

By , About.com Guide

Definition:

When you start writing XML, you will hear over and over the two terms "well formed" and valid. They are not the same thing. You can have a well formed XML document that is not valid, and a valid document that is not well formed. Basically, a well formed document is one that meets the minimum criteria for XML processors and validators to read the document.

An XML document consists of text, but the text forms two different things:

  • markup
    The tags, comments, character, and entity references.
  • character data
    the information and text within the document

When writing well formed XML documents, there are some specific rules you should follow:

  • the XML declaration must come first in every document
  • comments are not valid within a tag
  • comments may not contain two hyphens in a row, other than the beginning and end of the comment
  • tags must have an end tag, or be closed within the singleton tag itself, for example <br />
  • all attributes of tags must be quoted, preferably double quotes unless the attribute itself contains a double quote
  • every XML document must contain one element that completely contains all the other elements

You will find that most of the rules that apply to well formed XML also apply to HTML, well XHTML that is. This is because XHTML is HTML that is rewritten to XML specifications.

Pronunciation: wEl - formd - (adjective)

©2012 About.com. All rights reserved.

A part of The New York Times Company.