XML Schema attributeGroup 元素
❮ 完整的 XML Schema 參考
定義和用法
attributeGroup 元素用於對一組屬性宣告進行分組,以便可以將它們作為一個組併入複雜型別定義中。
元素資訊
- 父元素: attributeGroup, complexType, schema, restriction (simpleContent 和 complexContent), extension (simpleContent 和 complexContent)
語法
<attributeGroup
id=ID
name=NCName
ref=QName
任何屬性
>
(annotation?),((attribute|attributeGroup)*,anyAttribute?))
</attributeGroup>
(? 符號表示該元素可以出現零次或一次,* 符號表示該元素可以在 attributeGroup 元素內出現零次或多次)
Attribute | 描述 |
---|---|
id | 可選。指定元素的唯一 ID |
name | 可選。指定屬性組的名稱。name 和 ref 屬性不能同時存在 |
ref | 可選。指定對命名屬性組的引用。name 和 ref 屬性不能同時存在 |
任何屬性 | 可選。指定任何其他非 schema 名稱空間的屬性 |
示例 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>
上面的示例定義了一個名為 "personattr" 的屬性組,該屬性組在名為 "person" 的複雜型別中使用。
❮ 完整的 XML Schema 參考