List of usage examples for org.w3c.dom Document toString
public String toString()
From source file:org.wso2.developerstudio.eclipse.artifact.axis2.project.refactor.Axis2ServicesXMLFileChange.java
/** * Create an input stream from a DOM Document * * @param document a DOM Document to which an input stream should be created * @return InputStream representing given DOM Document *//*from w ww. j a v a 2s . c om*/ private InputStream createInputStreamFromDocument(Document document) throws CoreException { IStatus errorStatus = new Status(Status.WARNING, Activator.PLUGIN_ID, "Error in updating services.xml file with new class name, Name : " + newClassName); //Creating an output stream to keep the updated DOM temporarily in memory ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); DOMSource xmlSource = new DOMSource(document); StreamResult outputTarget = new StreamResult(outputStream); TransformerFactory transformerFactory = TransformerFactory.newInstance(); Transformer transformer; try { transformer = transformerFactory.newTransformer(); } catch (TransformerConfigurationException e) { log.error("Unable to create javax XML Transformer to update Axis2 services.xml file", e); throw new CoreException(errorStatus); } //Setting an optional parameter to transformer that omits xml declaration in services.xml file transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, ACCEPT_INDICATOR); try { //Updating services.xml file with updated DOM Document transformer.transform(xmlSource, outputTarget); } catch (TransformerException e) { log.error("Unable to transform updated DOM Document to services.xml file, DOM Document : " + document.toString(), e); throw new CoreException(errorStatus); } return new ByteArrayInputStream(outputStream.toByteArray()); }