users@jaxb.java.net

Re: Polymorphism and Code generation

From: Ingrid_Furnzel <ingrid_furnzel_at_gmx.de>
Date: Thu, 18 Dec 2008 00:03:34 -0800 (PST)

I fixed my mistake. Inside the xsd was a mistake. You are absolutely rigth -
the types were not different.

At the moment I still have the problem mentioned above.

Thanks for replies
Ingrid


Wolfgang Laun-2 wrote:
>
> Are all the types in <d> or <e> or <c> or ... different?
>
> If a content tree element is <JAXBElement<X>>, then the schema compiler
> has determined that the type alone is not sufficient to identify the
> object.
> A JAXBElement object also contains the XML tag.
>
> The full, current XML for type X would help to help you :-)
>
> -W
>
> On Wed, Dec 17, 2008 at 1:47 PM, Ingrid_Furnzel
> <ingrid_furnzel_at_gmx.de>wrote:
>
>>
>> Thank you for your fast answer. Now xjc is creating a class X with the
>> following list:
>> List<JAXBElement><Super>> dOrEOrC;
>>
>> What did i wrong and what does this mean?
>>
>> Regards
>> Ingrid
>>
>>
>>
>> Ingrid_Furnzel wrote:
>> >
>> > Hi,
>> >
>> > I have a problem with code generation (xjc) and inheritance.
>> >
>> > The following xml structure exists:
>> >
>> > <x>
>> > <d>some content</d>
>> > <e>some content</e>
>> > <c>some content</c>
>> > </x>
>> >
>> > d, e and c shall have the same super class
>> >
>> > My xsd looks like this:
>> >
>> > <xsd:complexType name="x">
>> > <xsd:sequence>
>> > <xsd:element name="d" type="d" maxOccurs="unbounded"
>> minOccurs="0"/>
>> > <xsd:element name="e" type="e" maxOccurs="unbounded"
>> minOccurs="0"/>
>> > <xsd:element name="c" type="c" maxOccurs="unbounded"
>> minOccurs="0"/>
>> > </xsd:sequence>
>> > </xsd:complexType>
>> >
>> > <xsd:complexType abstract="true" name="super">
>> > </xsd:complexType>
>> >
>> > <xsd:complexType name="d">
>> > <xsd:complexContent>
>> > <xsd:extension base="super">
>> > SOME CONTENT
>> > </xsd:extension>
>> > </xsd:complexContent>
>> > </xsd:complexType>
>> >
>> > <xsd:complexType name="e">
>> > <xsd:complexContent>
>> > <xsd:extension base="super">
>> > SOME CONTENT
>> > </xsd:extension>
>> > </xsd:complexContent>
>> > </xsd:complexType>
>> >
>> > <xsd:complexType name="c">
>> > <xsd:complexContent>
>> > <xsd:extension base="super">
>> > SOME CONTENT
>> > </xsd:extension>
>> > </xsd:complexContent>
>> > </xsd:complexType>
>> >
>> >
>> > xjc creates five classes (D, E, C, X and Super). Unfortunately, X has
>> > three lists: List<D>d; List<E>e and List<C> c;
>> >
>> > That is not what I want. I would prefer having only one list
>> List<Super>
>> > super;
>> >
>> > In order to do this I could modify the generated code with annotations:
>> > @XmlELements({
>> > @XmlElement(name="d", type=D.class),
>> > @XmlElement(name="e", type=E.class),
>> > @XmlElement(name="c", type=C.class)
>> > })
>> > List<Super> super;
>> >
>> > How must I write the xsd or the binding file to achieve this behaviour
>> > with code generation? The goal ist to have only one list although I
>> have
>> > three different XML tags (d, e, c).
>> >
>> >
>> > Regards
>> > Ingrid
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Polymorphism-and-Code-generation-tp21051962p21052540.html
>> Sent from the java.net - jaxb users mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
>> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>>
>>
>
>

-- 
View this message in context: http://www.nabble.com/Polymorphism-and-Code-generation-tp21051962p21068499.html
Sent from the java.net - jaxb users mailing list archive at Nabble.com.