There are several different languages available for specifying an XML schema. The primary purpose of a schema language is to specify what the structure of an XML document can be.This means which elements can reside in which other elements, which attributes are and are not legal to have on a particular element, and so forth.
Unlike W3C XML Schema, RELAX NG was designed so that validation and augmentation (adding type information and default values) are separate.
W3C XML Schema has a formal mechanism for attaching a schema to an XML document, while RELAX NG intentionally avoids such mechanisms for security and interoperability reasons.
An XML schema is a description of a type of XML document, typically expressed in terms of constraints on the structure and content of documents of that type, above and beyond the basic syntactical constraints imposed by XML itself.
These constraints are generally expressed using some combination of grammatical rules governing the order of elements, Boolean predicates that the content must satisfy, data types governing the content of elements and attributes, and more specialized rules such as uniqueness and referential integrity constraints.
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.
There are historic and current XML schema languages: The main ones (see also the ISO 19757's endorsed languages) are described below.
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.
XSD schemas are conventionally written as XML documents, so familiar editing and transformation tools can be used.