2017-01-19 12 views
1

Может вы, ребята, помогите мне понять эту ошибку:cvc-complex-type.2.4.a: Недействительный контент был найден, начиная с элемента 'ab: games'. Один из «{„http://teste2.org“: игрок}», как ожидается,

cvc-complex-type.2.4.a: Invalid content was found starting with element 'ab:games'.
One of '{" http://teste2.org ":player}' is expected.

Почему игрок ожидается в играх? Ожидается, что игрок достигнет цели в соответствии с моей схемой.

Я использую XSDValidator.java

Мой XML:

<?xml version="1.0" encoding="UTF-8" ?> 
<ab:nationalTeam xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"             
       xmlns:ab="http://teste2.org" 
       xsi:schemaLocation="http://teste2.org PT.xsd"> 
<ab:player id="1"> 
    <ab:number>1</ab:number> 
    <ab:name>Eduardo</ab:name> 
</ab:player> 
<ab:player id="11"> 
    <ab:number>11</ab:number> 
    <ab:name>Eder</ab:name> 
</ab:player> 
<ab:player id="2"> 
    <ab:number>10</ab:number> 
    <ab:name>Vieirinha</ab:name> 
</ab:player> 
<ab:games> 
<ab:game> 
    <ab:adversary> 
     France 
    </ab:adversary> 
    <ab:goals > 
     <ab:player id="11" minute="109"/> 
    </ab:goals> 
</ab:game> 
</ab:games> 
</ab:nationalTeam> 

Моя схема:

<?xml version="1.0" encoding="UTF-8"?>  
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
      xmlns:ab="http://teste2.org" 
      targetNamespace="http://teste2.org" 
      elementFormDefault="qualified" 
      attributeFormDefault="unqualified"> 

     <xs:complexType name="gameType"> 
      <xs:sequence> 
       <xs:element name="adversary" type="xs:string"/> 
       <xs:element name="goals" type="ab:goalsType"/> 
      </xs:sequence> 
     </xs:complexType> 

     <xs:complexType name="goalsType"> 
      <xs:sequence> 
       <xs:element ref="ab:player"/> 
      </xs:sequence> 
     </xs:complexType> 

     <xs:element name="games"> 
      <xs:complexType> 
       <xs:sequence> 
        <xs:element name="game" type="ab:gameType"/> 
       </xs:sequence> 
      </xs:complexType> 
     </xs:element> 

     <xs:element name="player"> 
      <xs:complexType> 
       <xs:sequence> 
       <xs:element name="number" type="xs:integer" minOccurs="0" maxOccurs="1"/> 
       <xs:element name="name" type="xs:string" minOccurs="0" maxOccurs="1"/> 
      </xs:sequence> 
      <xs:attribute name="id"> 
       <xs:simpleType> 
       <xs:restriction base="xs:integer"> 
        <xs:minInclusive value="1"/> 
       </xs:restriction> 
       </xs:simpleType> 
      </xs:attribute> 
      <xs:attribute name="minute" type="xs:string" use="optional"/> 
      </xs:complexType> 
     </xs:element> 

     <xs:element name="nationalTeam"> 
      <xs:complexType> 
        <xs:sequence> 
        <xs:element ref="ab:player" minOccurs="22" maxOccurs="25"/> 
        <xs:element ref="ab:games"/> 
        </xs:sequence> 
      </xs:complexType> 
      <xs:key name="pk_id"> 
       <xs:selector xpath="ab:nationalTeam/ab:player"/> 
       <xs:field xpath="@id"/> 
      </xs:key> 
      <xs:keyref name="fk_id" refer="ab:pk_id"> 
       <xs:selector xpath="ab:nationalTeam/ab:games/ab:game/ab:goals/ab:player"/> 
       <xs:field xpath="@id"/> 
      </xs:keyref> 
     </xs:element> 

</xs:schema> 

ответ

1

XSD ясно говорит о том, что nationalTeam должны быть между 22 и 25 игроков, а затем точно 1 games элемент.

В вашем файле XML есть только 3 игрока.

+0

Хорошо, что было антиклиматическим. Теперь мне неловко спрашивать об этом. Спасибо, и я прошу прощения за эту ошибку. – Greggz