users@jaxb.java.net

Re: Unmarshall and Marshalling does not produce the same XML

From: Herpertz, Francesca <francesca.herpertz_at_bearingpoint.com>
Date: Wed, 25 Mar 2015 16:57:32 +0000

Hi,

Thanks for all your help. The issue had ist origin in the XSD as one of you guys said.

The following construct will always result in an additional ns2: namespace:


<xs:complexType>

<xs:choice minOccurs="0" maxOccurs="unbounded">

<xs:annotation>

<xs:appinfo>

<jaxb:property name="types" />

</xs:appinfo>

</xs:annotation>

<xs:element name="a" type="vt:complexA" />

<xs:element name="b" type="vt:complexA" />

<xs:element name="c" type="vt:complexB" />

</xs:choice>

</xs:complexType>


Even if the unmarshal can handle this construct perfectly fine this will lead to the issue with the namespace in the marshaling . As soon as the "vt:complexA" complex type was copied, renamed and associated with the element "b" it worked with the standard mechanisms from JAXB and no ns2: namespace prefix was generated. The only real problem is now that I have to maintain both complex types in the XSD but this is a minor problem :).


When changing the XSD to this:


<xs:complexType>

<xs:choice minOccurs="0" maxOccurs="unbounded">

<xs:annotation>

<xs:appinfo>

<jaxb:property name="types" />

</xs:appinfo>

</xs:annotation>

<xs:element name="a" type="vt:complexA" />

<xs:element name="b" type="vt:complexB" />

<xs:element name="c" type="vt:complexC" />

</xs:choice>

</xs:complexType>


it just works out of the box.


Thanks people for your help. =)


Kind regards,

Francesca

________________________________
BearingPoint Software Solutions GmbH
Gesch?ftsf?hrer: J?rgen Lux, Thomas Sauer-Brab?nder, Dr. Robert Wagner
Sitz: Frankfurt am Main
Registergericht: Amtsgericht Frankfurt am Main HRB 81430

The information in this email is confidential and may be legally privileged. If you are not the intended recipient of this message, any review, disclosure, copying, distribution, retention, or any action taken or omitted to be taken in reliance on it is prohibited and may be unlawful. If you are not the intended recipient, please reply to or forward a copy of this message to the sender and delete the message, any attachments, and any copies thereof from your system.