当前位置: 首页 > 网络学院 > XML相关教程 > Schema (XSD) > XML Schema attributeGroup 元素

Schema (XSD)
XSD 逻辑值数据类型
XML Schema总结
XML Schema 参考
XSD 验证

Schema (XSD) 中的 XML Schema attributeGroup 元素


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-04   浏览: 466 ::
收藏到网摘: n/a

Definition and Usage
定义和用法

The attributeGroup element is used to group a set of attribute declarations so that they can be incorporated as a group into complex type definitions.
attributeGroup元素的作用是:将一组属性声明群组到复合类型声明中。

Element Information
元素信息

  • Parent elements: attributeGroup, complexType, schema, restriction (both simpleContent and complexContent), extension (both simpleContent and complexContent)
    父类元素:attributeGroup[属性组]、schema、complexType[符合类型]、restriction[限制] (包括simpleContent[单一内容]和complexContent[复合内容])、extension[扩展] (包括simpleContent[单一内容]和complexContent[复合内容])

Syntax
语法

<attributeGroup
id=ID
name=NCName
ref=QName
any attributes
>
(annotation?),((attribute|attributeGroup)*,anyAttribute?))
</attributeGroup>

(The ? sign declares that the element can occur zero or one time, and the * sign declares that the element can occur zero or more times inside the attributeGroup element)
“?”符号用于声明元素可以出现的次数(0次或1次),“*”符号用于声明元素可以在attributeGroup元素中出现的次数(0次或多次)。

属性 描述
id Optional. Specifies a unique ID for the element
可选参数。为元素指定一个独立的ID
name Optional. Specifies the name of the attribute group. Name and ref attributes cannot both be present
可选参数。指定属性组名称。名称和ref 属性不能同时存在
ref Optional. Specifies a reference to a named attribute group. Name and ref attributes cannot both be present
可选参数。为一个已命名的属性指定一个参数。名称和ref 属性不能同时存在。
any attributes Optional. Specifies any other attributes with non-schema namespace
可选参数。指定其它的非schema命名空间的属性

Example 1
案例1

<xs:attributeGroup name="personattr"> <xs:attribute name="attr1" type="string"/> <xs:attribute name="attr2" type="integer"/>
</xs:attributeGroup>
<xs:complexType name="person"> <xs:attributeGroup ref="personattr"/>
</xs:complexType>

The example above defines an attribute group named "personattr" which is used in a complex type named "person".
上述案例定义了一个名为“personattr”的属性组,该属性组是在名为“person”的复合类型中使用的。

评论 (0) All

登陆 | 还没注册?