@Override
public Object evaluate(MessageExchange exchange, NormalizedMessage message) throws MessagingException {
Object node = super.evaluate(exchange, message, XPathConstants.NODE);
HierarchicalStreamReader streamReader;
if (node instanceof Document) {
streamReader = new DomReader((Document) node);
} else if (node instanceof Element) {
streamReader = new DomReader((Element) node);
} else {
throw new IllegalArgumentException("DOMResult contains neither Document nor Element: " + node.getClass().getName());
}
return getXStream().unmarshal(streamReader);
}