XML schema languages

From Wikipedia, the free encyclopedia
  (Redirected from XML schema language comparison)
Jump to: navigation, search

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 syntax constraints imposed by XML itself. There are several different languages available for specifying an XML schema. Each language has its strengths and weaknesses.

Note: the W3C defined schema language is called "XML Schema". However, this name can be confusing in the context of referring to a number of XML schema languages. As such, throughout this document, references to the term "XML schema" will be any XML schema language where the meaning might be ambiguous, while the term "W3C XML Schema" (referred to in this article as WXS) will be used for the W3C-defined XML schema language.



This article also covers a brief review of other schema languages.

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. A schema is somewhat equivalent to a grammar for a language; a schema defines what the vocabulary for the language may be and what a valid "sentence" is.

Document Type Definitions[edit]

Tool Support[edit]


W3C XML Schema[edit]

Main article: XML Schema (W3C)

Advantages over DTDs[edit]

Compared to DTDs, W3C XML Schemas are exceptionally powerful. They provide much greater specificity than DTDs could. They are namespace aware, and provide support for types.

W3C XML Schema is written in XML itself, and therefore has a schema of its own (appropriately, written in W3C XML Schema).

W3C XML Schema has a large number of built-in and derived data types. These are specified by the W3C XML Schema specification, so all W3C XML Schema validators and processors must support them.

Due to the nature of the schema language, after an XML document is validated, the entire XML document, both content and structure, can be expressed in terms of the schema itself. This functionality, known as Post-Schema-Validation Infoset (PSVI), can be used to transform the document into a hierarchy of typed objects that can be accessed in a programming language through a neutral interface.

Commonality with RELAX NG[edit]

RELAX NG and W3C XML Schema allow for similar mechanisms of specificity. Both allow for a degree of modularity in their languages, going so far as to being able to split the schema into multiple files. And both of them are, or can be, defined in an XML language.

Advantages over RELAX NG[edit]

RELAX NG does not have any analog to PSVI. Unlike W3C XML Schema, RELAX NG was designed so that validation and augmentation (adding type information and default values) are separate (See XML Schema (W3C)#Criticism).

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 (See XML Schema (W3C)#Criticism).

RELAX NG has no ability to apply default attribute data to an element's list of attributes (i.e., changing the XML info set), while W3C XML Schema does. Again, this design is intentional and is to separate validation and augmentation (See XML Schema (W3C)#Criticism).[1]









Tool Support[edit]


RELAX NG[edit]

Main article: RELAX NG


Advantages over W3C XML Schema[edit]




  <ref name="odd" />
  <ref name="even" />
  <ref name="odd" />



<element name="some_element">
    <attribute name="has_name">
      <attribute name="has_name">








Tool Support[edit]

RELAX NG's tool support is significant, but it is less widespread than W3C XML Schema. The Mono Project's implementation of the .NET Framework includes a RELAX NG validator. The C library libxml2 provides RELAX NG support as well. Sun Microsystems's Multiple Schema Validator for Java also provides RELAX NG support.


Main article: Schematron







Tool Support[edit]


Namespace Routing Language (NRL)[edit]



See also[edit]

