for (int i = 0; i < parent.getAttributes().getLength(); i++) { Attr att = (Attr) parent.getAttributes().item(i); if (att.getName().startsWith("xmlns:") && elem.getAttributeNodeNS(att.getNamespaceURI(), att.getLocalName()) == null) { elem.setAttributeNS(att.getNamespaceURI(), att.getName(), att.getValue());
for (Iterator itNs = parent.getNamespacePrefixes(); itNs.hasNext();) { String prefix = (String) itNs.next(); String nsuri = parent.getNamespaceURI(prefix); if (elem.getAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, prefix) == null) { elem.addNamespaceDeclaration(prefix, nsuri); elem.setAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, XMLConstants.XMLNS_ATTRIBUTE + ":" + prefix, nsuri);
    public void toNMS(NormalizedMessage normalizedMessage, SOAPMessage soapMessage) throws MessagingException, SOAPException {        if (log.isDebugEnabled()) {        	try {	            ByteArrayOutputStream buffer = new ByteArrayOutputStream();	            soapMessage.writeTo(buffer);	            log.debug(new String(buffer.toByteArray()));        	} catch (Exception e) { }        }            	addNmsProperties(normalizedMessage, soapMessage);        SOAPPart soapPart = soapMessage.getSOAPPart();        SOAPBody soapBody = soapPart.getEnvelope().getBody();        SOAPElement elem = (SOAPElement) soapBody.getChildElements().next();                for (SOAPElement parent = elem.getParentElement(); parent != null; parent = parent.getParentElement()) {        	for (int i = 0; i < parent.getAttributes().getLength(); i++) {        		Attr att = (Attr) parent.getAttributes().item(i);        		if (att.getName().startsWith("xmlns:") &&         			elem.getAttributeNodeNS(att.getNamespaceURI(), att.getLocalName()) == null) {        			elem.setAttributeNS(att.getNamespaceURI(), att.getName(), att.getValue());        		}        	}        }                if (log.isDebugEnabled()) {        	try {        		log.debug(transformer.toString(elem));        	} catch (Exception e) { }        }                normalizedMessage.setContent(new DOMSource(elem));        addNmsAttachments(normalizedMessage, soapMessage);    }