2

I need your help :'( I have a problem with XSD validation, It returns error with Unexpected elements. But i want to allow and skip any unexpected elements. I try to use <xs:any>but its not allowed under <xs:all> and <xs:element ref doesn't work, I have no idea how to fix it :

<xs:complexType>
        <xs:all>
            <xs:any processContents="lax" maxOccurs="unbounded" minOccurs="0" />
            <xs:element name="id" type="xs:integer" />
            <xs:element name="lastname" type="xs:string" />
            <xs:element name="firstname" type="xs:string" />
            <xs:element ref="adress" />
            <xs:element ref="phone" />
        </xs:all>

It returns error for example when I got unexpected elements "gender". DO you know which tag can be help ? or any solutions. Thanks in advance guys.

Amy Mai
  • 21
  • 3

1 Answers1

1

Change <xs:all> to <xs:sequence> as specified in http://www.w3schools.com/schema/schema_complex_any.asp it will work.

<xs:element name="person">
  <xs:complexType>
    <xs:sequence>
      <xs:element name="firstname" type="xs:string"/>
      <xs:element name="lastname" type="xs:string"/>
      <xs:any minOccurs="0"/>
    </xs:sequence>
  </xs:complexType>
</xs:element> 
  • Thank you so much @Surendra Kongurootu :) But the point is I dont want to use . – Amy Mai Sep 16 '13 at 02:32
  • Sorry, to post after such a long time. That does not comply if the elements inside "xs:sequence" are in a different order than the one stated. Is there any way to accomplish both things? (no particular order in addition to one or more unexpected elements in the list) – Nicolasllk Jan 16 '18 at 18:24