}
protected Source getSourceFromPayload(Object payload) {
Source inputSource;
if (payload instanceof IFormattableValue) {
IFormattableValue value = (IFormattableValue) payload;
if (value.supportsGetValueAs(Document.class)) {
Document doc = (Document) value.getValueAs(Document.class);
inputSource = new DOMSource(doc);
} else if (value.supportsGetValueAs(byte[].class)) {
byte[] data = (byte[]) value.getValueAs(byte[].class);
inputSource = new BytesSource(data);
} else if (value.supportsGetValueAs(String.class)) {
String data = (String) value.getValueAs(String.class);
inputSource = new StringSource(data);
} else {
throw new UnsupportedOperationException("Unable to retrieve value");
}
} else if (payload instanceof Document) {