XML Schema anyAttribute 元素
❮ 完整的 XML Schema 參考
定義和用法
anyAttribute 元素允許作者使用模式未指定的屬性來擴充套件 XML 文件。
元素資訊
- 父元素: complexType, restriction (simpleContent 和 complexContent), extension (simpleContent 和 complexContent), attributeGroup
語法
<anyAttribute
id=ID
namespace=名稱空間
processContents=lax|skip|strict
任何屬性
>
(annotation?)
</anyAttribute>
(? 符號表示該元素可以在 anyAttribute 元素內出現零次或一次)
Attribute | 描述 |
---|---|
id | 可選。指定元素的唯一 ID |
namespace | 可選。指定允許使用的屬性所屬的名稱空間。可以設定為以下之一:
|
processContents | 可選。指定 XML 處理器應如何處理此 any 元素指定的元素的驗證。可以設定為以下之一:
|
任何屬性 | 可選。指定任何其他非 schema 名稱空間的屬性 |
示例 1
以下示例顯示了名為“person”的元素的宣告。透過使用 <anyAttribute> 元素,作者可以為“person”元素新增任意數量的屬性。
<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>
❮ 完整的 XML Schema 參考