Implement xmlbeans with inner Java objects

33 Views Asked by At

I have the following java Objects:

public class DataResponse
{
    int code;
    String description;
    DetailProfile detail;
    IntResponse profile;
}

public class DetailProfile
{
    String description;
}

public class IntResponse
{
    String name;
    UnitType type; /// this is enum
}

I tried to implement this xmlbeans configuration:

<xs:schema
   xmlns:xs="http://www.w3.org/2001/XMLSchema"
   xmlns:po="http://test.com/v1"
   targetNamespace="http://test.com/v1"
   elementFormDefault="qualified">

  <xs:element name="DataResponse">
    <xs:complexType>
      <xs:all>
        <xs:element name="code" type="xs:int"/>
        <xs:element name="description" type="xs:string"/>

        <xs:element name="DetailProfile">
          <xs:complexType>
            <xs:all>
              <xs:element name="description" type="xs:string"/>
            </xs:all>
          </xs:complexType>
        </xs:element>

        <xs:element name="IntResponse">
          <xs:complexType>
            <xs:all>
              <xs:element name="name" type="xs:string" />

              <xs:simpleType name="type">
                <xs:restriction base="xs:string">
                  <xs:enumeration value="one" />
                  <xs:enumeration value="sec" />
                  <xs:enumeration value="thur" />
                </xs:restriction>
              </xs:simpleType>
            </xs:all>
          </xs:complexType>
        </xs:element>
      </xs:all>
    </xs:complexType>
  </xs:element>

</xs:schema>

But I get error for enum: Invalid content was found starting with element '{"http://www.w3.org/2001/XMLSchema":simpleType}'. One of '{"http://www.w3.org/2001/XMLSchema":element}' is expected.

Do you know what is the proper way to implement inner Java objects with Enums using XML configuration?

0

There are 0 best solutions below