List of usage examples for javax.xml.soap SOAPElement getAllAttributes
public Iterator<Name> getAllAttributes();
From source file:com.googlecode.ddom.frontend.saaj.SOAPElementTest.java
/** * Test that {@link SOAPElement#getAllAttributes()} returns the correct {@link Name} for an * attribute without namespace.//from w w w .j a v a 2s. c om */ @Validated @Test public void testGetAllAttributesWithoutNamespace() { SOAPElement element = saajUtil.createSOAPElement(null, "test", null); element.setAttributeNS(null, "test", "value"); Iterator<?> it = element.getAllAttributes(); assertTrue(it.hasNext()); Name name = (Name) it.next(); assertTrue(StringUtils.isEmpty(name.getURI())); assertTrue(StringUtils.isEmpty(name.getPrefix())); assertEquals("test", name.getLocalName()); assertEquals("test", name.getQualifiedName()); }
From source file:com.googlecode.ddom.frontend.saaj.SOAPElementTest.java
/** * Test that {@link SOAPElement#getAllAttributes()} returns the correct {@link Name} for an * attribute with a namespace./*from w ww . j av a 2s .c o m*/ */ @Validated @Test public void testGetAllAttributesWithNamespace() { SOAPElement element = saajUtil.createSOAPElement(null, "test", null); element.setAttributeNS("urn:ns", "p:test", "value"); Iterator<?> it = element.getAllAttributes(); assertTrue(it.hasNext()); Name name = (Name) it.next(); assertEquals("urn:ns", name.getURI()); assertEquals("p", name.getPrefix()); assertEquals("test", name.getLocalName()); assertEquals("p:test", name.getQualifiedName()); }
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;// w w w . jav a 2s.c om // 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 ww w. j av a2s. c om } }