<mapping>
  <class name="xxx.xx.xx.xx.xx.beans.ItemWrapper" 
extends="xx.xx.xx.xx.xx.xx.beans.Item">
<map-to xml="Item"/>
 </class>
</mapping>



发件人: Chiths Mohandas [mailto:[email protected]]
发送时间: 2011年3月14日 2:06
收件人: [email protected]
主题: [castor-user] Overide Class while Unmarshalling and Marshalling.....





I have a problem, which I could not find in the archive or browsing the net.
We are using Castor 0.95.

We manage and process our Request Payload information via xml schema and use 
Castor generated beans as our principal mode  data transfer and business 
objects.
In our latest release we need to support a very specific information of our 
customer.
<CatalogRequest>
<header>
      ...
</header>
<payload>
   <Item>
       <field1>
        ....
       <field10>
       <custom><!![CDATA[<customerData>......</customerData>]CDATA]</custom>
  </Item>


Since we can ill-afford to describe the customer specific information in our 
schema , we have the customer send the data as CDATA. as described above 
<custom>

We have specified the custom element as StringType .

Problem:
The approach we have decided is to Create a new class non castor say 
ItemWrapper extends Item (castor  generated).
I have created a ItemWrapperDescriptor which extends ItemDescriptor (castor 
generated).
When I marshal / unmarshal ItemWrapper independently I get the <Item> xml as 
described the schema.

However, When I unmarshal the CatalogRequest object, for the Item elementI need 
to generated the object ItemWrapper.
How can I do this? I need to do this because the ItemWrapper object has some 
methods which parses the CDATA during unmarshal and converts it back to CDATA 
eleement while marshalling.

So to Summarize,
Is there a way during unmarshall we can ask the Unmarshaller to unmarshal a 
specific element to an Extended class of a Castor generated Class.

I tried this via a mappng as listed below and with no success.
Please note that the class I need to overide during unmarshal is not the root 
element.

<mapping>
  <class name="xxx.xx.xx.xx.xx.beans.ItemWrapper" 
extends="xx.xx.xx.xx.xx.xx.beans.Item">
  </class>
 </mapping>

Any help will be deeply appreciated ..

regds,
Chiths

Reply via email to