XML Schema attributeGroup 元素
完整 XML Schema 參考手冊(cè)
定義和用法
attributeGroup 元素用于對(duì)屬性聲明進(jìn)行組合,這樣這些聲明就能夠以組合的形式合并到復(fù)雜類(lèi)型中。
元素信息
- 父元素: attributeGroup, complexType, schema, restriction (both simpleContent and complexContent), extension (both simpleContent and complexContent)
語(yǔ)法
<attributeGroup
id=ID
name=NCName
ref=QName
any attributes
>
(annotation?),((attribute|attributeGroup)*,anyAttribute?))
</attributeGroup>
(? 符號(hào)聲明在 attributeGroup 元素中,元素可出現(xiàn)零次或一次,* 符號(hào)聲明元素可出現(xiàn)零次或多次。)
屬性 | 描述 |
id | 可選。規(guī)定該元素的唯一的 ID。 |
name | 可選。規(guī)定屬性組的名稱(chēng)。name 和 ref 屬性不能同時(shí)出現(xiàn)。 |
ref | 可選。規(guī)定對(duì)指定的屬性組的引用。name 和 ref 屬性不能同時(shí)出現(xiàn)。 |
any attributes | 可選。規(guī)定帶有 non-schema 命名空間的任何其他屬性。 |
實(shí)例 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>
上面的例子定義了一個(gè)名為 "personattr" 的屬性組,在名為 "person" 的復(fù)雜類(lèi)型中使用。
完整 XML Schema 參考手冊(cè)
更多建議: