Hi,

I have been puzzeling with this problem for some time, and I simply cannot get it to work.

My xml is something like this:
<news>
<title>Some news</title>
<body>
<p>The body of the <b>news</b></p>
</body>
<author>Me, Myself and I</author>
<date>2003-02-21</date>
</news>

My problem is that I would like to map the entire body tag to a single String on the object, this is no problem as long as the body does not contain any tags, but if it contain tags these are not passed as part of the body string.

My current castorMapping.xml is as follows:
<class name="dk.aub.webservice.news.om.News">
<map-to xml="news"/>
<field name="id" type="integer" required="false"/>
<field name="title" type="string" required="false"/>
<field name="body" type="string"
handler="dk.aub.webservice.BodyHandler">
<bind-xml name="body" node="element"/>
</field>
<field name="author" type="string" required="false"/>
<field name="date" type="string"
handler="dk.aub.webservice.DateHandler" >
<bind-xml name="date" node="element"/>
</field>
</class>

And my body handler is as follows:
public class BodyHandler implements FieldHandler {
public Object getValue(Object o) throws IllegalStateException {
return ((News)o).getBody();
}

public void setValue(Object o, Object o1)
throws IllegalStateException, IllegalArgumentException {
News n = (News)o;
n.setBody((String)o1);
}

public void resetValue(Object o)
throws IllegalStateException, IllegalArgumentException {
System.err.println("XX resetValue(" + o + ")");
}

public void checkValidity(Object o)
throws ValidityException, IllegalStateException {
System.err.println("XX checkValidity(" + o + ")");
}

public Object newInstance(Object o)
throws IllegalStateException {
System.err.println("XX newInstance(" + o + ")");
return new String();
}
}

Does anyone has an idea on how to do this?
Thanks in advance.

--
Bo Gundersen
DBA/Software Developer
M.Sc.CS.
www.atira.dk

----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev

Reply via email to