protected XSLProcessorImpl init(Result result)
throws TransformerException
{
XSLProcessorImpl processor = (XSLProcessorImpl) _processor.clone();
if (result instanceof StreamResult) {
StreamResult sr = (StreamResult) result;
OutputMethodHandlerImpl outputMethodHandler =
new OutputMethodHandlerImpl();
processor.setOutputMethodHandler(outputMethodHandler);
Destination dest;
OutputStream ostream = sr.getOutputStream();
if (ostream != null) {
dest = new OutputStreamDestination(ostream);
} else {
// FIXME: we need to handle a characterWriter
throw new TransformerException("cannot use Writer result");
}
outputMethodHandler.setDestination(dest);
} else if (result instanceof SAXResult) {
SAXResult sr = (SAXResult) result;
processor.setContentHandler(sr.getHandler());
// FIXME: set lexical handler?
} else {
throw new TransformerException("unrecognized Result class: " +
result.getClass().getName());
}