ITWissen.info - Tech know how online

XML schema

XML Schema defines a language for describing the structure and semantics of an XML document. The three-part specification was presented in March 2001 by the World Wide Web Consortium (W3C) as a recommendation - the individual parts are available under the link below.

XML schemas use XML documents

XML schemas, in contrast to Document Type Definition (DTD), are themselves based on XML documents, which makes their creation and processing much easier. In particular, the limitations of DTDs in dealing not only with text documents but with data formats for structured data of any kind, led to the definition of XML Schema. This is, among other things, a requirement that is realized in particular as soon as B2B or B2Ccommunication or, in general, the communication of application systems is involved. Like a DTD, an XML schema determines both the vocabulary and the grammar of an XML document; however, since it is an XML document, its well-formedness and validity can be checked at any time.

Before the final specification of the XML schema by the W3C, the IT industry had already made its own efforts to use XML beyond classical document processing in the form of specific variants such as XML-Data by Microsoft or Schema for Object Or iented XML (SOX) by VeoSystems. An alternative schema language is Relax NG

The recommendation published by the W3C defines three different parts of the specification:

  • XML Schema Part 0 (Primer) provides an introduction and summarizes basic information.
  • XML Schema Part 1 (Structures) defines the basic structures of an XML Schema document and details all the important elements of the schema language.
  • XML Schema Part 2 (Datatypes) defines the data types for schema documents.
Following this recommendation, an XML schema should implement the following requirements:

  • Be an XML document,
  • be more expressive than a DTD,
  • be self-documenting and readable,
  • be web-enabled,
  • be compatible with other XML specifications
  • support automatic parsing by XML parsers, and
  • take namespaces into account.
The basic structure of an XML schema contains the element schema as the root element and looks as follows:

Basic element of the XML sch

Basic element of the XML sch

ema This also defines the namespace that contains all the elements, attributes, and the predefined data types that can be used when designing a schema. The prefix of the namespace is usually xs or xsd. A so-called target namespace determines in which namespace the elements and attributes declared by the user are located. A schema is always stored in the form of a separate file of type .xsd and the corresponding XML schema is assigned to the XML document by means of an appropriately integrated declaration.

XML Schema as Application

An XML Schema defines a set of components to describe the structure of a class of XML documents. Therefore, a document corresponding to the XML Schema is also called an instance of the document class fixed by the schema. The vocabulary of the XML Schema language is itself an XML application - in this case an abstract description of content structures. XML Schema itself provides 44 predefined simple data types and additionally supports mechanisms for defining user-defined simple data types. Declarations have the task of assigning a name and a corresponding data type - there are complex and simple data types - to elements or attributes. Unlike DTDs, the assignment of data types to elements and attributes is a significant aspect of XML Schema.

An XML schema can be created for a class of XML documents in different so-called modeling variants. The corresponding XML documents will then be valid to all modeling variants, distinguishing between the Russian Matryoshka, Salami Design, and Blind Design variants.

As with all XML documents, DTDs and XML schemas can be created and edited with a simple text editor. However, since this is not very convenient and time-consuming, there are a number of tools, such as XML Authority or XML Spy, which also offer a graphical representation of the DTD or XML schema structures as well as interactive modification of them. In addition, of course, the correctness of the syntax is continuously checked. It should generally be taken into account that the code of an XML schema is significantly more extensive than the code of a DTD.

Informationen zum Artikel
Englisch: XML schema
Updated at: 29.10.2013
#Words: 568
Links: