2013-10-11 18 views
0

我收到以下錯誤試圖驗證XML schema-S4S-ELT-必match.1:錯誤XML模式

16: 24 s4s-elt-must-match.1: The content of 'member' must match (annotation?, (simpleType | complexType)?, (unique | key | keyref)*)). A problem was found starting at: complextype. 
31: 21 s4s-elt-must-match.1: The content of 'intake' must match (annotation?, (simpleType | complexType)?, (unique | key | keyref)*)). A problem was found starting at: complextype. 

下面是schema-

<?xml version="1.0"?> 

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
targetNamespace="http://www.w3schools.com" 
xmlns="http://www.w3schools.com" 
elementFormDefault="qualified"> 

<xs:element name="record"> 
    <xs:complexType> 
     <xs:sequence> 
      <xs:element name="id" minOccurs="1" maxOccurs="1"> 
       <xs:complexType> 
        <xs:sequence> 
         <xs:element name="hof" type="xs:string" minOccurs="1" maxOccurs="1"/> 
         <xs:element name="member" minOccurs="1" maxOccurs="unbounded"> 
          <xs:complextype> 
           <xs:all> 
            <xs:element name="name" type="xs:string"/> 
            <xs:element name="age" type="xs:nonNegativeInteger"/> 
            <xs:element name="sex" type="xs:string"/> 
            <xs:element name="occupation" type="xs:string" minOccurs="0"/> 
            <xs:element name="pregnant" type="xs:boolean" minOccurs="0"/> 
            <xs:element name="lactating" type="xs:boolean" minOccurs="0"/> 
           </xs:all> 
          </xs:complextype> 
         </xs:element> 
        </xs:sequence> 
       </xs:complexType> 
      </xs:element> 
      <xs:element name="intake" minOccurs="1" maxOccurs="1"> 
       <xs:complextype> 
        <xs:sequence> 
         <xs:element name="food" minOccurs="0" maxOccurs="unbounded"> 
          <xs:complextype> 
           <xs:sequence> 
            <xs:element name="name" type="xs:string" minOccurs="1" maxOccurs="1"/> 
            <xs:element name="amount" type="xs:decimal" minInclusive="0" minOccurs="1" maxOccurs="1"/> 
           </xs:sequence> 
          </xs:complextype> 
         </xs:element> 
        </xs:sequence> 
       </xs:complextype> 
      </xs:element> 
     </xs:sequence> 
    </xs:complexType> 
</xs:element> 

</xs:schema> 

這是相應的XML文件 -

<?xml version="1.0" encoding="UTF-8" standalone="no"?> 
<record xmlns="http://www.w3schools.com" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://www.w3schools.com record.xsd"> 
    <id> 
     <hof>ABC</hof> 
     <member> 
      <name>ABC</name> 
      <age>35</age> 
      <sex>Male</sex> 
      <occupation>Manual Laboror</occupation> 
     </member> 
     <member> 
      <name>DEF</name> 
      <age>30</age> 
      <sex>Female</sex> 
      <occupation>House Wife</occupation> 
      <pregnant>no</pregnant> 
      <lactating>no</lactating> 
     </member> 
     <member> 
      <name>ghi</name> 
      <age>2</age> 
      <sex>Female</sex> 
     </member> 
    </id> 
    <intake> 
     <food> 
      <name>rice</name> 
      <amount>800</amount> 
     </food> 
     <food> 
      <name>dal</name> 
      <amount>200</amount> 
     </food> 
    </intake> 
</record> 

我已經嘗試提供的解決方案here但could'nt得到它的工作。

回答

0

問題出在您的模式文檔中。 XML是大小寫敏感的,所以

<xs:complextype> 

所有出現應該是

<xs:complexType> 

用大寫字母「T」(且同樣匹配的結束標記)。