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

XML Schema redefine 元素

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

定义和用法

redefine 元素允许在当前 Schema 中重新定义从外部架构文件中获取的简单和复杂类型、组和属性组。

元素信息

出现次数 无限制
父元素 schema
内容 annotation、attributeGroup、complexType、group、simpleType

语法

</>code

  1. <redefine
  2. id=ID
  3. schemaLocation=anyURI
  4. any attributes
  5. >
  6. (annotation|(simpleType|complexType|group|attributeGroup))*
  7. </redefine>
属性 描述
id 可选。规定该元素的唯一的 ID。
schemaLocation 必需。对 schema 文档位置的 URI 引用。
any attributes 可选。规定带有 non-schema 命名空间的任何其他属性。

实例

例子 1

下面的例子展示了一个 schema,Myschama2.xsd,其中存在由 Myschama1.xsd 规定的元素。pname 类型被重新定义。根据此 schema,被 pname 约束的元素必须以 "country" 元素结束:

Myschema1.xsd:

</>code

  1. <?xml version="1.0"?>
  2. <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  3. <xs:complexType name="pname">
  4. <xs:sequence>
  5. <xs:element name="firstname"/>
  6. <xs:element name="lastname"/>
  7. </xs:sequence>
  8. </xs:complexType>
  9. <xs:element name="customer" type="pname"/>
  10. </xs:schema>

Myschema2.xsd:

</>code

  1. <?xml version="1.0"?>
  2. <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  3. <xs:redefine schemaLocation="Myschema1.xsd">
  4. <xs:complexType name="pname">
  5. <xs:complexContent>
  6. <xs:extension base="pname">
  7. <xs:sequence>
  8. <xs:element name="country"/>
  9. </xs:sequence>
  10. </xs:extension>
  11. </xs:complexContent>
  12. </xs:complexType>
  13. </xs:redefine>
  14. <xs:element name="author" type="pname"/>
  15. </xs:schema>

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

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

快速入口

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

其它栏目

· 建站教程
· 365学习

业务咨询

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

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

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