Hi all,
I am just using Castor 0.9.3 and it is interesting to use and to apply.
However I have a problem with mapping file. From previous posting, it
seems that Castor maintain a tight coupling between XML and
corresponding Java objects.
The problem happens because I need to map XML which has no direct
correspondence to Java object.
XML format:
<appointment>
<date>20001101</date>
<time>1500</time>
</appointment>
Java class:
public class Message {
Request _request;
public void setRequest(Request req) {
_request = req;
}
public Request getRequest(){
return _request;
}
public class Request {
Appointment _appointment;
public void setAppointment(Appointment app) {
_appointment = app;
}
public Appointment getAppointment(){
return _appointment;
}
public class Appointment {
String _date, _time;
public String getDate(){return _date;}.
public void setDate(String date){_date = date;}
public String getTime(){return _time;}.
public void setDate(String time){_time = time;}
}
Thus, the Java classes are expected to generate a new XML :
<message>
<request>
<appointment>
<date>20001101</date>
<time>1500</time>
</appointment>
</request>
</message>
It appears that the mapping file below does not give expected result.
<mapping>
<class name="Message">
<field name="Request"
type="Request">
<bind-xml name="request" node="element"/>
</field>
</class>
<class name="Request">
<field name="Appointment"
type="Appointment">
<bind-xml name="appointment" node="element"/>
</field>
</class>
<class name="Appointment">
<map-to xml="appointment"/>
<field name="date"
type="java.lang.String">
<bind-xml name="date" node="element"/>
</field>
<field name="time"
type="java.lang.String">
<bind-xml name="time" node="element"/>
</field>
</class>
</mapping>
It will give message error that the class for the root element
'appointment' could not be found.
Can I skip the Message and Request classes, and directly pointing to
Appointment, because it is obvious that Message and Request classes have
no link to XML input ? And I intend to use the same mapping file for
marshalling to generate new XML.
Thanks for any suggestion.
Regards,
Agustinus Tedja
Technische Universit�t Hamburg-Harburg
Telematik Arbeitsbereich
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev