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();
StartElement startEl = factory.createStartElement(obj.getName(), null, null);
evtWriter.add(startEl);
simpleBindingImpl.writePrimitiveToStax(obj, evtWriter, factory);
EndElement endEl = factory.createEndElement(obj.getName(), null);
evtWriter.add(endEl);
evtWriter.flush();
} catch (XMLStreamException ex) {
}
ByteArrayInputStream inStream = new ByteArrayInputStream(outStream.toByteArray());