inMessage.setContent(src);
Map namespaces = (Map) ctx.getProperty(ReadHeadersHandler.DECLARED_NAMESPACES); Node node = transformer.toDOMNode(src); Element element; if (node instanceof Element) { element = (Element) node; } else if (node instanceof Document) { element = ((Document) node).getDocumentElement(); } else { throw new UnsupportedOperationException("Unable to handle nodes of type " + node.getNodeType()); }  for (Iterator it = namespaces.entrySet().iterator(); it.hasNext();) { Entry entry = (Entry) it.next(); if (element.getAttributes().getNamedItemNS( XMLConstants.XMLNS_ATTRIBUTE_NS_URI, (String) entry.getKey()) == null) { element.setAttributeNS( XMLConstants.XMLNS_ATTRIBUTE_NS_URI, XMLConstants.XMLNS_ATTRIBUTE + ":" + (String) entry.getKey(), (String) entry.getValue()); } }  inMessage.setContent(new DOMSource(element));
    protected void populateExchange(MessageExchange exchange, Source src, MessageContext ctx) throws JBIException {        // TODO: Retrieve properties        NormalizedMessage inMessage = exchange.createMessage();        inMessage.setContent(src);        Attachments attachments = (Attachments) ctx.getProperty(Attachments.ATTACHMENTS_KEY);        if (attachments != null) {            for (Iterator it = attachments.getParts(); it.hasNext();) {                Attachment part = (Attachment) it.next();                inMessage.addAttachment(part.getId(), part.getDataHandler());            }        }        exchange.setMessage(inMessage, "in");    }