XML(二):约束模式
一、约束模式
二、好处
三、常用的约束模式语言
四、XMLDTD
4、修改root节点,把 <article></article>改为自己的,并新增一条 xmlns=" http://www.tns.com" <students xmlns="http://www.tns.com" 新增 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.tns.com file:///C:/Documents%20and%20Settings/xx/%e6%a1%8c%e9%9d%a2/%e7%bd%91%e9%a1%b5API/students.xsd"> 内容 </students> 5、常用.xsd使用 <xs:element name="name" > <xs:simpleType> <xs:restriction base="xs:string"> <xs:minLength value="2"/> <xs:maxLength value="5" /> </xs:restriction> </xs:simpleType> </xs:element> //限定范围,minInclusive和maxInclusive <xs:element name="age"> <xs:simpleType> <xs:restriction base="xs:integer"> <xs:minInclusive value="0" /> <xs:maxInclusive value="35"/> </xs:restriction> </xs:simpleType> </xs:element> //限定输入取值,只能取‘男’‘女’ <xs:element name="sex"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:pattern value="['男'|'女']" /> </xs:restriction> </xs:simpleType> </xs:element> //可接受的值是由 8 个字符组成的一行字符 <xs:element name="password"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:pattern value="[a-zA-Z0-9]{8}"/> </xs:restriction> </xs:simpleType> </xs:element> 六:参考代码: (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |