public XMLObject unmarshall(Element domElement) throws UnmarshallingException {
log.trace("Starting to unmarshall DOM element {}", XMLHelper.getNodeQName(domElement));
checkElementIsTarget(domElement);
XMLObject xmlObject = buildXMLObject(domElement);
log.trace("Unmarshalling attributes of DOM Element {}", XMLHelper.getNodeQName(domElement));
NamedNodeMap attributes = domElement.getAttributes();
Node attribute;
for (int i = 0; i < attributes.getLength(); i++) {
attribute = attributes.item(i);
// These should allows be attribute nodes, but just in case...
if (attribute.getNodeType() == Node.ATTRIBUTE_NODE) {
unmarshallAttribute(xmlObject, (Attr) attribute);
}
}
log.trace("Unmarshalling other child nodes of DOM Element {}", XMLHelper.getNodeQName(domElement));
NodeList childNodes = domElement.getChildNodes();
Node childNode;
for (int i = 0; i < childNodes.getLength(); i++) {
childNode = childNodes.item(i);
if (childNode.getNodeType() == Node.ATTRIBUTE_NODE) {
unmarshallAttribute(xmlObject, (Attr) childNode);
} else if (childNode.getNodeType() == Node.ELEMENT_NODE) {
unmarshallChildElement(xmlObject, (Element) childNode);
} else if (childNode.getNodeType() == Node.TEXT_NODE) {
unmarshallTextContent(xmlObject, (Text) childNode);
}
}
xmlObject.setDOM(domElement);
return xmlObject;
}