/** * Saves this memento's document current values to the specified writer. * * @param writer the writer used to save the memento's document * @throws IOException if there is a problem serializing the document to the stream. */ public void save(Writer writer) throws IOException { DOMWriter out = new DOMWriter(writer); try { out.print(element); } finally { out.close(); } }
/** * Test whether this object model recognizes a particular kind of JAXP Result object, and if it * does, return a Receiver that builds an instance of this data model from a sequence of events. * If the Result is not recognised, return null. */ public Receiver getDocumentBuilder(Result result) throws XPathException { if (result instanceof DOMResult) { DOMWriter emitter = new DOMWriter(); Node root = ((DOMResult) result).getNode(); if (root == null) { try { DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = dfactory.newDocumentBuilder(); Document out = docBuilder.newDocument(); ((DOMResult) result).setNode(out); emitter.setNode(out); } catch (ParserConfigurationException e) { throw new DynamicError(e); } } else { emitter.setNode(root); } return emitter; } return null; }
public String toString() { return dw.writeToString(docElt); }