-- 作者:sun2010
-- 发布时间:9/14/2010 12:01:00 PM
-- 帮忙看看,schema 为何起不到验证作用,如<age>取值abcd却不报错
department_xsd.xsd文件 <?xml version="1.0" encoding="ISO-8859-1" ?> <xs:schema xmlns:xs="http:www.w3c.org/2001/XMLschema" targetNamespace="123456.com" elementFormDefault="qualified"> <xs:complexType name="departmentType"> <xs:sequence> <xs:element name="staff" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="sex"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:numeration value="m" /> <xs:numeration value="f" /> </xs:restriction> </xs:simpleType> </xs:element> <xs:element name="position"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:numeration value="professor" /> <xs:numeration value="lecter" /> <xs:numeration value="assitaince" /> <xs:numeration value="lab" /> </xs:restriction> </xs:simpleType> </xs:element> <xs:element name="name" type="xs:string" /> <xs:element name="age" type="xs:positiveInteger" /> <xs:element name="class" type="xs:string" minOccurs="0" /> <xs:element name="status" > <xs:simpleType> <xs:restriction base="xs:string"> <xs:numeration value="work" /> <xs:numeration value="retired" /> </xs:restriction> </xs:simpleType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> <xs:element name="department"> <xs:complexType> <xs:sequence> <xs:element name="computer" type="departmentType" /> <xs:element name="art" type="departmentType" /> <xs:element name="politics" type="departmentType" /> </xs:sequence> </xs:complexType> </xs:element> </xs:schema> xml文件 <?xml version="1.0" encoding="ISO-8859-1" ?> <department xmlns="123456.com" xmlns:xsi="http:www.w3c.org/2001/XMLschema-instance" xsi:schemaLocation="123456.com department_xsd.xsd"> <computer> <staff> <sex>f</sex> <position>lab</position> <name>wanger</name> <age>34</age> <class>3</class> <status>work</status> </staff> <staff> <sex>f</sex> <position>lecter</position> <name>zhaoliu</name> <age>43</age> <class>4</class> <status>work</status> </staff> <staff> <sex>f</sex> <position>lab</position> <name>zhaoer2</name> <age>67</age> <status>retired</status> </staff> </computer> <art> <staff> <sex>m</sex> <position>lecter</position> <name>lisimusic</name> <age>42</age> <class>6</class> <status>work</status> </staff> <staff> <sex>f</sex> <position>lab</position> <name>wangermusic</name> <age>35</age> <status>work</status> </staff> </art> <politics> <staff> <sex>f</sex> <position>lecter</position> <name>zhaoliuP</name> <age>43</age> <class>4</class> <status>work</status> </staff> <staff> <sex>m</sex> <position>lecter</position> <name>zhaoerP</name> <age>71</age> <status>retired</status> </staff> </politics> </department> [此贴子已经被作者于2010-9-22 0:04:37编辑过]
|