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

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

Schema (XSD) 中的 XML Schema anyAttribute 元素


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

Definition and Usage
定义和用法

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

Element Information
元素信息

  • Parent elements: complexType, restriction (both simpleContent and complexContent), extension (both simpleContent and complexContent), attributeGroup
    父类元素: complexType[符合类型]、restriction[限制] (包括simpleContent[单一内容]和complexContent[复合内容])、extension[扩展] (包括simpleContent[单一内容]和complexContent[复合内容])、attributeGroup[属性组]

Syntax
语法

<anyAttribute
id=ID
namespace=namespace
processContents=lax|skip|strict
any attributes
>
(annotation?)
</anyAttribute>

(The ? sign declares that the element can occur zero or one time inside the anyAttribute element)
“?”符号用于声明元素在anyAttribute元素中允许出现的次数(0次或1次)

属性 描述
id Optional. Specifies a unique ID for the element
可选参数。为元素指定一个独立的ID
namespace

Optional. Specifies the namespaces containing the attributes that can be used. Can be set to one of the following:

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

  • ##any - attributes from any namespace is allowed (this is default)
    ##any - 允许来自于任何命名空间的属性(默认值)
  • ##other - attributes from any namespace that is not the namespace of the parent element can be present
    ##other - 可以使用非父类元素命名空间中的属性
  • ##local - attributes must come from no namespace
    ##local - 非命名空间属性
  • ##targetNamespace - attributes from the namespace of the parent element can be present
    ##targetNamespace - 可以使用父类元素命名空间中的属性
  • List of {URI references of namespaces, ##targetNamespace, ##local} - attributes 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 <anyAttribute> element the author can add any number of attributes to the "person" element:
下面的案例声明了一个名为“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>

评论 (0) All

登陆 | 还没注册?