XML Schema - Validation

Validation

The process of checking to see if an XML document conforms to a schema is called validation, which is separate from XML's core concept of syntactic well-formedness. All XML documents must be well-formed, but it is not required that a document be valid unless the XML parser is "validating," in which case the document is also checked for conformance with its associated schema. DTD-validating parsers are most common, but some support W3C XML Schema or RELAX NG as well.

Documents are only considered valid if they satisfy the requirements of the schema with which they have been associated. These requirements typically include such constraints as:

  • Elements and attributes that must/may be included, and their permitted structure
  • The structure as specified by a regular expression syntax
  • How character data is to be interpreted, e.g. as a number, a date, a URL, a Boolean, etc.

Validation of an instance document against a schema can be regarded as a conceptually separate operation from XML parsing. In practice, however, many schema validators are integrated with an XML parser.

Read more about this topic:  XML Schema