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
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