当前位置: 首页 > 网络学院 > XML相关教程 > Schema (XSD) > XML Schema any 元素

Schema (XSD)
XSD 逻辑值数据类型
XML Schema总结
XML Schema 参考
XSD 验证

Schema (XSD) 中的 XML Schema any 元素


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-04   浏览: 291 ::
收藏到网摘: n/a

Definition and Usage
定义和用法

The any element enables the author to extend the XML document with elements not specified by the schema.
any元素可以让代码设计者使用未被schema指定的元素来扩展XML文档。

Element Information
元素信息

  • Parent elements: choice, sequence
    父类信息:选择、序列

Syntax
语法

<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:

可选参数。指定可以使用包含元素的命名空间。可以是下列值之一:

  • ##any - elements from any namespace is allowed (this is default)
    ##any - 允许来自于任何命名空间的元素(默认值)
  • ##other - elements from any namespace that is not the namespace of the parent element can be present
    ##other - 可以使用非父类元素命名空间中的元素
  • ##local - elements must come from no namespace
    ##local - 非命名空间元素
  • ##targetNamespace - elements from the namespace of the parent element can be present
    ##targetNamespace - 可以使用父类元素命名空间中的元素
  • List of {URI references of namespaces, ##targetNamespace, ##local} - elements from a space-delimited list of the namespaces can be present
    {URI 命名空间参数、##targetNamespace、##local} 列表 - 可以使用命名空间的空格定界符列表中的元素
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处理器处理元素有效性的方式。可以是下列值之一:

  • strict - the XML processor must obtain the schema for the required namespaces and validate the elements (this is default)
    strict [严格] - XML处理器必须包含必要命名空间的schema,并验证元素的有效性(默认值)
  • lax - same as strict but; if the schema cannot be obtained, no errors will occur
    lax [不严格] - 功能于strict相同,但是,如果不能包含schema,也不会产生错误信息
  • skip - The XML processor does not attempt to validate any elements from the specified namespaces
    skip [跳过] - XML处理器不验证来自于指定命名空间的任何元素
any attributes Optional. Specifies any other attributes with non-schema namespace
可选参数。指定非schema命名空间的其它属性

Example 1
案例1

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>

评论 (0) All

登陆 | 还没注册?