使用XML Spy来定义一个XML schema

A hello world sample.
http://www.javadrink.cn/article/475.htm

一些基本概念:
一个xsd文件可以定义多个root Element,每个root Element对应一个xml的schema.
可以自定义多个complex type,也可以不定义complex type,前者的好处是可以 重用定义过的complex type,常用在在shema比较复杂的时候
最常用的一些shema 语法:
Indicator
There are seven indicators:

Order indicators:

All
Choice
Sequence
Occurrence indicators:

maxOccurs
minOccurs
Group indicators:

Group name
attributeGroup name
Indicator 是用来控制Element怎么排列的关键字,xmlspy里可以看到3种Indicator
All Indicator:无顺序,minOcus:0/1, maxOcus: 1
Sequence Indicator:有序,minOcus,maxOcus没有限制
Choice Indicator:多者选其一

我们可以定义一个Element indicator的group,这样可以复用,
xs:group name="persongroup
xs:sequence>
xs:group ref="persongroup"

同样的Attribute有类似的。

这样,xsd就在3个层次上建立起复用。
complex type----Element
xs:group---->Element的顺序 ---->xmlspy(组合)
xs:attributeGroup---->attribute--->xmlspy(属性组)


一个非常好的在线查询网站:
http://www.w3schools.com/Schema/default.asp
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值