I don't think this will work because of the extra elements defined in Employee. You'll probably need a patch contributed by John Weir that allows extra elements to be ignored. I haven't yet checked this patch into the CVS, but am trying to get it in this week.
--Keith "Brian Dillon (ext. 944)" wrote: > > Arnaud, > > I will try using the xsi:type aproach, I would prefer not to have an added > dependency on a mapping file. > > Thanks, > > Brian > > -----Original Message----- > From: Arnaud Blandin [mailto:[EMAIL PROTECTED]] > Sent: 07 October 2002 16:09 > To: [EMAIL PROTECTED] > Subject: Re: [castor-dev] Unmarshalling extended types > > Hi Brian, > > Have you tried the xsi:type approach? > You could set on your root tag the name of the class to use for > unmarshalling: > > <employee xsi:type="java:person"> > ... > </employee> > > you could also set a mapping file to specify that a person should be > unmarshalled using the Person class. > > Hope that helps, > > Arnaud > > > -----Original Message----- > > From: Brian Dillon (ext. 944) [mailto:[EMAIL PROTECTED]] > > Sent: Friday, October 04, 2002 3:25 PM > > To: [EMAIL PROTECTED] > > Subject: [castor-dev] Unmarshalling extended types > > > > Hi, > > > > If I have a type say Person and this is extended by another type > > Employee, > > is there anyway to unmarhsall as a Person the XML produced by the > > Employee > > helper class. > > > > For example the Xsd would be; > > > > <xsd:complexType name="Person"> > > <xsd:complexContent> > > <xsd:sequence> > > <xsd:element name="firstName" > > type="xsd:string" minOccurs="0"/> > > <xsd:element name="lastName" > > type="xsd:string" minOccurs="0"/> > > </xsd:sequence> > > </xsd:complexContent> > > </xsd:complexType> > > > > <xsd:complexType name="Employee"> > > <xsd:complexContent> > > <xsd:extension base="Person"> > > <xsd:sequence> > > <xsd:element > name="employeeNumber" > > type="xsd:long" minOccurs="0"/> > > <xsd:element name="salary" > > type="xsd:long" minOccurs="0"/> > > </xsd:sequence> > > </xsd:extension> > > </xsd:complexContent> > > </xsd:complexType> > > > > The Xml produced by Employee would look something like; > > > > <employee> > > <firstName>Fred</firstName> > > <lastName>Flintstone</lastName> > > <employeeNumber>345</employeeNumber> > > <salary>10000</salary> > > </employee> > > > > I want this XML to be read into a Person object ignoring the extra > > elements > > (i.e. I don't want to have to first parse it into an Employee and > > then cast > > back). > > > > Any help on this would be appreciated. > > > > Thanks > > > > Brian. > > > > > > > > ******************************************************************** > > ****** > > The information contained in this e-mail is confidential, > > may be privileged and is intended only for the use of the > > recipient named above. If you are not the intended > > recipient or a representative of the intended recipient, > > you have received this e-mail in error and must not copy, > > use or disclose the contents of this email to anybody > > else. If you have received this e-mail in error, please > > notify the sender immediately by return e-mail and > > permanently delete the copy you received. This email has > > been swept for computer viruses. However, you should > > carry out your own virus checks. > > > > > > Registered in Ireland, No. 205721. http://www.FINEOS.com > > ******************************************************************** > > ****** > > > > ----------------------------------------------------------- > > 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 > > ----------------------------------------------------------- > 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
