2013-04-15 65 views
0

我一直在寻找通过类似的问题寻找答案来解决我的问题。但是,无论我如何更改命名空间,我总是会遇到同样的问题。任何人有什么想法是错的?XSD验证错误:“cvc-elt.1.a:找不到元素'school'的声明。”

这里是我的XML文件

<?xml version="1.0" encoding="UTF-8"?> 

<school 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns="http://www.somesite.org" 
xsi:schemaLocation="http://www.somesite.org/schemas Schema.xsd"> 
    <student id ="1000"> 
     <phone> 312-453-3495 </phone> 
     <name> Hazael Mladen </name> 
     <email> [email protected] </email> 
     <borrowed amount = "2"> 
      <book> 
       <isbn> 184356028-3 </isbn> 
       <date> 10-12-2012 </date> 
       <return> 10-14-2013 </return> 
      </book> 
      <book> 
       <isbn> 184357328-3 </isbn> 
       <date> 10-12-2012 </date> 
       <return> 10-14-2013 </return> 
      </book> 
     </borrowed> 
    </student> 

    <student id = "1001"> 
     <phone> 434-213-5434 </phone> 
     <name> Pankratios Kenyon </name> 
     <email> [email protected] </email> 
     <borrowed amount = "2"> 
      <book> 
       <isbn> 184356028-6 </isbn> 
       <date> 10-12-2012 </date> 
       <return> 10-14-2013 </return> 
      </book> 
      <book> 
       <isbn> 184356548-7 </isbn> 
       <date> 10-12-2012 </date> 
       <return> 10-14-2013 </return> 
      </book> 
     </borrowed> 
    </student> 

    <student id = "1002"> 
     <phone> 432-419-3645 </phone> 
     <name> Mike Abhay </name> 
     <email> [email protected] </email> 
     <borrowed amount = "1"> 
      <book> 
       <isbn> 184356028-3 </isbn> 
       <date> 10-12-2012 </date> 
       <return> 10-14-2013 </return> 
      </book> 
     </borrowed> 
    </student> 

    <student id = "1003"> 
     <phone> 945-325-4586 </phone> 
     <name> Genghis Hollis </name> 
     <email> [email protected] </email> 
     <borrowed amount = "2"> 
      <book> 
       <isbn> 184356028-3 </isbn> 
       <date> 10-12-2012 </date> 
       <return> 10-14-2013 </return> 
      </book> 
      <book> 
       <isbn> 184356028-3 </isbn> 
       <date> 10-12-2012 </date> 
       <return> 10-14-2013 </return> 
      </book> 
     </borrowed> 
    </student> 

    <student id = "1004"> 
     <studentID> 1000 </studentID> 
     <phone> 348-628-9546 </phone> 
     <name> Jengo Giuliano </name> 
     <email> [email protected] </email> 
     <borrowed amount = "3"> 
      <book> 
       <isbn> 184356028-3 </isbn> 
       <date> 10-12-2012 </date> 
       <return> 10-14-2013 </return> 
      </book> 
      <book> 
       <isbn> 184356028-3 </isbn> 
       <date> 10-12-2012 </date> 
       <return> 10-14-2013 </return> 
      </book> 
      <book> 
       <isbn> 184356028-3 </isbn> 
       <date> 10-12-2012 </date> 
       <return> 10-14-2013 </return> 
      </book> 
     </borrowed> 
    </student> 
</school> 

,这里是我的XSD架构文件:

<?xml version="1.0" encoding="UTF-8"?> 

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

    <xs:element name="school"> 
     <xs:complexType> 
      <xs:sequence> 
       <xs:element name="student" minOccurs="1"> 
        <xs:complexType> 
         <xs:sequence> 
          <xs:element name="phone" type="xs:string"/> 
          <xs:element name="name" type="xs:string"/> 
          <xs:element name="email" type="xs:string"/> 
          <xs:element name="borrowed"> 
           <xs:complexType> 
            <xs:sequence> 
             <xs:element name="book"> 
              <xs:complexType> 
               <xs:sequence> 
                <xs:element name="isbn" type="xs:string"/> 
                <xs:element name="date" type="xs:date"/> 
                <xs:element name="return" type="xs:date"/> 
               </xs:sequence> 
              </xs:complexType> 
             </xs:element> 
            </xs:sequence> 
            <xs:attribute name="amount" type="xs:integer" default="0"/> 
           </xs:complexType> 
          </xs:element> 
         </xs:sequence> 
         <xs:attribute name="id" type="xs:integer" use="required"/> 
        </xs:complexType> 
       </xs:element> 
      </xs:sequence> 
     </xs:complexType> 
    </xs:element> 

</xs:schema> 

回答

1
xmlns="http://www.somesite.org" 
xsi:schemaLocation="http://www.somesite.org/schemas Schema.xsd" 

我认为,第一行应该是:

xmlns="http://www.somesite.org/schemas" 
相关问题