XML入门:Schema约束API查看

<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.org/1" xmlns:tns="http://www.example.org/1" elementFormDefault="qualified">
      <element name="person">
         <complexType>
           <XXXXXXX>
             <element name="name" type="string"></element>
             <element name="age" type="int"></element>
           </XXXXXXX>
           <attribute name="p1" type="string" use="required"></attribute>
         </complexType>
      </element>
</schema>

<XXXXXX>

 

<sequence> :表示元素的出现顺序

<all>:表示元素只能出现一次

<Choice>: 只能出现其中的一个

<maxOccurs="unbounded"> 表示出现次数没有限制

<element name=“name” type="double" maxOccurs="unbounded"/>

<any></any> :表示任意元素

定义属性(必须是复杂元素):

<attribute name="p1" type="string" use="required"></attribute>

1.要写在复杂元素里面  </complexType>上面

2.name:属性名称  type: 属性类型    use:属性是否必须要出现

 

引入多个Schema文件,可以给每一个起一个别名

阅读剩余
THE END