I got problems during deserialization of my object model, which has a couple abstract classes. I don't know if my model is not suitable for xml or if it is a castor problem.


I defined an object type, which consists of some "LightSources":
<xsd:complexType name="Scene">
<xsd:sequence>
<xsd:element name="lightSources" type="my:LightSource" maxOccurs="unbounded"/>
..


These "LightSources" have an abstract base class:
<xsd:complexType name="LightSource" abstract="true">
<xsd:sequence>    
<xsd:element name="color" type="my:color" use="required"/>
..

There are a few concrete sub-classes like this one:
<xsd:complexType name="PointLightSource">
<xsd:complexContent>
<xsd:extension base="my:LightSource">
<xsd:sequence>    
<xsd:element name="position" type="my:Point" use="required"/>
..


1) When creating the sources with the SourceGenerator the resulting classdescriptor for "Scene" has compile errors, because the XMLFileHandler defines a method which tries to instanciate the abstract "LightSource":
public java.lang.Object newInstance( java.lang.Object parent ) {
return new my.LightSource();
}


2) Even when the base class isn't abstract, the deserialization does not work, because the XMLFieldHandler returns a new instance of the base class. Of cource this base class cannot be used to deserialize a sub-class of e.g. "PointLightSource", because of the missing element "position":

<scene ...>
<lightsource xsi:type="my:PointLightSource">
<color>...</color>
<position>...</position>
..

Didn't I get the point of abstract schema types? What am I doing wrong? Or is this maybe a known castor problem?


Any help is appreciated, Torsten



----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-user

Reply via email to