Schema files are used to assure that the data within an XML document conforms to expected values. For example, an element
that contains a zip code may be restricted to a numeric integer. Schema files can also limit the length or number of occurrences
of an element as well as guarantee that elements occur in the expected order.
A schema file may be applied to an XML document using any of the following methods:
- The entire schema file may reside within the document. (This situation is infrequent.)
- A link to the schema file may be placed in the document. (This technique is more common.)
- A process that loads a given XML document may also load a schema file that controls the document.
Note: In the Windows implementation, the Microsoft MSXML parser 6.0 ignores the document type definition (DTD) when validating an
XML document against a schema file. Any entities declared in the DTD will not be defined and cannot be referenced. If any
entities other than the predefined XML entities are referenced, the document is not well-formed and will fail to load, much
less validate. Thus, when a DTD is generated to define entities in an exported document, the exported document should be transformed
prior to being imported so as not to contain entity references. For information on generating a DTD to define entity references,
Document Type Definition Support.