users@jaxb.java.net

Re: More JAXBElement

From: Brian Pontarelli <brian_at_pontarelli.com>
Date: Mon, 14 Feb 2005 12:58:20 -0600

Yeah, I'm getting a JAXBElement<SomeRequest> returned from the
unmarshaller rather than a SomeRequest. I just included the
ObjectFactory code to show you what is being generated. The SomeRequest
and Request classes look like normal JavaBeans and have the correct
annotations. Just looks like the unmarshaller is doing something strange.

Kohsuke Kawaguchi wrote:

> Brian Pontarelli wrote:
>
>> I'm having another JAXBElement problem with JAXB 2.0. I'm wondering
>> if this is caused by the same bug that I emailed out before. This
>> time it looks like the ObjectFactory is returning JAXBElement
>> whenever a complex type is inherited. Here's my schema:
>
>
> The ObjectFactory generates createSomeRequest for "someRequest" as a
> complex type, and then it generates another createSomeRequest for
> "someRequest" as an element.
>
> I agree that it might not be very intuitive, but I'm not sure what you
> consider as a bug. Do you get some strange object when you unmarshal?
> Is that it?
>
> If you could elaborate on this some more, that would be very helpful.
>
>>
>> base-request.xsd
>> ----------------
>> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
>> elementFormDefault="qualified">
>> <xs:complexType name="request" mixed="false"/>
>> </xs:schema>
>>
>>
>> some-request.xsd
>> ----------------
>> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
>> elementFormDefault="qualified">
>> <xs:include schemaLocation="base-request-1.0.xsd"/>
>> <xs:element name="someRequest">
>> <xs:complexType mixed="false">
>> <xs:complexContent>
>> <xs:extension base="request">
>> <xs:sequence>
>> <xs:element name="foo" type="xs:string"/>
>> </xs:sequence>
>> </xs:extension>
>> </xs:complexContent>
>> </xs:complexType>
>> </xs:element>
>> </xs:schema>
>>
>> I also thought at first it might be because my base type was empty. I
>> tried adding an element to the base type and the same thing occurred.
>> The ObjectFactory methods look like this:
>>
>> /**
>> * Create an instance of {_at_link com.inversoft.SomeRequest}
>> *
>> */
>> public com.inversoft.SomeRequest createSomeRequest() {
>> return new com.inversoft.SomeRequest();
>> }
>>
>> /**
>> * Create an instance of {_at_link
>> javax.xml.bind.JAXBElement<com.inversoft.SomeRequest>}
>> *
>> */
>> @javax.xml.bind.annotation.XmlElementDecl(name = "someRequest",
>> namespace = "")
>> public javax.xml.bind.JAXBElement<com.inversoft.SomeRequest>
>> createSomeRequest(com.inversoft.SomeRequest value) {
>> return new
>> javax.xml.bind.JAXBElement<com.inversoft.SomeRequest>(_SomeRequest_QNAME,
>> ((java.lang.Class) com.inversoft.SomeRequest.class), null, value);
>> }
>>
>> Let me know if it is in fact a bug and if it is, if there are any
>> work-arounds until the next release is out.
>>
>> Thanks,
>> - brian
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
>> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>>
>>
>
>