XML - schema (without capital S)

1 - About

A schema contains a set of rules that constrains the structure and content of an xml document, i.e., its elements, attributes, and text.

A schema is, in other words, a specification of the syntax and semantics of a (potentially infinite) set of XML documents. A document is said to be valid with respect to a schema if, and only if, it satisfies the constraints specified in the schema.

The purpose of a schema is to define a class of XML documents, and so the term “instance document” is often used to describe an XML document that conforms to a particular schema.

An XML schema is a description of a type of XML document, typically expressed in terms of constraints on:

These constraints are generally expressed using rules to define:

They provide a means for defining:

of XML documents.

With an schema, an application can automatically parses an XML document and assign to the content the good data type. A schema describes data types, with the intent of defining one or more hierarchical types defining XML documents.

The purpose of a schema is to define a class of XML documents, and so the term “instance document” is often used to describe an XML document that conforms to a particular schema.

3 - In what language is a schema defined?

The XML specification itself describes a sublanguage for writing document-type definitions, or DTDs.

The Document Type Definition (DTD) language is then native to the XML specification. It is of relatively limited capability, but has also other uses in XML aside from the expression of schemas.

DTDs are fairly weak. They support the definition of simple constraints on structure and content, but provide no real facility for expressing datatypes or complex structural relationships.

The XML Schema language has gained widespread acceptance. It is the schema language of choice for many of the XML related specifications authored by industry standard working groups. Xsd provide functionality above and beyond what is provided by DTD.

Other languages:

  • XDR,
  • SOX,
  • RELAX NG, RELAX,
  • TREX

4 - Association

The mechanism for associating an XML document with a schema varies according to the schema language. The association may be achieved via markup within the XML document itself, or via some external means.

5 - Documentation / Reference

markup/xml/schema.txt · Last modified: 2017/09/13 21:21 by gerardnico