Penguin
Note: You are viewing an old revision of this page. View the current version.
An XML document is WellFormed if it parses correctly. The main issue that causes XML not to be WellFormed is tag ordering. For example the following is WellFormed
... <a> this is well formed </b> <c> this is well formed too </c> </a> ...
while this is not
... <a> this is well formed <b> <c> this is well formed too </a> ...

In the second fragment, neither the <b> nor the <c> tag are closed. Unlike SGML, XML does not allow tags to be automatically closed when the enclosing tag is closed. This is the reason why the <p> tag in HTML/XHTML gives people grief---in HTML you only need to put in the opened tags while in XHTML you need to put in both the opening and the closing tag.

The tag pattern
<a> ... ... </a> ...
is not WellFormed in either SGML or XML, if you want non-nesting overlapping ranges such as this you need something like
<a id="1"/> ... <b id="2"/> ... <a id="1"/> ... <b id="2"/>

then you can reconstruct either of the tags as necessary.

WellFormed XML differs from Valid XML in that Valid XML has been (or could be) checked against a Schema or DTD.