Latest web development tutorials

Why use XML Schema?

XML Schema is more powerful than the DTD.


XML Schema datatypes support

One of the most important is the ability of XML Schema data types are supported.

Through support for data types:

  • It can be more easily described allowable document content
  • It can be more easily verify the correctness of the data
  • Can more easily work together with data from the database
  • Data can be more easily defined constraints (data facets)
  • Can more easily define the data model (or data format)
  • It can be more easily convert data between different data types

Editor's note: The data constraints, or said facets, is XML Schema prototype of a term, Chinese can be translated as "face", used to constrain the allowable value of the data type.


XML Schema using the XML syntax

Another important feature about XML Schema is that they are written by XML.

XML write the XML Schema has many advantages:

  • Without having to learn a new language
  • You can use XML editor to edit your Schema files
  • You can use XML parser to parse your Schema files
  • Schema can be handled through XML DOM
  • Schema can be converted by XSLT

XML Schema can protect data communication

When data is sent from the sender to the recipient, the point is that both sides should respect the content of the same "expectations."

By XML Schema, the sender can in a recipient can understand the way to describe the data.

A data, such as "03-11-2004" in some countries, be interpreted as November 3, while in other countries as March 11.

However, a data type of XML element with, for example: <date type = "date"> 2004-03-11 </ date>, to ensure consistent understanding of the content, because the XML data type "date" requirement the format is "YYYY-MM-DD".


XML Schema can be extended

XML Schema is extensible, because they are written by XML.

By extensible Schema definition you can:

  • Reuse your Schema in other Schema
  • Created by standard types derived from your own data types
  • Schema multiple references in the same document

Good form is not enough

We called the document conforms to the XML syntax of well-formed XML documents, such as:

  • It must begin with the XML declaration
  • It must have a unique root element
  • Start tag must match the end tag
  • Elements are case sensitive
  • All elements must be closed
  • All elements must be properly nested
  • Special characters must use entity

Even the good form of the document, still can not guarantee that they will not contain errors, and those errors can have serious consequences.

Consider the following situation: you order 5 dozen laser printers, instead of five. By XML Schema, most of these errors can be caught in your software to verify.