XMLInputFactory inputFactory = XMLInputFactory.newInstance();
XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
XMLEventWriter evtWriter = null;
try {
evtWriter = outputFactory.createXMLEventWriter(outStream);
} catch (XMLStreamException ex) {
}
assertNotNull(evtWriter);
try {
XMLEventFactory factory = XMLEventFactory.newInstance();
staxObject.writeObjectToStax(obj, evtWriter, factory);
evtWriter.flush();
} catch (XMLStreamException ex) {
}
ByteArrayInputStream inStream = new ByteArrayInputStream(outStream.toByteArray());
XMLEventReader evtReader = null;