cvc-complex-type.2.4.a: invalid content was found starting with element 'ProcessDesc'. One of ProcessName expected

The XML Sehema code

<xs:complexType name="Process">
  <xs:sequence>
    <xs:element name="ProcessId" type="xs:int" />
    <xs:element name="ProcessName" type="xs:string" />
    <xs:element name="ProcessDesc" type="xs:string" minOccurs="0" />
  </xs:sequence>
</xs:complexType>

describes some XML which ought to look like

<proc> <!-- of type Process -->
  <ProcessId>123</ProcessId>
  <ProcessName>procA</ProcessName>
  <ProcessDesc>A funny process</ProcessDesc> <!-- this could be omitted -->
<proc>

But your XML data looks like

<proc> <!-- of type Process -->
  <ProcessId>123</ProcessId>
  <ProcessDesc>A funny process</ProcessDesc>
  <!-- ... don't know what follows -->

If you don't care about the order of Id, Name, Desc you'll have to change the XML schema. Otherwise you'll have to fix the XML (which is easier).

If you think that "any order of elements" is a good idea, use:

<xs:complexType name="Process">
  <xs:all>
    <xs:element name="ProcessId" type="xs:int" />
    <xs:element name="ProcessName" type="xs:string" />
    <xs:element name="ProcessDesc" type="xs:string" minOccurs="0" />
  </xs:all>
</xs:complexType>

These kind of erors are due to one of the following reason


Element name is mistyped.

Element not described in schema is trying to be used.

Elements are in incorrect order.

Namespace definitions declared either in the root tag or a parent element don't match with the prefix (or no prefix) used in the element.

Java object has a null field required in xsd



If you use a sequence you must keep the order of each element

Definition and Usage The sequence element specifies that the child elements must appear in a sequence. Each child element can occur from 0 to any number of times.

see here

Tags:

Xml

Xsd

Schema

Jaxb