public static String serializeNode(Node node, Properties format)
throws ProcessingException {
try {
if (node == null) return "";
StringWriter writer = new StringWriter();
TransformerHandler transformerHandler;
transformerHandler = ((SAXTransformerFactory)TransformerFactory.newInstance()).newTransformerHandler();
transformerHandler.getTransformer().setOutputProperties(format);
transformerHandler.setResult(new StreamResult(writer));
if ( node.getNodeType() != Node.DOCUMENT_NODE ) {
transformerHandler.startDocument();
}
DOMStreamer domStreamer = new DOMStreamer(transformerHandler, transformerHandler);
domStreamer.stream(node);
if ( node.getNodeType() != Node.DOCUMENT_NODE ) {
transformerHandler.endDocument();
}
return writer.toString();
} catch (javax.xml.transform.TransformerException local) {
throw new ProcessingException("TransformerException: " + local, local);
} catch (SAXException local) {