public StatusReport unmarshall(StaxUnmarshallerContext context) throws Exception { StatusReport statusReport = new StatusReport(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 1; while (true) { XMLEvent xmlEvent = context.nextEvent(); if (xmlEvent.isEndDocument()) return statusReport; if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) { if (context.testExpression("Status", targetDepth)) { statusReport.setStatus(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } if (context.testExpression("CheckedTime", targetDepth)) { statusReport.setCheckedTime(DateStaxUnmarshallerFactory.getInstance("iso8601").unmarshall(context)); continue; } } else if (xmlEvent.isEndElement()) { if (context.getCurrentDepth() < originalDepth) { return statusReport; } } } }