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

XML Schema complexContent 元素

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

定义和用法

complexContent 元素定义对复杂类型(包含混合内容或仅包含元素)的扩展或限制。

元素信息

出现次数 一次
父元素 complexType
内容

可选项。annotation

必选项。 有并且只有一个下列元素: restriction (complexContent) 或 extension (complexContent)。

语法

</>code

  1. <complexContent
  2. id=ID
  3. mixed=true|false
  4. any attributes
  5. >
  6. (annotation?,(restriction|extension))
  7. </complexContent>

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

属性 描述
id 可选。规定该元素的唯一的 ID。
mixed 可选。规定是否允许字符数据出现在该 complexType 元素的子元素之间。 默认值为 false。
any attributes 可选。规定带有 non-schema 命名空间的任何其他属性。

实例

下面的例子中有一个复杂类型 "fullpersoninfo",这个复杂类型是通过用三个补充的元素扩展继承的类型,从另一个复杂类型 "personinfo" 衍生而来的:

</>code

  1. <xs:element name="employee" type="fullpersoninfo"/>
  2. <xs:complexType name="personinfo">
  3. <xs:sequence>
  4. <xs:element name="firstname" type="xs:string"/>
  5. <xs:element name="lastname" type="xs:string"/>
  6. </xs:sequence>
  7. </xs:complexType>
  8. <xs:complexType name="fullpersoninfo">
  9. <xs:complexContent>
  10. <xs:extension base="personinfo">
  11. <xs:sequence>
  12. <xs:element name="address" type="xs:string"/>
  13. <xs:element name="city" type="xs:string"/>
  14. <xs:element name="country" type="xs:string"/>
  15. </xs:sequence>
  16. </xs:extension>
  17. </xs:complexContent>
  18. </xs:complexType>

在上例中,"employee" 元素必须按顺序包含下面的元素:"firstname"、"lastname"、"address"、"city" 以及 "country"。

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

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

快速入口

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

其它栏目

· 建站教程
· 365学习

业务咨询

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

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

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