private void write(Source source, Node n) { try { if (source instanceof DOMSource && ((DOMSource)source).getNode() == null) { return; } XMLStreamWriter writer = new W3CDOMStreamWriter((Element)n); StaxUtils.copy(source, writer); } catch (XMLStreamException e) { throw new Fault(e); } }
try { writer = StaxUtils.createXMLStreamWriter(bwriter); StaxUtils.copy(o, writer); writer.flush(); ds = new ByteDataSource(bwriter.toByteArray(), ct);
private void doFromSoapMessage(Message message, Object sm) { SOAPMessage m = (SOAPMessage)sm; MessageContentsList list = (MessageContentsList)message.getContent(List.class); if (list == null) { list = new MessageContentsList(); message.setContent(List.class, list); } Object o = m; if (StreamSource.class.isAssignableFrom(type)) { try { try (CachedOutputStream out = new CachedOutputStream()) { XMLStreamWriter xsw = StaxUtils.createXMLStreamWriter(out); StaxUtils.copy(new DOMSource(m.getSOAPPart()), xsw); xsw.close(); o = new StreamSource(out.getInputStream()); } } catch (Exception e) { throw new Fault(e); } } else if (SAXSource.class.isAssignableFrom(type)) { o = new StaxSource(new W3CDOMStreamReader(m.getSOAPPart())); } else if (Source.class.isAssignableFrom(type)) { o = new DOMSource(m.getSOAPPart()); } list.set(0, o); }
/** * Copies the reader to the writer. The start and end document methods must * be handled on the writer manually. * * @param reader * @param writer * @throws XMLStreamException */ public static void copy(XMLStreamReader reader, XMLStreamWriter writer) throws XMLStreamException { copy(reader, writer, false, false); } public static void copy(XMLStreamReader reader, XMLStreamWriter writer, boolean fragment)
private Document copy(Document doc) { try { return StaxUtils.copy(doc); } catch (XMLStreamException | ParserConfigurationException e) { // ignore } return doc; }
/** * Copies the reader to the writer. The start and end document methods must * be handled on the writer manually. * * @param reader * @param writer * @throws XMLStreamException */ public static void copy(XMLStreamReader reader, XMLStreamWriter writer) throws XMLStreamException { copy(reader, writer, false, false); } public static void copy(XMLStreamReader reader, XMLStreamWriter writer, boolean fragment)
public static void copy(XMLStreamReader reader, OutputStream os) throws XMLStreamException { XMLStreamWriter xsw = StaxUtils.createXMLStreamWriter(os); StaxUtils.copy(reader, xsw); xsw.close(); }
public static void copy(XMLStreamReader reader, OutputStream os) throws XMLStreamException { XMLStreamWriter xsw = StaxUtils.createXMLStreamWriter(os); StaxUtils.copy(reader, xsw); xsw.close(); }
public static void copy(Document doc, XMLStreamWriter writer) throws XMLStreamException { XMLStreamReader reader = createXMLStreamReader(doc); copy(reader, writer); } public static void copy(Element node, XMLStreamWriter writer) throws XMLStreamException {
public static void copy(XMLStreamReader reader, OutputStream os) throws XMLStreamException { XMLStreamWriter xsw = StaxUtils.createXMLStreamWriter(os); StaxUtils.copy(reader, xsw); xsw.close(); }
SAAJUtils.getBody(m).removeContents(); W3CDOMStreamWriter writer = new W3CDOMStreamWriter(SAAJUtils.getBody(m)); StaxUtils.copy(s, writer); writer.flush(); writer.close();
public static void print(Node node) { XMLStreamWriter writer = null; try { writer = createXMLStreamWriter(System.out); copy(new DOMSource(node), writer); writer.flush(); } catch (XMLStreamException e) { throw new RuntimeException(e); } finally { StaxUtils.close(writer); } }
private void writeXml(Node n, PrintWriter pw) throws XMLStreamException { XMLStreamWriter writer = StaxUtils.createXMLStreamWriter(pw); writer = new PrettyPrintXMLStreamWriter(writer, 2); StaxUtils.copy(new DOMSource(n), writer); writer.close(); } }
static Document loadFastinfosetDocument(URL url) throws IOException, ParserConfigurationException, XMLStreamException { InputStream is = url.openStream(); InputStream in = new BufferedInputStream(is); XMLStreamReader staxReader = new StAXDocumentParser(in); W3CDOMStreamWriter writer = new W3CDOMStreamWriter(); StaxUtils.copy(staxReader, writer); in.close(); return writer.getDocument(); }
SOAPPart part = soapMessage.getSOAPPart(); if (o instanceof Source) { StaxUtils.copy((Source)o, new SAAJStreamWriter(part));
@Override protected void marshalToWriter(Marshaller ms, Object obj, XMLStreamWriter writer, Annotation[] anns, MediaType mt) throws Exception { CachedOutputStream out = new CachedOutputStream(); marshalToOutputStream(ms, obj, out, anns, mt); StaxUtils.copy(new StreamSource(out.getInputStream()), writer); }