public static Map getNamespaces(Element elem) { HashMap namespaces = new HashMap(); try { Navigator nav = DocumentNavigator.getInstance(); Iterator namespaceAxis = nav.getNamespaceAxisIterator(elem); while (namespaceAxis.hasNext()) { Object namespace = namespaceAxis.next(); String prefix = nav.getNamespacePrefix(namespace); // exclude default namespaces and overriden namespaces if (!StringUtils.isEmpty(prefix) && !namespaces.containsKey(prefix)) { String uri = nav.getNamespaceStringValue(namespace); namespaces.put(prefix, uri); } } } catch (UnsupportedAxisException e) { log.fatal( "Jaxen DOM navigator does not support the namespace axis, " + "cannot determine namespace declarations of DOM elements", e); throw new AssertionError(e); } return namespaces; }
public static void setObjectValue(Element elem, Object value) { if (value instanceof Node) { if (value instanceof SOAPElement) { // replace element copy(elem, (SOAPElement) value); } else if (value instanceof Element) { // replace element copy(elem, (Element) value); } else if (value instanceof Document) { // replace element copy(elem, ((Document) value).getDocumentElement()); } else { // replace content setStringValue(elem, ((Node) value).getNodeValue()); } } else if (value instanceof EndpointReference) { // replace element ((EndpointReference) value).writeServiceRef(elem); } else { // replace content setStringValue(elem, StringFunction.evaluate(value, DocumentNavigator.getInstance())); } }