Validation
Validation is the process of checking an XML document
against its DTD or schema. This important step
insures that:
-
The XML data set has exactly the characteristics
such as data type, values, and value ranges that
it should have.
-
Any scripts, CGI, or other programs that process the
structure are guaranteed to work (assuming that the
processing programs have been designed to conform to the
DTD or schema)
For example, if the DTD defines the
elements SIZE and SHAPE, this document fragment is
well-formed but not valid:
<Shape> rect <Size> 3x8 </Size> </Shape>
because, although the elements are properly nested, all
definitions are case sensitive and "SHAPE" does not equal
"Shape" nor does "SIZE" equal "Size" according to the DTD.
Validation Programs
A validation program reads in both the XML and the
controlling DTD or schema and then determines whether or not any of
these rules are violated: if so it can print out a message
that pinpoints the first of these errors in terms of line
and character number, the offending line, and a message
about the error type.