anyAttribute 元素使創(chuàng)作者可以通過未被 schema 規(guī)定的屬性來擴展 XML 文檔。
項目 | 說明 |
---|---|
出現(xiàn)次數(shù) | 無限制 |
父元素 | complexType、restriction (simpleContent)、extension (simpleContent)、restriction (complexContent)、extension (complexContent)、attributeGroup |
內(nèi)容 | annotation |
<anyAttribute id=ID namespace=namespace processContents=lax|skip|strict any attributes > (annotation?) </anyAttribute>
(? 符號聲明該元素可在 anyAttribute 元素內(nèi)出現(xiàn)零次或一次。)
可選。規(guī)定該元素的唯一的 ID。
可選。規(guī)定包含可以使用的元素的命名空間。如果沒有指定命名空間,則 ##any 為默認值。如果指定命名空間,則必須是以下值之一。
可選。一個指示符,指示應(yīng)用程序或 XML 處理器應(yīng)如何根據(jù)由該 any 元素指定的元素處理 XML 文檔的驗證。 如果沒有指定 processContents 屬性,則默認為 strict。 如果指定了 processContents,必須是以下值之一。
可選。規(guī)定帶有 non-schema 命名空間的任何其他屬性。
下面的例子展示了針對 "person" 元素的一個聲明。通過使用 <anyAttribute> 元素,創(chuàng)作者能夠向 "person" 元素添加任意數(shù)量的屬性:
<xs:element name="person"> <xs:complexType> <xs:sequence> <xs:element name="firstname" type="xs:string"/> <xs:element name="lastname" type="xs:string"/> </xs:sequence> <xs:anyAttribute/> </xs:complexType> </xs:element>
如對本文有疑問,請?zhí)峤坏浇涣髡搲瑥V大熱心網(wǎng)友會為你解答??! 點擊進入論壇