Object value,
SerializationContext context)
throws IOException {
try {
AxisContentHandler hand = new AxisContentHandler(context);
Marshaller marshaller = new Marshaller(hand);
// Don't include the DOCTYPE, otherwise an exception occurs due to
//2 DOCTYPE defined in the document. The XML fragment is included in
//an XML document containing already a DOCTYPE
marshaller.setMarshalAsDocument(false);
String localPart = name.getLocalPart();
int arrayDims = localPart.indexOf('[');
if (arrayDims != -1) {
localPart = localPart.substring(0, arrayDims);
}
marshaller.setRootElement(localPart);
// Marshall the Castor object into the stream (sink)
marshaller.marshal(value);
} catch (MarshalException me) {
log.error(Messages.getMessage("castorMarshalException00"), me);
throw new IOException(Messages.getMessage(
"castorMarshalException00")
+ me.getLocalizedMessage());