Title: XSD complexTypes and source generation.

Hi,

perhaps I am missing something, haven't read the manual enough, am overlooking something, but I have a question about the source generation and the use of complex types in relation to the code generated. In short, why doesn't castor use the complex type for input and output parameters, but instead does it use generated classes named after the element name.

Considering the following example:

<xs:complexType name="Person">
        <xs:sequence>
                <xs:element name="Gender" type="xs:string"/>
                <xs:element name="Age" type="xs:int"/>
                <xs:element name="Name" type="xs:string"/>
        </xs:sequence>
</xs:complexType>

<xs:complexType name="HappyFamily">
        <xs:sequence>
                <xs:element name="Mom" type="Person">
                <xs:element name="Dad" type="Person">
                <xs:element name="Child" type="Person" minOccurs="0" maxOccurs="unbounded">
                <!-- hardly realistic :-) -->
        </xs:sequence>
</xs:complexType>


Why does castor generate a class for each element of the HappyFamily complex type?
Why doesn't it only generate classes for each used complex type?
Why does it generate accessors that use the element name as input and output classes instead of the element type?

In other words, why does castor generate the classes Mom, Dad, Child (extending Person).
And why does castor generate code that require those classes instead of the type they are?

In java:

HappyFamily family = new HappyFamily();
family.setMom(new Mom());

Why can't this be:

HappyFamily family = new HappyFamily();
family.setMom(new Person());

Thanks,

Rutger Lubbers

Reply via email to