List of usage examples for javax.xml.soap SOAPElement hasAttributes
public boolean hasAttributes();
From source file:org.jbpm.bpel.integration.soap.SoapUtil.java
public static void copyAttributes(Element target, SOAPElement source) { // easy way out: no attributes to copy if (!source.hasAttributes()) return;//from w w w. j av a 2s .c o m // traverse attributes Iterator attrNameIt = source.getAllAttributes(); while (attrNameIt.hasNext()) { Name attrName = (Name) attrNameIt.next(); String namespaceURI = attrName.getURI(); // isn't the attribute a namespace declaration? if (BpelConstants.NS_XMLNS.equals(namespaceURI)) continue; // unqualified? if (namespaceURI == null || namespaceURI.length() == 0) { String localName = attrName.getLocalName(); target.setAttribute(localName, source.getAttributeValue(attrName)); if (traceEnabled) log.trace("set attribute: " + localName); } // qualified else { Attr attr = target.getOwnerDocument().createAttributeNS(namespaceURI, attrName.getQualifiedName()); attr.setValue(source.getAttributeValue(attrName)); target.setAttributeNodeNS(attr); XmlUtil.ensureNamespaceDeclared(attr, namespaceURI, attrName.getPrefix()); if (traceEnabled) log.trace("set attribute: {" + namespaceURI + '}' + attrName.getQualifiedName()); } } }
From source file:org.jbpm.bpel.integration.soap.SoapUtil.java
public static void removeAttributes(SOAPElement elem) { if (elem.hasAttributes()) { Iterator attrNameIt = elem.getAllAttributes(); while (attrNameIt.hasNext()) { Name attrName = (Name) attrNameIt.next(); elem.removeAttribute(attrName); }//from w ww . ja va2s.c o m } }