ok hear me out on this one.

class A{
 String field1;
 String field2;
}
class B{
 String field2;
 String field3;
}

class DumpEverything{
 String field1,field2,field3;
} 

You can probably map class DumpEverything with ur
'<bind-xml name="Contract"/>'

And then pick a decision field say field3
if(field3==null)
 A a = BeanMapperUtil.getClassA(DumpEverything de);
else 
 B b = BeanMapperUtil.getClassA(DumpEverything de);

A pretty silly solution, but like Keith pointed out u
most probably dont have a valid schema for ur xml
instance.
 

--- Keith Visco <[EMAIL PROTECTED]> wrote:

> 
> Hi David,
> 
> How do you distinguish between whether something is
> a Contract or a 
> Payment if they both use the Contract element name?
> 
> Castor basically follows the rules set forth in XML
> Schema, which 
> doesn't allow two sibling elements to have the same
> name and different 
> types. Basically if you have to look at the
> child-elements to determine 
> the type it's not going to work well. Castor
> determines the type before 
> examining the child elements.
> 
> --Keith
> 
> [EMAIL PROTECTED] wrote:
> > Hi,
> > 
> > I have a Response POJO that has two attributes:
> contracts and payments. The
> > XML message I receive from SOAP for the
> <Response/> element can have only
> > one sub-element whether contract or payment,
> cannot be both at the same
> > time. Castor gives error because I have two same
> bind-xml element names
> > (contract and payment have the same element name
> <Contract/>). How do you
> > work around this issue?
> > 
> > <Response>
> >   <Contract primaryKey="">
> >   </Contract>
> > </Response>
> > 
> > <class name="com.domain.function.Response">
> >  <field name="_contracts"
> type="com.domain.function.Contract" collection=
> > "arraylist" set-method="setContracts"
> get-method="getContracts">
> >       <bind-xml name="Contract"/>
> >  </field>
> >  <field name="_payments"
> type="com.domain.function.Payment" collection=
> > "arraylist" set-method="setPayments"
> get-method="getPayments">
> >       <bind-xml name="Contract"/>
> >  </field>
> > </class>
> > 
> > <class name="com.domain.function.Contract">
> >  ...
> > </clase>
> > 
> > <class name="com.domain.function.Payment">
> >  ...
> > </clase>
> > 
> > 
> > 
> > 
> >
>
------------------------------------------------------------------------------
> > Electronic Privacy Notice. This e-mail, and any
> attachments, contains information that is, or may
> be, covered by electronic communications privacy
> laws, and is also confidential and proprietary in
> nature. If you are not the intended recipient,
> please be advised that you are legally prohibited
> from retaining, using, copying, distributing, or
> otherwise disclosing this information in any manner.
> Instead, please reply to the sender that you have
> received this communication in error, and then
> immediately delete it. Thank you in advance for your
> cooperation.
> >
>
==============================================================================
> > 
> > 
> > 
> >
>
-----------------------------------------------------------
> 
> > If you wish to unsubscribe from this mailing, send
> mail to
> > [EMAIL PROTECTED] with a subject of:
> >         unsubscribe castor-dev
> > 
> > 
> 
> 
> 
>
-----------------------------------------------------------
> 
> If you wish to unsubscribe from this mailing, send
> mail to
> [EMAIL PROTECTED] with a subject of:
>         unsubscribe castor-dev
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



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

Reply via email to