StringWriter writer = new StringWriter();
XMLStreamWriter xmlwriter = StAXUtils.createXMLStreamWriter(writer);
OMXMLParserWrapper builder = OMXMLBuilderFactory.createStAXOMBuilder(
metaFactory.getOMFactory(), root.getXMLStreamReader());
OMDocument omDocument = builder.getDocument();
Iterator it = omDocument.getChildren();
while (it.hasNext()) {
OMNode omNode = (OMNode) it.next();
// TODO: quick fix required because OMChildrenIterator#next() no longer builds the node
omNode.getNextOMSibling();
omNode.serializeAndConsume(xmlwriter);