// Build tree
root.build();
// Use tree as input to XMLStreamReader
OMXMLStreamReader xmlStreamReader = (OMXMLStreamReader) root.getXMLStreamReader();
// Issue XOP:Include events for optimized MTOM text nodes
xmlStreamReader.setInlineMTOM(false);
DataHandler dh = null;
while(xmlStreamReader.hasNext() && dh == null) {
xmlStreamReader.next();
if (xmlStreamReader.isStartElement()) {
QName qName =xmlStreamReader.getName();
if (XOP_INCLUDE.equals(qName)) {
String hrefValue = xmlStreamReader.getAttributeValue("", "href");
if (hrefValue != null) {
dh =((OMAttachmentAccessor)xmlStreamReader).getDataHandler(hrefValue);
}
}
}
}
assertTrue(dh != null);
// Make sure next event is an an XOP_Include END element
xmlStreamReader.next();
assertTrue(xmlStreamReader.isEndElement());
assertTrue(XOP_INCLUDE.equals(xmlStreamReader.getName()));
// Make sure the next event is the end tag of name
xmlStreamReader.next();
assertTrue(xmlStreamReader.isEndElement());
assertTrue("name".equals(xmlStreamReader.getLocalName()));
}