我有一个非常简单的XML文件和一个XML模式文件。我一直试图根据模式验证XML文件无济于事。以下是详细信息;
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="StockDataSet">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="StockRecord" maxOccurs="unbounded">
<xsd:complexType>
<!--<xsd:sequence>-->
<xsd:element name="Item_Code" type="xsd:string" />
<xsd:element name="Item_Description" type="xsd:string" />
<xsd:element name="Current_Count" type="xsd:positiveInteger" />
<xsd:element name="On_Order">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="yes" />
<xsd:enumeration value="Yes" />
<xsd:enumeration value="YES" />
<xsd:enumeration value="no" />
<xsd:enumeration value="No" />
<xsd:enumeration value="NO" />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
XML:
<?xml version="1.0"?>
<StockDataSet xmlns:xsi="http://www.w3.org./2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="stockschema.xsd" >
<StockRecord>
<Item_Code>A0001</Item_Code>
<Item_Description>Horse on Wheels</Item_Description>
<Current_Count>5</Current_Count>
<On_Order>Yes</On_Order>
</StockRecord>
<StockRecord>
<Item_Code>A0002</Item_Code>
<Item_Description>Elephant on Wheels</Item_Description>
<Current_Count>2</Current_Count>
<On_Order>No</On_Order>
</StockRecord>
<StockRecord>
<Item_Code>A0003</Item_Code>
<Item_Description>Dog on Wheels</Item_Description>
<Current_Count>23</Current_Count>
<On_Order>Yes</On_Order>
</StockRecord>
</StockDataSet>
现在我使用了Apatan工作室,它给出了一个模糊的错误。我还使用了[xml_validation_online],错误是 cvc-complex-type.3.2.2:Attribute&#39; xsi:noNamespaceSchemaLocation&#39;不允许出现在元素&#39; StockDataSet&#39;中。 的
[xml_validation_online] http://www.xmlvalidation.com/
谢谢!
答案 0 :(得分:0)
Omg,我找到了罪魁祸首。
StockDataSet xmlns:xsi =“http://www.w3.org./2001
组织后的额外点造成问题。 Embarrassig,花了好几个小时!不管怎样,谢谢