Search in sources :

Example 91 with OMAttribute

use of org.apache.axiom.om.OMAttribute in project webservices-axiom by apache.

the class TestAddAttributeAlreadyOwnedByElement method runTest.

@Override
protected void runTest() throws Throwable {
    OMFactory factory = metaFactory.getOMFactory();
    OMElement element = factory.createOMElement(new QName("test"));
    OMAttribute att = element.addAttribute("test", "test", null);
    OMAttribute result = element.addAttribute(att);
    assertSame(result, att);
    assertSame(element, att.getOwner());
    Iterator<OMAttribute> it = element.getAllAttributes();
    assertTrue(it.hasNext());
    assertSame(att, it.next());
    assertFalse(it.hasNext());
}
Also used : OMFactory(org.apache.axiom.om.OMFactory) QName(javax.xml.namespace.QName) OMElement(org.apache.axiom.om.OMElement) OMAttribute(org.apache.axiom.om.OMAttribute)

Example 92 with OMAttribute

use of org.apache.axiom.om.OMAttribute in project webservices-axiom by apache.

the class TestAddAttributeAlreadyOwnedByOtherElement method runTest.

@Override
protected void runTest() throws Throwable {
    OMFactory factory = metaFactory.getOMFactory();
    OMElement element1 = factory.createOMElement(new QName("test"));
    OMElement element2 = factory.createOMElement(new QName("test"));
    OMAttribute att1 = element1.addAttribute("test", "test", null);
    OMAttribute att2 = element2.addAttribute(att1);
    assertSame(element1, att1.getOwner());
    assertNotSame(att1, att2);
    assertSame(element2, att2.getOwner());
}
Also used : OMFactory(org.apache.axiom.om.OMFactory) QName(javax.xml.namespace.QName) OMElement(org.apache.axiom.om.OMElement) OMAttribute(org.apache.axiom.om.OMAttribute)

Example 93 with OMAttribute

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());
}
Also used : QName(javax.xml.namespace.QName) OMElement(org.apache.axiom.om.OMElement) OMAttribute(org.apache.axiom.om.OMAttribute)

Example 94 with OMAttribute

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());
}
Also used : OMElement(org.apache.axiom.om.OMElement) OMAttribute(org.apache.axiom.om.OMAttribute)

Example 95 with OMAttribute

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();
}
Also used : OMFactory(org.apache.axiom.om.OMFactory) PullOMDataSource(org.apache.axiom.ts.om.sourcedelement.util.PullOMDataSource) OMSourcedElement(org.apache.axiom.om.OMSourcedElement) OMAttribute(org.apache.axiom.om.OMAttribute)

Aggregations

OMAttribute (org.apache.axiom.om.OMAttribute)187 OMElement (org.apache.axiom.om.OMElement)116 QName (javax.xml.namespace.QName)82 Iterator (java.util.Iterator)41 OMFactory (org.apache.axiom.om.OMFactory)31 OMNamespace (org.apache.axiom.om.OMNamespace)28 SynapseException (org.apache.synapse.SynapseException)28 JaxenException (org.jaxen.JaxenException)28 OMNode (org.apache.axiom.om.OMNode)13 Value (org.apache.synapse.mediators.Value)12 SynapseXPath (org.apache.synapse.util.xpath.SynapseXPath)11 ArrayList (java.util.ArrayList)8 Endpoint (org.apache.synapse.endpoints.Endpoint)7 IOException (java.io.IOException)6 List (java.util.List)6 OMText (org.apache.axiom.om.OMText)6 SOAPEnvelope (org.apache.axiom.soap.SOAPEnvelope)6 StringReader (java.io.StringReader)5 SOAPHeaderBlock (org.apache.axiom.soap.SOAPHeaderBlock)5 EndpointDefinition (org.apache.synapse.endpoints.EndpointDefinition)5