users@jaxb.java.net

Re: Polymorphism and Code generation

From: Ingrid_Furnzel <ingrid_furnzel_at_gmx.de>
Date: Wed, 17 Dec 2008 04:47:42 -0800 (PST)

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.