1
我已经使用eclipse工具创建了xsd文件,我也在同一个工具中使用该xsd文件创建了xml文件。我无法识别这个错误。xml:元素的值无效
cvc-type.3.1.3: The value 'tns:name' of element 'tns:name' is not valid.
cvc-type.3.1.3: The value 'tns:description' of element 'tns:description' is not valid.
根据我的分析,它是好的,并遵循xsd文件。
这里是我的xsd文件:
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.jaggorder.org/order"
xmlns:tns="http://www.jaggorder.org/order"
elementFormDefault="qualified">
<element name="order" type="tns:order"></element>
<complexType name="order">
<sequence>
<element name= "product" type = "string"></element>
<sequence>
<element name= "name" type = "tns:name_rs"></element>
<element name= "description" type = "tns:desp"></element>
<element name= "price" type = "int"></element>
<element name= "category" type = "string"></element>
</sequence>
</sequence>
</complexType>
<simpleType name="name_rs">
<restriction base="string">
<length value="20"></length></restriction>
</simpleType>
<simpleType name="desp">
<restriction base="string">
<length value="100"></length></restriction>
</simpleType>
<simpleType name="category_en">
<restriction base="string">
<enumeration value="electronics"></enumeration>
<enumeration value="Books"></enumeration>
<enumeration value="shoes"></enumeration>
</restriction>
</simpleType>
</schema>
下面是从XSD文件我生成的XML文件。
<?xml version="1.0" encoding="UTF-8"?>
<tns:order xmlns:tns="http://www.jaggorder.org/order" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.jaggorder.org/order order.xsd ">
<tns:product>tns:product</tns:product>
<tns:name>tns:name</tns:name>
<tns:description>tns:description</tns:description>
<tns:price>0</tns:price>
<tns:category>tns:category</tns:category>
</tns:order>