-----Original Message-----
From: Naresh Bhatia
Sent: Saturday, February 22, 2003 11:21 PM
To: [EMAIL PROTECTED]
Subject: [castor-dev] Instantiating extension types using XML mappingI am having trouble instantiating extension types using XML mapping. Castor is not able to instantiate extended types. Here's my schema:
<xsd:complexType name="MessageType" abstract="true">
</xsd:complexType><xsd:complexType name="CreateMeetingMessageType">
<xsd:complexContent>
<xsd:extension base="MessageType">
<xsd:sequence>
<xsd:element name="meeting" type="MeetingType"/>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
...Here's my mapping file:
<class name="Message">
<map-to xml="message" ns-uri="my-schema"/>
</class><class name="CreateMeetingMessage" extends="Message">
<map-to xml="message" ns-uri="my-schema"/>
<field name="meeting" type="Meeting">
<bind-xml name="meeting"/>
</field>
</class>
...Here's my XML instance:
<message
xmlns="my-schema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:type="CreateMeetingMessageType">
<meeting>
...
</meeting>
</message>When I try to unmarshall this instance using Castor, I get the following exception:
org.xml.sax.SAXException: unable to instantiate org.framework.message.Message;
java.lang.InstantiationException: org.framework.message.Message
at org.exolab.castor.xml.UnmarshalHandler.startElement(Unknown Source)
at org.exolab.castor.xml.util.DOMEventProducer.process(Unknown Source)
at org.exolab.castor.xml.util.DOMEventProducer.process(Unknown Source)
at org.exolab.castor.xml.util.DOMEventProducer.start(Unknown Source)
at org.exolab.castor.xml.Unmarshaller.unmarshal(Unknown Source)
at org.exolab.castor.xml.Unmarshaller.unmarshal(Unknown Source)
at Test.main(Client.java:81)I would appreciate any ideas to overcome this problem.
Thanks.
Naresh
Title: Message
Hope
this post did not get lost in the "weekend shuffle" :-). I am really stuck on
this problem. Could somebody please comment on whether this is expected to work
using XML mapping? It appears that Castor is getting confused by the two classes
that map to the same XML element, namely <message>, but in fact are
distinguished by their xsi:type attribute.
Thanks.
Naresh
- [castor-dev] Instantiating extension types using XML mapping Naresh Bhatia
- Naresh Bhatia
