public String encode(Object obj) throws ValidationException {
StringWriter sw = new StringWriter();
GeometryTransformer transformer = new GeometryTransformer();
try {
transformer.transform(obj, sw);
} catch (TransformerException e) {
throw new ValidationException(e);
}
return "<geometry>\n" + sw.toString() + "</geometry>\n";