15.2.4. Choosing a Validation Method
The first major implementation decision of designing a new XML
application is what type of validation (if any) will be performed on
instance documents. In many cases, prototyping a set of instance
documents is the best way to determine what level of validation must
be performed.
If your application is simply saving some internal program state
between invocations (such as window positions or menu configurations
within a GUI application), going to the trouble of building a schema
and validating documents may not be necessary. Since these
configuration documents will always be written and read by the same
program, the structure is fixed by the program logic itself. The only
conceivable purpose for validating a document like this would be to
detect file corruption, which would be likely to generate a
well-formedness error in any case.
An example of an application that would require some level of
validation is where XML documents are exchanged between different
related systems that are not maintained by the same development
organization. In this case, a DTD or schema can serve as a definitive
blueprint to ensure that all systems are sending and receiving
information in the expected formats.
The most rigorous type of validation is required when developing a
new XML standard that will be implemented independently by many
different vendors without any explicit control or restrictions. For
example, the XHTML 1.1 standard is enforced by a very explict and
well-documented DTD that is hosted by the W3C. This well-known public
DTD allows tool and application vendors to ensure that their systems
will interoperate as long as instance documents conform to the
standard.
After determining the level of validation for a particular
application, it must be decided what validation language will be
used. The DTD mechanism of XML 1.0 is still the most widely supported
standard, although it lacks the expressive power that is required by
sophisticated data-oriented applications. The W3C XML schema
recommendation provides very rich type and content model expression,
but brings with it a commensurate level of complexity.