XML : Get rid of JAXBElement from jaxb-generated code?

I have an xsd from which I am generating some java code:

  <xs:element name="full-account-v2" >    <xs:complexType>      <xs:sequence>          <xs:element name="ban" type="xs:string" />          <xs:element name="status" type="xs:int" />      </xs:sequence>    </xs:complexType>  </xs:element>    

This has been working ok and gives me a generated class called FullAccountV2.

I want to use the same complex type elsewhere, so I thought I would create a named complex type in the xsd file, and refer to it like this:

  <xs:element name="full-account-v2" type="fullAccountV2Type"/>    

The complex type is defined as follows:

  <xs:complexType name="fullAccountV2Type">      <xs:sequence>          <xs:element name="ban" type="xs:string" />          <xs:element name="status" type="xs:int" />      </xs:sequence>  </xs:complexType>    

Now suddenly the unmarshaller stops working. The following xml was unmarshalling just fine to a FullAccountV2:

  <er-response id="100058" version="2">    <payload>     <full-account-v2>      <ban>BAN_P146058461158163004</ban>       <status>401</status>     </full-account-v2>    </payload>  </er-response>    

But now that class no longer appears, and the xml is unmarshalled by jaxb to a JAXBElement with Qname full-account-v2 and declaredType FullAccountV2Type.

ErResponse and Payload are defined elsewhere as:

  <xs:complexType name="payloadType">      <xs:sequence>          <xs:any processContents="lax" minOccurs="0" />      </xs:sequence>  </xs:complexType>    

I tried defining the type in a separate xml file to the element declaration, but got the same result.

How can such a simple refactor have caused me 8 hours of struggle? What am I doing wrong?

No comments:

Post a Comment