StringResult extends StreamResult { public StringResult() { super(new StringWriter()); } StringResult(); String toString();  }
@Test public void testStringResult() throws Exception { Document document = DocumentBuilderFactoryUtils.newInstance().newDocumentBuilder().newDocument(); Element element = document.createElementNS("namespace", "prefix:localName"); document.appendChild(element); Transformer transformer = TransformerFactoryUtils.newInstance().newTransformer(); StringResult result = new StringResult(); transformer.transform(new DOMSource(document), result); assertXMLEqual("Invalid result", "<prefix:localName xmlns:prefix='namespace'/>", result.toString()); }