Java Reference
In-Depth Information
<class name="">
<map-to xml="TemperatureInfo"
ns-uri="" />
<field name="city" type="string">
<bind-xml name="city" node="attribute" />
<field name="date" type="string"
<bind-xml name="date" node="attribute" />
<field name="min" type="double">
<bind-xml name="min" node="element" />
<field name="max" type="double">
<bind-xml name="max" node="element" />
<field name="average" type="double">
<bind-xml name="average" node="element" />
Remember that for each class mapping, you must specify the namespace URI for the element.
Besides, for all the date fields, you have to specify a handler to convert the dates with a particular date
format. The handler is implemented as shown following:
import org.exolab.castor.mapping.GeneralizedFieldHandler;
public class DateFieldHandler extends GeneralizedFieldHandler {
private DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
public Object convertUponGet(Object value) {
return format.format((Date) value);
public Object convertUponSet(Object value) {
try {
return format.parse((String) value);
} catch (ParseException e) {
throw new RuntimeException(e);
public Class getFieldType() {
return Date.class;
Search WWH ::

Custom Search