15.2.3. Why use XML Schemas?

发布时间 : 2025-10-25 13:35:24 UTC      

Page Views: 9 views

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 is easier to describe the allowed document content.

  • It is easier to verify the correctness of the data.

  • Makes it easier to work with data from the database

  • Data constraints can be more easily defined (data facets)

  • It is easier to define a data model (or data format)

  • It is easier to convert data between different data types

Editor’s note: data constraint, or facets, is a term in the XML Schema prototype, which can be translated as “face” in Chinese and is used to constrain the allowable values of data types.

XML Schema uses XML syntax

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

There are many benefits to writing XML Schema by XML:

  • There is no need to learn a new language

  • You can use the XML editor to edit Schema files

  • You can use the XML parser to parse Schema files

  • Schema can be handled through XML DOM

  • Schema can be converted through XSLT

XML Schema protects data communication

When data is sent from the sender to the receiver, the point is that both parties should have the same “expected value” about the content.

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

One kind of data, such as “03-11-2004”, is interpreted as November 3 in some countries and March 11 in others.

But a XML element with a data type, such as < date type= “date” > 2004-03-11 < / date >, ensures a consistent understanding of the content, because the format required by XML’s data type “date” is “YYYY-MM-DD”.

XML Schema Extensible

XML Schema are extensible because they are written by XML.

With extensible Schema definitions, you can:

  • Reuse your Schema in other Schema

  • Create your own data types derived from standard types

  • Reference multiple Schema in the same document

Good form is not enough.

We refer to documents that conform to XML syntax as well-formed XML documents, such as:

  • It must start with a XML declaration

  • It must have a unique root element.

  • The start tag must match the end tag

  • Elements are case sensitive

  • All elements must be closed

  • All elements must be nested correctly

  • Entities must be used for special characters

Even if the documents are well formed, there is no guarantee that they will not contain errors, and these errors can have serious consequences.

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

《地理信息系统原理、技术与方法》  97

最近几年来,地理信息系统无论是在理论上还是应用上都处在一个飞速发展的阶段。 GIS被应用于多个领域的建模和决策支持,如城市管理、区划、环境整治等等,地理信息成为信息时代重要的组成部分之一; “数字地球”概念的提出,更进一步推动了作为其技术支撑的GIS的发展。 与此同时,一些学者致力于相关的理论研究,如空间感知、空间数据误差、空间关系的形式化等等。 这恰好说明了地理信息系统作为应用技术和学科的两个方面,并且这两个方面构成了相互促进的发展过程。