OMFactory factory = metaFactory.getOMFactory();
OMElement incompleteElement = OMXMLBuilderFactory.createOMBuilder(factory,
new StringReader("<elem>text</elem>")).getDocumentElement(true);
OMElement root = factory.createOMElement("root", null);
OMElement child = factory.createOMElement("child", null, root);
child.addChild(incompleteElement);
StringWriter out = new StringWriter();
root.serializeAndConsume(out);
assertEquals("<root><child><elem>text</elem></child></root>", out.toString());
assertConsumed(incompleteElement);
}