users@jaxb.java.net

JAXB Model Group Binding

From: Carsten Cibura <ccibura_at_ipsi.fhg.de>
Date: Fri, 18 Mar 2005 15:23:58 +0100

Hello,

I am facing a problem using JAXB Model Group Binding. Consider the
following schema fragment:

<xsd:element name="Container">
        <xsd:complexType>
                <xsd:choice>
                        <xsd:element ref="Reference"/>
                        <xsd:sequence>
                                <xsd:element ref="Container" minOccurs="0"
                                        maxOccurs="unbounded"/>
                                <xsd:element ref="Item" minOccurs="0"
                                        maxOccurs="unbounded"/>
                        </xsd:sequence>
                </xsd:choice>
        </xsd:complexType>
</xsd:element>

xjc creates an inner class of ContainerType called
ReferenceOrContainerAndItem, which sounds great.
Additionally it creates accessor methods getContainer() and getItem(),
which return Lists.
But when I try to add() a Container and an Item subsequently to their
respective Lists
(as the XML schema definition would allow), I get a StackOverflowError,
because
of an infinite recursion, when the Container- and the Item-List are trying
to clear() each other
respectively.
But while adding a Reference SHOULD clear the Container- and Item-List,
these two should be able
to co-exist peacefully. This seems to be an implementation fault. Is there
anything I can do,
besides adapting the auto-generated code manually?

Thanks for your quick help,
Carsten Cibura