Validating xml using schema
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.
A schema is analogous to a grammar for a language; a schema defines what the vocabulary for the language may be and what a valid "sentence" is.
An XML Schema is a language for expressing constraints about XML documents.
There are several different schema languages in widespread use, but the main ones are Document Type Definitions (DTDs), Relax-NG, Schematron and W3C XSD (XML Schema Definitions).
XSD schemas are conventionally written as XML documents, so familiar editing and transformation tools can be used.
As well as validation, XSD allows XML instances to be annotated with type information (the Post-Schema-Validation Infoset (PSVI)) which is designed to make manipulation of the XML instance easier in application programs.
The association may be achieved via markup within the XML document itself, or via some external means.
The process of checking to see if a XML document conforms to a schema is called validation, which is separate from XML's core concept of syntactic well-formedness.
Both allow for a degree of modularity in their languages, including, for example, splitting the schema into multiple files.
And both of them are, or can be, defined in RELAX NG does not have any analog to PSVI.
Checking a document against a Schema is known as validating against that schema; for a DTD, this is just validating, but for any other type of schema the type is mentioned, such as XSD Validation or Relax-NG validation.
Validating against a schema is an important component of quality assurance.
This may be by mapping the XSD-defined types to types in a programming language such as Java ("data binding") or by enriching the type system of XML processing languages such as XSLT and XQuery (known as "schema-awareness").