return new Stanza(null, name, null, stanzaAttributes, xmlFragments);
}
private boolean fillDeep(String name, List<XMLFragment> xmlFragments) throws ParsingException {
XMLEvent event;
while (true) {
event = getNextXMLEvent();
if (event == null) return false;
if (event.type == XMLEvent.ELEMENT) {
ElementEvent elementEvent = (ElementEvent) event;
if (elementEvent.start) {
// collect element basics
String namespaceURI = resolveNamespace(elementEvent);
String innerName = elementEvent.element.localpart;
// collect detail data
List<Attribute> stanzaAttributes = fillAttributesFromXML(elementEvent);
List<XMLFragment> xmlInnerFragments = new ArrayList<XMLFragment>();
fillDeep(elementEvent.element.rawname, xmlInnerFragments); // (return value can be savely ignored)
// create element with all collected data
XMLElement xmlInnerElement = new XMLElement(namespaceURI, innerName, null, stanzaAttributes, xmlInnerFragments);
xmlFragments.add(xmlInnerElement);
} else {
return name.equals(elementEvent.element.rawname); // succeed if exact end element found and all is balanced
}
} else if (event.type == XMLEvent.CDATA) {
xmlFragments.add(new XMLText(event.toString()));
} else if (event.type == XMLEvent.CHARACTERS) {
XMLString xmlString = ((CharactersEvent) event).text;
xmlFragments.add(new XMLText(xmlString.toString()));
} else {
// ignore other types, as of XMPP spec