Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Why Use XML Schema?

Why Use XML Schemas?


XML Schema is more powerful than DTD.


XML Schema supports data types

One of the most important capabilities of XML Schema is its support for data types.

Through support for data types:

Editor's note: data constraints, or facets, are a term in the XML Schema prototype, translated into Chinese as "face", used to constrain the allowable values of a data type.


XML Schema Uses XML Syntax

Another important feature of XML Schema is that they are written in XML.

There are many benefits to writing XML Schema in XML:


XML Schema Can Protect Data Communication

When data is sent from sender to receiver, the key point is that both parties should have the same "expectations" about the content.

With XML Schema, the sender can describe data in a way that the receiver can understand.

A piece of data, such as "03-11-2004", is interpreted as November 3 in some countries, and as March 11 in others.

But an XML element with a data type, such as:2004-03-11, ensures a consistent understanding of the content, because the XML data type "date" requires the format "YYYY-MM-DD".


XML Schema Is Extensible

XML Schema is extensible because it is written in XML.

With extensible schema definitions, you can:


Well-Formed Is Not Enough

We call documents that comply with XML syntax well-formed XML documents, for example:

Even if documents are well-formed, there is still no guarantee that they do not contain errors, and these errors may have serious consequences.

Consider the following situation: you ordered 5 dozen laser printers instead of 5. With XML Schema, most such errors will be caught by your validation software.