Search in sources :

Example 96 with OMAttribute

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

Example 97 with OMAttribute

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

Example 98 with OMAttribute

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

the class TestGetLangWithParser method runTest.

@Override
protected void runTest(SOAPEnvelope envelope) throws Throwable {
    SOAPFaultText faultText = envelope.getBody().getFault().getReason().getFirstSOAPText();
    assertTrue("SOAP 1.2 Fault Text Test With Parser : - getLang method returns incorrect string", faultText.getLang().equals("en"));
    OMAttribute langAttribute = faultText.getAllAttributes().next();
    assertTrue("SOAP 1.2 Fault Text Test With Parser : - Lang attribute local name mismaatch", langAttribute.getLocalName().equals(SOAP12Constants.SOAP_FAULT_TEXT_LANG_ATTR_LOCAL_NAME));
    assertTrue("SOAP 1.2 Fault Text Test With Parser : - Lang attribute namespace prefix mismatch", langAttribute.getNamespace().getPrefix().equals(SOAP12Constants.SOAP_FAULT_TEXT_LANG_ATTR_NS_PREFIX));
    assertTrue("SOAP 1.2 Fault Text Test With Parser : - Lang attribute namespace uri mismatch", langAttribute.getNamespace().getNamespaceURI().equals(SOAP12Constants.SOAP_FAULT_TEXT_LANG_ATTR_NS_URI));
}
Also used : SOAPFaultText(org.apache.axiom.soap.SOAPFaultText) OMAttribute(org.apache.axiom.om.OMAttribute)

Example 99 with OMAttribute

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

the class TestSetLocalName method runTest.

@Override
protected void runTest() throws Throwable {
    OMFactory factory = metaFactory.getOMFactory();
    OMAttribute attr = factory.createOMAttribute("test", factory.createOMNamespace("urn:test", "p"), "value");
    attr.setLocalName("test2");
    assertEquals("test2", attr.getLocalName());
    QName qname = attr.getQName();
    assertEquals("test2", qname.getLocalPart());
    assertEquals("p", qname.getPrefix());
    assertEquals("urn:test", qname.getNamespaceURI());
}
Also used : OMFactory(org.apache.axiom.om.OMFactory) QName(javax.xml.namespace.QName) OMAttribute(org.apache.axiom.om.OMAttribute)

Example 100 with OMAttribute

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

the class TestGetPrefixWithoutNamespace method runTest.

@Override
protected void runTest() throws Throwable {
    OMFactory factory = metaFactory.getOMFactory();
    OMAttribute attr = factory.createOMAttribute("name", null, "value");
    assertNull(attr.getPrefix());
}
Also used : OMFactory(org.apache.axiom.om.OMFactory) 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