XSD validation Error: s4s-elt-must-match error

1.6k views Asked by At

Please help to resolve the below error for the XSD as i'm a newbie to xsd

Sample SOAP response XML

 <ACCOUNTDETAILS>
 <STATUS></STATUS>
 <RESPONSE></RESPONSE>
 <ACCOUNTID>
 <DETAILS>
 <NAME></NAME>
 <CATEGORY></CATEGORY>
 <LASTMODIFIED></LASTMODIFIED>
  </DETAILS>
  </ACCOUNTID>
  </ACCOUNTDETAILS>

XSD generated

<xsd:element name="AccountDetailsResponse">
  <xsd:element name="ACCOUNTDETAILS" type="account:Account">
     <xsd:complexType>
       <xsd:sequence>
         <xsd:element type="xsd:string" name="STATUS"/>
         <xsd:element type="xsd:string" name="RESPONSE"/>
         <xsd:element name="ACCOUNTID">
           <xsd:complexType>
             <xsd:sequence>
               <xsd:element name="DETAILS">
                 <xsd:complexType>
                   <xsd:sequence>
                     <xsd:element type="xsd:string" name="NAME"/>
                     <xsd:element type="xsd:string" name="CATEGORY"/>
                     <xsd:element type="xsd:string" name="LASTMODIFIED"/>
                   </xsd:sequence>
                 </xsd:complexType>
               </xsd:element>
             </xsd:sequence>
           </xsd:complexType>
         </xsd:element>
        </xsd:sequence>
      </xsd:complexType>
    </xsd:element>
  </xsd:element>

XSD ERROR:

s4s-elt-must-match.1: The content of 'AccountDetailsResponse' must match (annotation?, (simpleType | complexType)?, (unique | key | keyref)*)). A problem was found starting at: element.

Thanks in advance

1

There are 1 answers

0
Florent Georges On

Most likely you did not provided us with the entire input. From your schema, I would expect an element AccountDetailsResponse around the excerpt you posted.

As you figured out for the other elements, you cannot have an xs:element as a direct child of another xs:element. Most likely, using the same as you did for the other elements (an ordered sequence of children) would do what you want:

<xsd:element name="AccountDetailsResponse">
   <xsd:complexType>
      <xsd:sequence>
         <xsd:element name="ACCOUNTDETAILS" type="account:Account">
         ...

This will not work either, as you cannot have both a type attribute, and an embedded xs:complexType at the same time. So probably you will want to get rid of that one type attribute. So the following should work:

<xsd:element name="AccountDetailsResponse">
   <xsd:complexType>
      <xsd:sequence>
         <xsd:element name="ACCOUNTDETAILS">
         ...