Schema Why
# 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:
* Itβs easier to describe allowed document content
* Itβs easier to validate data correctness
* Itβs easier to work with data from databases
* Itβs easier to define data constraints (data facets)
* Itβs easier to define data models (or data formats)
* Itβs easier to convert data between different data types
Editorβs Note: Data constraints, or facets, are a term in XML Schema that can be translated into Chinese as βfaces,β used to constrain the allowable values of data types.
* * *
## XML Schema Uses XML Syntax
Another important feature of XML Schema is that they are written in XML.
### Writing XML Schema in XML Has Many Benefits:
* No need to learn a new language
* You can use an XML editor to edit Schema files
* You can use an XML parser to parse Schema files
* You can process Schema through XML DOM
* You can transform Schema through XSLT
* * *
## XML Schema Protects Data Communication
When data is sent from the sender to the receiver, the key point is that both parties should have the same βexpectationsβ about the content.
With XML Schema, the sender can describe the data in a way that the receiver can understand.
For example, the data β03-11-2004β might be interpreted as November 3rd in some countries and as March 11th in others.
However, an XML element with a data type, such as 2004-03-11, ensures 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 they are written in XML.
### Through Extensible Schema Definitions, you can:
* Reuse your Schema in other Schemas
* Create your own data types derived from standard types
* Reference multiple Schemas in the same document
* * *
## Being Well-Formed Is Not Enough
YouTip