-- 作者:gaojianxun000
-- 发布时间:9/10/2007 10:28:00 AM
-- 对复杂型xm的schema定义,元素出错问题请求帮助。l
我copy了个xml如下: <?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="false.xsl"?> <persons xmlns="http://www.w3school.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3school.com false.xsd"> <person> <name>lisongtao</name> <age>25</age> <tel> <hometel> <tell>64456787</tell> <childtel>64456785</childtel> </hometel> <offtel>44442222</offtel> <worktel>3333333</worktel> </tel> </person> <person> <name>liweiasd</name> <age>25</age> <tel> <hometel> <tell>66545434</tell> <childtel>65433333</childtel> </hometel> <offtel>64442222</offtel> <worktel>6333333</worktel> </tel> </person> <person> <name>zhangxue</name> <age>25</age> <tel> <hometel> <tell>84343434</tell> <childtel>8333333</childtel> </hometel> <offtel>84442222</offtel> <worktel>8333333</worktel> </tel> </person> <person> <name>wureasd</name> <age>26</age> <tel> <hometel> <tell>66545434</tell> <childtel>65433333</childtel> </hometel> <offtel>64442222</offtel> <worktel>6333333</worktel> </tel> </person> </persons> 对于上面的xml我写了这样一个schema: <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.w3school.com" targetNamespace="http://www.w3school.com" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xs:element name="persons"> <xs:complexType> <xs:sequence> <xs:element name="person"> <xs:complexType> <xs:sequence> <xs:element name="name" type="xs:string"/> <xs:element name="age" type="xs:string"/> <xs:element ref="tel"/> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="tel"> <xs:complexType> <xs:sequence> <xs:element name="hometel"> <xs:complexType> <xs:sequence> <xs:element name="tell" type="xs:string"/> <xs:element name="childtel" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="offtel" type="xs:string"/> <xs:element name="worktel" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:element> </xs:schema> 结果在xml中的第二个person老是显示错误,错误类型为: cvc-complex-type.2.4.d: Invalid content was found starting with element 'person'. No child element is expected at this point. 想了很长时间不知道所谓.希望高手帮忙。
|