*/
void writeComplex(OutputStream output, OutputDataType result)
throws IOException {
Object rawResult = result.getData().getComplexData().getData().get(0);
if (rawResult instanceof RawDataEncoderDelegate) {
RawDataEncoderDelegate delegate = (RawDataEncoderDelegate) rawResult;
delegate.encode(output);
} else if (rawResult instanceof XMLEncoderDelegate) {
XMLEncoderDelegate delegate = (XMLEncoderDelegate) rawResult;
try {
TransformerHandler xmls =
((SAXTransformerFactory)SAXTransformerFactory.newInstance()).newTransformerHandler();
xmls.setResult(new StreamResult(output));
delegate.encode(xmls);
} catch (IOException e) {
throw e;
} catch (Exception e) {
throw new WPSException("An error occurred while encoding "
+ "the results of the process", e);