W3C

Schema

An XML Schema is a language for expressing constraints about XML documents.

What is an XML Schema?

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). From this page you can find out more about DTDs and W3C XSD, since those are the primary schema languages defined at W3C.

What is XML Schema Used For?

A Schema can be used:

  • to provide a list of elements and attributes in a vocabulary;
  • to associate types, such as integer, string, etc., or more specifically such as hatsize, sock_colour, etc., with values found in documents;
  • to constrain where elements and attributes can appear, and what can appear inside those elements, such as saying that a chapter title occurs inside a chapter, and that a chapter must consist of a chapter title followed by one or more paragraphs of text;
  • to provide documentation that is both human-readable and machine-processable;
  • to give a formal description of one or more documents.

Information in schema documents is often used by XML-aware editing systems so that they can offer users the most likely elements to occur at any given location in a document.

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.

The Service Modeling Language (SML) provides a framework for relating multiple XSD documents to one or more documents in a single validation episode.

Since XSD supports associating data types with element and attribute content, it is also used for data binding, that is, for software components that read and write XML representations of computer programming-language objects.

Examples

Document Type Definitions are defined in the XML Recommendation. They are very widely supported with a high degree of interoperability.

W3C XML Schema Definitions are defined in the W3C XML Schema specification. This is in three parts, of which the first part, numbered zero, is an introductory document.

Learn More

...Explanation...

Current Status of Specifications

Learn more about the current status of specifications related to:

These W3C Groups are working on the related specifications:

Contact

[photo: Liam Quin]Liam R. E. Quin <liam@w3.org>

Use It

Validators