您现在的位置: 365建站网 > 建站教程 > Schema 教程 > XML Schema anyAttribute 元素

XML Schema anyAttribute 元素

此节有 232 人学习过     参与评论

定义和用法

anyAttribute 元素使创作者可以通过未被 schema 规定的属性来扩展 XML 文档。

元素信息

项目 说明
出现次数 无限制
父元素 complexType、restriction (simpleContent)、extension (simpleContent)、restriction (complexContent)、extension (complexContent)、attributeGroup
内容 annotation

语法

<anyAttribute
id=ID
namespace=namespace
processContents=lax|skip|strict
any attributes
>

(annotation?)

</anyAttribute>

(? 符号声明该元素可在 anyAttribute 元素内出现零次或一次。)

属性

id

可选。规定该元素的唯一的 ID。

namespace

可选。规定包含可以使用的元素的命名空间。如果没有指定命名空间,则 ##any 为默认值。如果指定命名空间,则必须是以下值之一。

  • ##any - 来自任何命名空间的元素都可以出现(默认)。
  • ##other - 来自该元素的父元素的目标命名空间之外的任何命名空间的元素都可以出现。
  • ##local - 未由命名空间限定的元素可以出现。
  • ##targetNamespace - 来自包含该元素的父元素的目标命名空间的元素可以出现。
  • {URI references of namespaces, ##targetNamespace, ##local} 的列表 - 来自通过空格分隔的命名空间列表的元素可以出现。 该列表可以包含以下内容: 命名空间 ##targetNamespace 和 ##local 的 URI 引用。

processContents

可选。一个指示符,指示应用程序或 XML 处理器应如何根据由该 any 元素指定的元素处理 XML 文档的验证。 如果没有指定 processContents 属性,则默认为 strict。 如果指定了 processContents,必须是以下值之一。

  • strict - XML 处理器必须获得所需命名空间的架构,并且必须验证来自这些命名空间的所有元素。(默认)
  • lax - 与 strict 相同;但是,即使不能获取该架构,也不会发生任何错误。
  • skip - XML 处理器不尝试验证来自指定命名空间的所有元素。

any attributes

可选。规定带有 non-schema 命名空间的任何其他属性。

实例

下面的例子展示了针对 "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>

如对本文有疑问,请提交到交流论坛,广大热心网友会为你解答!! 点击进入论坛

发表评论 (232人查看0条评论)
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
昵称:
最新评论
------分隔线----------------------------
Schema 教程目录

快速入口

· 365软件
· 杰创官网
· 建站工具
· 网站大全

其它栏目

· 建站教程
· 365学习

业务咨询

· 技术支持
· 服务时间:9:00-18:00
365建站网二维码

Powered by 365建站网 RSS地图 HTML地图

copyright © 2013-2024 版权所有 鄂ICP备17013400号