2016-03-15 99 views
-1

我有一個非常簡單的XML文件和一個XML模式文件。我一直試圖根據模式驗證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:屬性'xsi:noNamespaceSchemaLocation'不允許出現在元素'StockDataSet'中。

[xml_validation_online] http://www.xmlvalidation.com/

謝謝!

回答

0

Omg,我找到了罪魁禍首。

StockDataSet的xmlns:XSI =「http://www.w3.org./2001

組織後

額外點引發的問題Embarrassig,花了幾個小時還是要謝謝你