||It has been suggested that XML schema languages be merged into this article. (Discuss) Proposed since November 2012.|
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.
There are languages developed specifically to express XML schemas. The Document Type Definition (DTD) language, which is native to the XML specification, is a schema language that is of relatively limited capability, but that also has other uses in XML aside from the expression of schemas. Two more expressive XML schema languages in widespread use are XML Schema (with a capital S) and RELAX NG.
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.
There is some confusion as to when to use the capitalized spelling "Schema" and when to use the lowercase spelling. The lowercase form is a generic term and may refer to any type of schema, including DTD, XML Schema (aka XSD), RELAX NG, or others, and should always be written using lowercase except when appearing at the start of a sentence. The form "Schema" (capitalized) in common use in the XML community always refers to W3C XML Schema.
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.
XML schema languages
- Constraint Language in XML (CLiX)
- Document Content Description facility for XML, an RDF framework
- Document Definition Markup Language (DDML)
- Document Schema Definition Languages (DSDL)
- Document Structure Description (DSD)
- SGML’s Document Type Definition (DTD)
- Namespace Routing Language (NRL)
- OASIS CAM Content Assembly Mechanism
- RELAX NG and its predecessors RELAX and TREX
- Schema for Object-Oriented XML (SOX)
- XML-Data Reduced (XDR)
- ASN.1 XML Encoding Rules (XER)
- XML Schema (WXS or XSD)
- Data structure
- Structuring information
- List of XML schemas
- XML Information Set
- XML Schema Language Comparison
- Schema (disambiguation) (for other uses of the term)
- Comparing XML Schema Languages by Eric van der Vlist (2001)
- Comparative Analysis of Six XML Schema Languages by Dongwon Lee, Wesley W. Chu, In ACM SIGMOD Record, Vol. 29, No. 3, page 76-87, September 2000
- Taxonomy of XML Schema Languages using Formal Language Theory by Makoto Murata, Dongwon Lee, Murali Mani, Kohsuke Kawaguchi, In ACM Trans. on Internet Technology (TOIT), Vol. 5, No. 4, page 1-45, November 2005
- Application of XML Schema in Web Services Security by Sridhar Guthula, W3C Schema Experience Report, May 2005
- March 2009 DEVX article "Taking XML Validation to the Next Level: Introducing CAM" by Michael Sorens