@Override public void write(OutputStream outputStream) throws IOException { try { if (getDocument() != null) { final Transformer transformer = createTransformer(); transformer.transform(new DOMSource(getDocument()), new StreamResult(outputStream)); } } catch (TransformerConfigurationException tce) { throw new IOException("Couldn't write the XML representation: " + tce.getMessage()); } catch (TransformerException te) { throw new IOException("Couldn't write the XML representation: " + te.getMessage()); } catch (TransformerFactoryConfigurationError tfce) { throw new IOException("Couldn't write the XML representation: " + tfce.getMessage()); } } }
@Override public void write(Writer writer) throws IOException { if (Edition.CURRENT == Edition.ANDROID) { throw new UnsupportedOperationException( "Instances of DomRepresentation cannot be written at this time."); } try { if (getDocument() != null) { final javax.xml.transform.Transformer transformer = createTransformer(); transformer.transform(new javax.xml.transform.dom.DOMSource( getDocument()), new javax.xml.transform.stream.StreamResult(writer)); } } catch (javax.xml.transform.TransformerConfigurationException tce) { throw new IOException("Couldn't write the XML representation: " + tce.getMessage()); } catch (javax.xml.transform.TransformerException te) { throw new IOException("Couldn't write the XML representation: " + te.getMessage()); } catch (javax.xml.transform.TransformerFactoryConfigurationError tfce) { throw new IOException("Couldn't write the XML representation: " + tfce.getMessage()); } } }