use of javax.xml.transform.Result in project spring-framework by spring-projects.
the class Jaxb2MarshallerTests method marshalAWrappedObjectHoldingAnXmlElementDeclElement.
@Test
public void marshalAWrappedObjectHoldingAnXmlElementDeclElement() throws Exception {
// SPR-10714
marshaller = new Jaxb2Marshaller();
marshaller.setPackagesToScan(new String[] { "org.springframework.oxm.jaxb" });
marshaller.afterPropertiesSet();
Airplane airplane = new Airplane();
airplane.setName("test");
StringWriter writer = new StringWriter();
Result result = new StreamResult(writer);
marshaller.marshal(airplane, result);
DifferenceEvaluator ev = chain(Default, downgradeDifferencesToEqual(XML_STANDALONE));
assertThat("Marshalling should use root Element", writer.toString(), isSimilarTo("<airplane><name>test</name></airplane>").withDifferenceEvaluator(ev));
}
use of javax.xml.transform.Result in project spring-framework by spring-projects.
the class XStreamMarshallerTests method marshalStaxResultXMLEventWriter.
@Test
public void marshalStaxResultXMLEventWriter() throws Exception {
XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
StringWriter writer = new StringWriter();
XMLEventWriter eventWriter = outputFactory.createXMLEventWriter(writer);
Result result = StaxUtils.createStaxResult(eventWriter);
marshaller.marshal(flight, result);
assertThat("Marshaller writes invalid StreamResult", writer.toString(), isSimilarTo(EXPECTED_STRING));
}
use of javax.xml.transform.Result in project dbeaver by serge-rider.
the class DBDDocumentXML method serializeDocument.
@Override
public void serializeDocument(@NotNull DBRProgressMonitor monitor, @NotNull OutputStream stream, String encoding) throws DBException {
try {
Transformer transformer = TransformerFactory.newInstance().newTransformer();
Result output = new StreamResult(new OutputStreamWriter(stream, encoding));
transformer.transform(new DOMSource(document), output);
} catch (Exception e) {
throw new DBException("Error serializing XML document", e);
}
}
use of javax.xml.transform.Result in project camel by apache.
the class XQueryBuilder method evaluateAsBytes.
public byte[] evaluateAsBytes(Exchange exchange) throws Exception {
LOG.debug("evaluateAsBytes: {} for exchange: {}", expression, exchange);
initialize(exchange);
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
Result result = new StreamResult(buffer);
getExpression().pull(createDynamicContext(exchange), result, properties);
byte[] answer = buffer.toByteArray();
buffer.close();
return answer;
}
use of javax.xml.transform.Result in project asciidoctor-fopub by asciidoctor.
the class InputHandler method transformTo.
/**
* In contrast to render(Fop) this method only performs the XSLT stage and saves the
* intermediate XSL-FO file to the output file.
* @param out OutputStream to write the transformation result to.
* @throws FOPException in case of an error during processing
*/
public void transformTo(OutputStream out) throws FOPException {
Result res = new StreamResult(out);
transformTo(res);
}
Aggregations