15.2.56. XML Schema attribute element

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

Page Views: 9 views

XML Schema 参考手册 完整 XML Schema 参考手册

Definition and usage

The attribute element defines an attribute.

Element information

  • 父元素: AttributeGroup, schema, complexType, restriction (both simpleContent and complexContent), extension (both simpleContent and complexContent)

Grammar

 (annotation?,(simpleType?))  

(? The symbol declares that the element can appear zero or once in the attribute element. )

Attribute

Description

Default

Optional. Specifies the default value for the property. The default and fixed properties cannot appear at the same time.

Fixed

Optional. Specifies the fixed value of the attribute. The default and fixed properties cannot appear at the same time.

Form

Optional. Specifies the format of the attribute. The default value is the value of the attributeFormDefault attribute of the schema element that contains the attribute. Can be set to the following values:

  • “qualified”-indicates that this attribute must be qualified by the namespace prefix and the non-colon name (NCName) of the attribute.

  • “unqualified”-indicates that this property does not need to be qualified by a namespace prefix and does not need to match the non-colon name (NCName), the local name, of this attribute.

Id

Optional. Specifies the unique ID of the element.

Name

Optional. Specifies the name of the attribute. The name and ref properties cannot appear at the same time.

Ref

Optional. Specifies a reference to the specified property. The name and ref properties cannot appear at the same time. If ref appears, the simpleType element, form, and type cannot appear.

Type

Optional. Specify built-in data types or simple types. The type attribute can only appear if the content does not contain a simpleType element.

Use

Optional. Specifies how to use this property. The following values can be set:

  • Optional-the attribute is optional and can have any value (default).

  • Prohibited-attributes cannot be used.

  • Required-required for the attribute.

Any attributes

Optional. Specifies any other attributes with the non-schema namespace.

Example 1

<xs:attribute name="code"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:pattern value="[A-Z][A-Z]"/> xs:restriction> xs:simpleType> xs:attribute>    

The above example indicates that the “code” property has a qualification. The only acceptable values are the two letters in the uppercase letters A to Z.

Example 2

To declare a property using an existing property definition in a complex type, use the ref property:

<xs:attribute name="code"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:pattern value="[A-Z][A-Z]"/> xs:restriction> xs:simpleType> xs:attribute> <xs:complexType name="someComplexType"> <xs:attribute ref="code"/> xs:complexType>     

Example 3

Property can have either a default value or a specified fixed value. When no other value is specified, the default value is automatically assigned to the property. In the following example, the default value is “EN”:

<xs:attribute name="lang" type="xs:string" default="EN"/> 

When no other value is specified, a fixed value is automatically assigned to the property. However, unlike the default value, if you specify a value other than a fixed value for the property, the document is validated as invalid. In the following example, the fixed value is “EN”:

<xs:attribute name="lang" type="xs:string" fixed="EN"/> 

Example 4

All properties are optional by default. To explicitly specify that the property is optional, use the “use” attribute:

<xs:attribute name="lang" type="xs:string" use="optional"/> 

To make an attribute a required attribute:

<xs:attribute name="lang" type="xs:string" use="required"/> 

XML Schema 参考手册 完整 XML Schema 参考手册

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

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