全局声明与局部声明

全局声明:
  也就是直接处于<xs:schema>下元素或属性的声明。

局部声明:
  处于复杂类型定义之下元素或属性的声明。

例:
XML文档:
<?xml version="1.0"?>
<books xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="027.xsd" id="3">
<name id="001">XML学习天下
<author>张三</author>
<price>88.50</price>
</name>
<name id="002">XML百例
<author>李四</author>
<author>赵五</author>
<price>68.00</price>
</name>
</books>

Schema文档:
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="books">
<xs:complexType>
<xs:sequence>
<xs:element name="name" type="name_book" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute ref="id" use="required"/>
</xs:complexType>
</xs:element>

<xs:complexType name="name_book" mixed="true">
<xs:sequence>
<xs:element name="author" type="xs:string" maxOccurs="3"/>
<xs:element name="price" type="xs:decimal"/>
</xs:sequence>
<xs:attribute ref="id" use="required"/>
</xs:complexType>

<xs:attribute name="id" type="xs:integer"/>
</xs:schema>
说明:
  <books>元素声明为全局声明;
  <name>、<author>和<price>均为局部声明;
  <books>里的属性id为全局元素属性;
  <name>里的属性id为局部元素属性。
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值