users@jaxb.java.net

Re: JAXB Model Group Binding

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Tue, 22 Mar 2005 15:29:36 -0800

Carsten Cibura wrote:
>
> 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?

If you would file a test case for this as an issue, that would be great.



-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com