Note: Forwarded message attached
-- Orignal Message --
From: "bhupinder ubhi" <[EMAIL PROTECTED]>
To: [email protected]
Subject: [castor-user] mapping classes by default
--- Begin Message ---
Hi Keith,
Thank you for your interest. As you had asked for,
My xml file looks like this :
<SEARCH_DATA>
<ARRANGE_BY>E</ARRANGE_BY>
<CABIN>E</CABIN>
</SEARCH_DATA>
Now here i have a class for called Cabin which i m not using here. but somewhere else.
My mapping xml looks like this:
<mapping>
<class name="com.kyoo.ibe.traveltypes.SearchData">
<map-to xml="SEARCH_DATA"/>
<field name="arrangeBy" type="java.lang.String">
<bind-xml name="ARRANGE_BY" node="element"/>
</field>
</class>
</mapping>
My unmarshalling code looks like this.
Note: doc contains the enitre xml document.
Document doc;
Mapping mapping = new Mapping("<mapping_file_name>");
unmar = new Unmarshaller(mapping);
unmar.setIgnoreExtraAttributes(true);
unmar.setIgnoreExtraElements(true);
SearchData = (SearchData)unmar.unmarshal(doc);
I get the error as :
NoClassDefFoundError: <package-name>.CABIN(Wrong name <package_name>.Cabin)
Here I dont want to map Cabin class to the CABIN element in the xml.
Is there a way i can fix this without changing the name of class Cabin to something else say Cabin1.
Our previous conversation
I have an xml which says:
<A>
<B></B>
<CABIN>E</CABIN>
</A>
i want to read only <A> and <B> and ignore <CABIN>.
i have used unmarshaller.setIgnoreExtraElements(true) in the code to ignore <CABIN>.
I have three class a , b and Cabin.
i have mapped <A> to class a and <B> to class b.
When i run the code i get and error:
NoClassDefFoundError: <package-name>.CABIN(Wrong name <package_name>.Cabin).
I think the element <CABIN> get mapped to Cabin by default.
It is possible to stop this if i change the name of the class Cabin to Cabin1.
How do stop this without changing the name of the class Cabin?
You said that you need a bit more insight on the xml and the mapping file.
![]()
----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to [EMAIL PROTECTED] with a subject of: unsubscribe castor-user
--- End Message ---
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-user
