Пример #1
0
 private InputStream getInputStream(Source source) throws Exception {
   Transformer trans = TransformerFactory.newInstance().newTransformer();
   ByteArrayBuffer bab = new ByteArrayBuffer();
   StreamResult result = new StreamResult(bab);
   trans.transform(source, result);
   return bab.newInputStream();
 }
Пример #2
0
 private DOMSource toDOMSource(Source source) throws Exception {
   if (source instanceof DOMSource) {
     return (DOMSource) source;
   }
   Transformer trans = TransformerFactory.newInstance().newTransformer();
   DOMResult result = new DOMResult();
   trans.transform(source, result);
   return new DOMSource(result.getNode());
 }