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 参考