15.2.6. XSD simple element

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

Page Views: 9 views

XML Schema defines the elements of the XML file.

Simple elements are those that contain only text. It does not contain any other elements or attributes.

What are simple elements?

Simple elements are those that contain only text. It does not contain any other elements or attributes.

However, the limitation of “text only” can easily be misunderstood. There are many types of text. It can be one of the types included in the XML Schema definition (Boolean, string, data, etc.), or it can be a custom type that you define yourself.

You can also limit its content by adding qualifications (that is, facets) to the data type, or you can require the data to match a particular schema.

Define simple elements

Define the syntax for simple elements:

<xs:element name="xxx" type="yyy"/> 

Here xxx refers to the name of the element, and yyy refers to the data type of the element. XML Schema has many built-in data types.

The most common types are:

  • Xs:string

  • Xs:decimal

  • Xs:integer

  • Xs:boolean

  • Xs:date

  • Xs:time

Example

Here are some XML elements:

<lastname>Refsneslastname> <age>36age> <dateborn>1970-03-27dateborn>    

This is the corresponding simple element definition:

<xs:element name="lastname" type="xs:string"/> <xs:element name="age" type="xs:integer"/> <xs:element name="dateborn" type="xs:date"/> 

Default values and fixed values for simple elements

Simple elements can have specified default values or fixed values.

When no other value is specified, the default value is automatically assigned to the element.

In the following example, the default value is “red”:

<xs:element name="color" type="xs:string" default="red"/> 

A fixed value is also automatically assigned to the element, and you cannot specify another value.

In the following example, the fixed value is “red”:

<xs:element name="color" type="xs:string" fixed="red"/> 
《地理信息系统原理、技术与方法》  97

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