当前位置: 首页 > 网络学院 > XML相关教程 > Schema (XSD) > XML Schema any 元素
The any element enables the author to extend the XML document with elements not specified by the schema.
any元素可以让代码设计者使用未被schema指定的元素来扩展XML文档。
<any id=ID maxOccurs=nonNegativeInteger|unbounded minOccurs=nonNegativeInteger namespace=namespace processContents=lax|skip|strict any attributes > (annotation?) </any> |
(The ? sign declares that the element can occur zero or one time inside the any element)
“?”符号用于声明元素在any元素中允许出现的次数(0次或1次)
属性 | 描述 |
---|---|
id | Optional. Specifies a unique ID for the element 可选参数。为元素指定一个独立的ID |
maxOccurs | Optional. Specifies the maximum number of times the any element can occur in the parent element. The value can be any number >= 0, or if you want to set no limit on the maximum number, use the value "unbounded". Default value is 1 可选参数。指定any元素在父类元素中出现的最大次数。其值可以大于等于0;或者,如果你不希望对最大值进行限制,可以使用“unbounded”。默认值是1 |
minOccurs | Optional. Specifies the minimum number of times the any element can occur in the parent element. The value can be any number >= 0. Default value is 1 可选参数。指定any元素在父类元素中出现的最小次数。其值可以大于等于0。默认值是1 |
namespace | Optional. Specifies the namespaces containing the elements that can be used. Can be set to one of the following: 可选参数。指定可以使用包含元素的命名空间。可以是下列值之一:
|
processContents | Optional. Specifies how the XML processor should handle validation against the elements specified by this any element. Can be set to one of the following: 可选参数。指定XML处理器处理元素有效性的方式。可以是下列值之一:
|
any attributes | Optional. Specifies any other attributes with non-schema namespace 可选参数。指定非schema命名空间的其它属性 |
The following example shows a declaration for an element called "person". By using the <any> element the author can extend (after <lastname>) the content of "person" with any element:
下面的案例声明了一个名为“person”的元素。通过使用<any>元素,代码设计者可以(在<lastname>元素之后)扩展所有元素中的“person”内容:
<xs:element name="person"> <xs:complexType> <xs:sequence> <xs:element name="firstname" type="xs:string"/> <xs:element name="lastname" type="xs:string"/> <xs:any minOccurs="0"/> </xs:sequence> </xs:complexType> </xs:element> |