ByteArrayOutputStream baosForSource = new FixedByteArrayOutputStream(BYTE_ARRAY_SIZE);
XMLStreamWriter xsWriterForSource = XMLOutputFactory.newInstance().
createXMLStreamWriter(baosForSource);
sourceNode.serialize(xsWriterForSource);
isForSource = new ByteArrayInputStream(baosForSource.toByteArray());
transformSrc = new StreamSource(isForSource);
transformTgt = new StreamResult(baosForTarget);
} catch (XMLStreamException e) {
handleException("Error creating a StreamResult for the transformation", e, synCtx);