users@jaxb.java.net

Re: need some explanation on jaxb generated code

From: Praseeda Sathaye <praseeda_at_yahoo.com>
Date: Thu, 25 Sep 2008 14:12:39 -0700 (PDT)

This issue was due to the fact that the XML that I was passing to the UnMarshaller did not had namespace. So the next question is is there any way I can add namespace while unmarshalling.

Thanks,
Praseeda.



----- Original Message ----
From: Wolfgang Laun <wolfgang.laun_at_gmail.com>
To: users_at_jaxb.dev.java.net
Sent: Thursday, September 25, 2008 12:08:58 AM
Subject: Re: need some explanation on jaxb generated code

Sorry, I didn't look closely enough. The Java code is not due to mixed="true".
(In that case, the code would be similar, with a List<?> content, but that
would have an annotation XmlMixed.)

The reason that would make JAXB generate the Java class as shown could be
the duplication of one of the child elements of the complex type - same tag, same type.

-WL


On 9/24/08, Wolfgang Laun <wolfgang.laun_at_gmail.com> wrote:
You don't, by any chance, have an attribute mixed="true" in the <xs:complexType name="SaisieActeMessage">?

If that's so, then you have XML content that cannot be mapped to a
simple set of unordered class fields, plus one for content. Processors
of your input action message expect to obtain the sub-elements
and the chunks (!) of content one by one, in the order of their
appearance.

Cheers
Wolfgang


On 9/24/08, nicolas de loof <nicolas_at_apache.org> wrote:
Hello, I'm an apache CXF user, and I get a strange behaviour with JAXB binding. CXF user list forwarded me here for this :

My (WSDL) schema defines a complextype :

   <xs:complexType name="SaisieActeMessage">
     <xs:sequence>
         <xs:element name="adressefacturation" type="tns:Adresse"/>
         <xs:element name="adresselivraison" type="tns:Adresse"/>

         <xs:element name="contact" type="tns:MoyenDeContact"/>

[~10 more elements] ...

I
expected the generated Java class to define attributes
"adressefacturation", "adresselivraison", "contact" ..., as it does for
many other types in my WSDL, but I get :

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "SaisieActeMessage", propOrder = {
    "content"
})
public class SaisieActeMessage {

    @XmlElementRefs({
        @XmlElementRef(name = "adresselivraison", namespace = "http://foo", type = JAXBElement.class),

        @XmlElementRef(name = "adresseFacturation", namespace = "http://w foo", type = JAXBElement.class),

        @XmlElementRef(name = "contact", namespace = "http://foo", type = JAXBElement.class),
..... })

    protected List<JAXBElement<?>> content;


Is this REALLY what is expected ? Is there no way to have something more developer-compliant ?