users@jaxb.java.net

serialization issue with xs:choice?

From: <Corbett.Klempay_at_trilogy.com>
Date: Wed, 17 Mar 2004 11:53:14 -0600

I have an odd scenario where only the leaf children of an element are
being serialized. The relevant fragment of my schema looks like this:


<xs:element name="groupedFamilies">
        <xs:complexType>
                <xs:sequence>
                        <xs:choice minOccurs="1" maxOccurs="unbounded">
                                <xs:element ref="family"/>
                                <xs:element name="familyGroup">
                                        <xs:complexType>
                                                <xs:sequence>
                                                        <xs:element
ref="family" minOccurs="1" maxOccurs="unbounded"/>
                                                </xs:sequencE>
                                        <xs:complexType>
                                </xs:element>
                        </xs:choice>
                </xs:sequence>
        </xs:complexType>
</xs:element>

This should allow for instances like:

<groupedFamilies>
        <family>
        <family>
        <family>
        <family>
        <familyGroup>
                <family>
                <family>
        </familyGroup>
        <familyGroup>
                <family>
        </familyGroup>
</groupedFamilies>

The test scenario I have is exactly the above, actually: 4 toplevel,
standalone <family> elements, along with 2 familyGroups, one with 2
families, one with 1. However, when I populate the wrapper tree and
serialize this bugger, I end up with this:

<groupedFamilies>
        <family>
        <family>
        <family>
        <family>
        <family>
        <family>
        <family>
</groupedFamlies>

All 7 families appear on the same level...the 3 families nested inside the
two familyGroup elements appear alongside the top level, and the
familyGroup elements are nowhere to be be found.

Stepping through my code that populates this in the debugger, I have
verified that the List gotten off of the groupedFamilies element contains
4 FamilyTypeImpl classes and 2 FamilyGroupTypeImpl classes (and also that
each of those two FamilyGroupTypeImpls contained the right FamilyTypeImpl
classes)...yet it still serializes just the leaves (the 7 family
elements).

Does this ring a bell for anyone? I am using 1.0.2.

---
Corbett J. Klempay
Trilogy
512.874.5176 (W) | 512.750.1372 (C)
corbett.klempay_at_trilogy.com