Loïc,
                My answer is below.  Hopefully it is pretty accurate.
Castor team,
                Can someone copy this to the website(after correcting possibly)?  I know this would have helped me tremendously from the beginning if I knew this up front.

Example XSD.....
<xsd:complexType name="something">
</xsd:complexType>
<xsd:complexType name="someOtherType">
</xsd:complexType>

<xsd:element name="TryMe" type="something">

<xsd:element name="Again">
    <xsd:complexType>
        <xsd:sequence>
            <element name="lookMa" type="someOtherType"/>
            <element name="lookMa2" type="someOtherType"/>
        </xsd:sequence>
    <xsd:complexType>
</xsd:element>

Element
----------------------------
would generate abstract class Something and SomeOtherType
would generate a TryMe class as subclass of Something
would generate a LookMa and LookMa2 class as subclasses of SomeOtherType
would generate a concrete Again class
Disadvantage here is the explosion of objects you can have.  Notice the LookMa and LookMa2 are generated even though there is only one type.  Also, you will get more naming conflicts(if someone else has an element called LookMa, you will have to use the binding file to map it so there is not a naming conflict)

Type
-----------------------------
would generate a concrete class Something and SomeOtherType and Again
Notice TryMe, LookMa, and LookMa2 are no longer generated
Disadvantage here is when you marshall the complexType, you need to know what element to marshal it as.
Example, say there was another element <xsd:element name="TryMe2" type="something"> and you have a "something" object, do you marshal it as TryMe2 or TryMe?
I am thinking about adding a feild in the generated code called element so the xml element can be retrieved by the unmarshaller.  The element could be set at construction time or a set method.  

Dean


Loïc Bertholet wrote:
hi,
 
I don't really understand the differences between these 2 ways of generating sources with the sourceGenerator.
What is considered as a "top-level type" and a "top-level complexType" ?
 
A simple example of a XmlSchema which obtains 2 differents source code after these 2 kind of generation would be great !
thanks,
 
Loïc

Reply via email to