XML.com 
 Published on XML.com http://www.xml.com/pub/a/98/10/guide3.html
See this if you're having trouble printing code examples

 

Validity
By Norman Walsh

Given the preceding discussion of type declarations, it follows that some documents are valid and some are not. There are two categories of XML documents: well-formed and valid.

Well-formed Documents

A document can only be well-formed [Section 2.1] if it obeys the syntax of XML. A document that includes sequences of markup characters that cannot be parsed or are invalid cannot be well-formed.

In addition, the document must meet all of the following conditions (understanding some of these conditions may require experience with SGML):

By definition, if a document is not well-formed, it is not XML. This means that there is no such thing as an XML document which is not well-formed, and XML processors are not required to do anything with such documents.

Valid Documents

A well-formed document is valid only if it contains a proper document type declaration and if the document obeys the constraints of that declaration (element sequence and nesting is valid, required attributes are provided, attribute values are of the correct type, etc.). The XML specification identifies all of the criteria in detail.

Previous: What Does XML Look Like? next Next: Pulling the Pieces Together next

XML.com Copyright © 2000 O'Reilly & Associates, Inc.