protected Object transformSource(Source source, Object payload, Transformer transformer)
     throws TransformerException {
   Result result = resultFactory.createResult(payload);
   transformer.transform(source, result);
   if (resultTransformer != null) {
     return resultTransformer.transformResult(result);
   }
   return result;
 }
 protected Document transformDocument(Document documentPayload, Transformer transformer)
     throws TransformerException {
   DOMSource source = new DOMSource(documentPayload);
   Result result = resultFactory.createResult(documentPayload);
   if (!DOMResult.class.isAssignableFrom(result.getClass())) {
     throw new MessagingException(
         "Document to Document conversion requires a DOMResult-producing ResultFactory implementation.");
   }
   DOMResult domResult = (DOMResult) result;
   transformer.transform(source, domResult);
   return (Document) domResult.getNode();
 }