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) {
inputSource = new DOMSource((Document) payload);
} else if (payload instanceof byte[]) {
inputSource = new BytesSource((byte[]) payload);
} else if (payload instanceof String) {
inputSource = new StringSource((String) payload);
} else {
throw new UnsupportedOperationException("Unable to retrieve value");
}