use of org.apache.axiom.om.OMAttribute in project webservices-axiom by apache.
the class TestGetAttributeWithXmlPrefix2 method runTest.
@Override
protected void runTest() throws Throwable {
OMElement elem = AXIOMUtil.stringToOM(metaFactory.getOMFactory(), "<Policy xml:base=\"uri:thisBase\"></Policy>");
OMAttribute attr = elem.getAttribute(new QName(XMLConstants.XML_NS_URI, "base"));
assertEquals("Attribute namespace mismatch", XMLConstants.XML_NS_URI, attr.getNamespace().getNamespaceURI());
}
use of org.apache.axiom.om.OMAttribute in project webservices-axiom by apache.
the class TestGetAllAttributes1 method runTest.
@Override
protected void runTest() throws Throwable {
OMElement element = metaFactory.getOMFactory().createOMElement("test", null);
element.addAttribute("attr1", "value1", null);
element.addAttribute("attr2", "value2", null);
Iterator<OMAttribute> it = element.getAllAttributes();
assertTrue(it.hasNext());
OMAttribute attr = it.next();
assertEquals("attr1", attr.getLocalName());
assertTrue(it.hasNext());
attr = it.next();
assertEquals("attr2", attr.getLocalName());
assertFalse(it.hasNext());
}
use of org.apache.axiom.om.OMAttribute in project webservices-axiom by apache.
the class TestGetAllAttributes method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
OMSourcedElement element = factory.createOMElement(new PullOMDataSource("<root attr='value'/>"), "root", null);
Iterator<OMAttribute> attributes = element.getAllAttributes();
assertThat(attributes.hasNext()).isTrue();
OMAttribute attr = attributes.next();
assertThat(attr.getLocalName()).isEqualTo("attr");
assertThat(attributes.hasNext()).isFalse();
}
use of org.apache.axiom.om.OMAttribute in project webservices-axiom by apache.
the class TestGetAttribute method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
OMSourcedElement element = factory.createOMElement(new PullOMDataSource("<root attr='value'/>"), "root", null);
OMAttribute attr = element.getAttribute(new QName("attr"));
assertThat(attr).isNotNull();
assertThat(attr.getLocalName()).isEqualTo("attr");
}
use of org.apache.axiom.om.OMAttribute in project webservices-axiom by apache.
the class AxiomTraverser method getAttributes.
@Override
public Map<QName, String> getAttributes() {
Map<QName, String> attributes = null;
for (Iterator<OMAttribute> it = ((OMElement) node).getAllAttributes(); it.hasNext(); ) {
OMAttribute attr = it.next();
if (attributes == null) {
attributes = new HashMap<QName, String>();
}
attributes.put(attr.getQName(), attr.getAttributeValue());
}
return attributes;
}
Aggregations