public ReplaceableItem unmarshall(StaxUnmarshallerContext context) throws Exception { ReplaceableItem replaceableItem = new ReplaceableItem(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 1; while (true) { XMLEvent xmlEvent = context.nextEvent(); if (xmlEvent.isEndDocument()) return replaceableItem; if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) { if (context.testExpression("ItemName", targetDepth)) { replaceableItem.setName(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } if (context.testExpression("Attribute", targetDepth)) { replaceableItem.withAttributes(ReplaceableAttributeStaxUnmarshaller.getInstance().unmarshall(context)); continue; } } else if (xmlEvent.isEndElement()) { if (context.getCurrentDepth() < originalDepth) { return replaceableItem; } } } }
public ReplaceableItem unmarshall(StaxUnmarshallerContext context) throws Exception { ReplaceableItem replaceableItem = new ReplaceableItem(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 1; while (true) { XMLEvent xmlEvent = context.nextEvent(); if (xmlEvent.isEndDocument()) return replaceableItem; if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) { if (context.testExpression("ItemName", targetDepth)) { replaceableItem.setName(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } if (context.testExpression("Attribute", targetDepth)) { replaceableItem.withAttributes(ReplaceableAttributeStaxUnmarshaller.getInstance().unmarshall(context)); continue; } } else if (xmlEvent.isEndElement()) { if (context.getCurrentDepth() < originalDepth) { return replaceableItem; } } } }