String uri = uri = destination.getSystemId();
if (writer == null) {
if (outputStream == null) {
if (uri == null) {
if (ser.fDOMErrorHandler != null) {
DOMErrorImpl error = new DOMErrorImpl();
error.fMessage = "no-output-specified";
error.fSeverity = DOMError.SEVERITY_FATAL_ERROR;
ser.fDOMErrorHandler.handleError(error);
}
return false;
}
else {
// uri was specified
FileOutputStream fileOut = new FileOutputStream(new File(uri));
ser.setOutputCharStream( new OutputStreamWriter(fileOut, encoding));
}
}
else {
// byte stream was specified
ser.setOutputByteStream(outputStream);
}
}
else {
// character stream is specified
ser.setOutputCharStream(writer);
}
if (node.getNodeType() == Node.DOCUMENT_NODE)
ser.serialize((Document) node);
else if (node.getNodeType() == Node.DOCUMENT_FRAGMENT_NODE)
ser.serialize((DocumentFragment) node);
else if (node.getNodeType() == Node.ELEMENT_NODE)
ser.serialize((Element) node);
else
return false;
} catch (Exception e) {
if (ser.fDOMErrorHandler != null) {
DOMErrorImpl error = new DOMErrorImpl();
error.fException = e;
error.fMessage = e.getMessage();
error.fSeverity = DOMError.SEVERITY_ERROR;
ser.fDOMErrorHandler.handleError(error);