I tried using just the .setRequest(reqImpl) without
prior copying but I still get the same ClassCastException.

Is there anything else I need to check?
Would it possibly be something to do with the
schema itself?

Thanks,
James Kavanagh

-----Original Message-----
From: David Jencks [mailto:[EMAIL PROTECTED] 
Sent: 02 August 2005 16:45
To: [email protected]
Subject: Re: ClassCastException

You can leave out the .copy().  setFoo() copies the xmlobject anyway:  
otherwise you would get diamonds or directed acyclic graphs, not trees
or setting in one place would remove the object from its original
location.

I suspect that .copy() is an XmlObject method and you would need to
changeType on the returned object, but I didn't check.

thanks
david jencks

On Aug 2, 2005, at 6:10 AM, James Kavanagh wrote:

> As an addendum I've included the code snippet I'm using.
>
> RequestDocument req =
>       RequestDocument.Factory.parse(new File("C:/Temp/ex.xml"),
options);
>                       
> System.out.println(
>       "Request -- " +
> req.getRequest().getCardDetails().getExpiryDate());
>
> ResponseDocument res = ResponseDocument.Factory.newInstance();
>                       
> Request reqImpl = (Request)req.getRequest().copy();
>                       
>>> res.setRequest(reqImpl);
>                       
> System.out.println(
>       "Response -- " +
> res.getResponse().getCardDetails().getExpiryDate());
>
>>> Indicates the line where the ClassCastException is occurring.
> Hope this makes things a little clearer.
>
> -----Original Message-----
> From: James Kavanagh [mailto:[EMAIL PROTECTED]
> Sent: 02 August 2005 12:42
> To: [email protected]
> Subject: RE: ClassCastException
>
> Hi,
>
> I'm new to XML Beans so forgive me if I've missed something glaringly 
> obvious...
>
> I have a schema with two elements, Request and Response.
> The Response element is derived from the Request element and this is 
> very helpfully reflected in the compiled objects after using scomp.
>
> Effectively when I receive a request instance I construct a response 
> instance which needs to have the original details of the request. 
> There is a method ResponseDocument.setRequest() which I call passing 
> in a cloned instance of the original RequestImpl object. Doing this I 
> get the following ClassCastException:
>
> Cannot cast org.apache.xmlbeans.impl.values.XmlAnyTypeImpl (id=159) to

> noNamespace.Request
>
> Is there something fundamentally wrong with what I'm trying to do
here?
>
> James Kavanagh
> Global-Nomi
> Mob: +447971031459
>
>
> ______________________________________________________________________
> _
> _
> ________
>
> DISCLAIMER:  This email contains proprietary information some or all 
> of which may be legally privileged.
> It is for the intended recipient only. If an addressing or 
> transmission error has misdirected this email, please notify the 
> author by replying to this email.
> If you are not the intended recipient, you must not use, disclose, 
> copy, print, or rely on this email.
> Global-Nomi cannot accept liability for any statements made which are 
> clearly the sender's own and not  expressly made on behalf of 
> Global-Nomi or one of its agents.
> This message is sent with the premise that it will arrive unaltered 
> and as the author intended.  But no assumption should be made that 
> this message is exactly as transmitted
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to