Robert,
It's not weird behavior..it's the expected behavior...see below... Robert Ollila wrote: > > Hi all, > > I am seeing some weird marhsalling behavior. I have a simple schema as > follows: > > <?xml version="1.0" encoding="UTF-8"?> > <!--W3C Schema generated by XML Spy v4.1 U (http://www.xmlspy.com)--> > <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" > elementFormDefault="qualified"> > <xs:element name="profile"> > <xs:complexType> > <xs:sequence> > <xs:element name="profile_name" > type="xs:string"/> > <xs:element name="profile_revision" > type="xs:long"/> > </xs:sequence> > </xs:complexType> > </xs:element> > </xs:schema> > > The class that gets generated is "Profile". After generating the source, I > create class ProfileVCWrapper which extends Profile, so I can add > miscellaneous methods without modifying the generated source. Now when I > try to marshall the class ProfileVCWrapper this is what I get: > > <?xml version="1.0"?> > <profile-vCWrapper profile-revision="222"> > <profile-name>Bobs Profile</profile-name> > </profile-vCWrapper> > > Why is the marshaller trying to use the name of the class which extended the > generated class? When using generated source Castor relies on Descriptor files to give it the information it needs... You need to create a ProfileVCWrapperDescriptor that extends ProfileDescriptor. You don't have to add any methods to this class...simply extend it. public class ProfileVCWrapperDescriptor extends ProfileDescriptor { public ProfileVCWrapperDescriptor() { super(); } } > Why does "profile-revision" tag output as an attribute? (when you marshall > the Profile class alone everything works fine and "profile-revision" is > correctly output as an element). > Castor is performing default introspection, because you don't have a ProfileVCWrapperDescriptor. > Subsequently the unmarshalling also goes haywire, it says that it cannot > find the "profile-name" descriptor. Because you don't have ProfileVCWrapperDescriptor. > > If this means that you simply cannot extend generated source and then > marshall the new class, how else can you address this problem? > By creating a ProfileCVWrapperDescriptor. --Keith ----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to [EMAIL PROTECTED] with a subject of: unsubscribe castor-dev
