Search in sources :

Example 36 with OMNamespace

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

the class TestCreateOMAttributeWithInvalidNamespace2 method runTest.

@Override
protected void runTest() throws Throwable {
    OMFactory factory = metaFactory.getOMFactory();
    OMNamespace ns = factory.createOMNamespace("urn:test", "");
    try {
        factory.createOMAttribute("attr", ns, "value");
        fail("Expected IllegalArgumentException");
    } catch (IllegalArgumentException ex) {
        assertEquals("Cannot create an unprefixed attribute with a namespace", ex.getMessage());
    }
}
Also used : OMFactory(org.apache.axiom.om.OMFactory) OMNamespace(org.apache.axiom.om.OMNamespace)

Example 37 with OMNamespace

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

the class TestCreateOMElementWithNonDefaultNamespace method runTest.

@Override
protected void runTest() throws Throwable {
    OMFactory factory = metaFactory.getOMFactory();
    OMElement element = variant.createOMElement(factory, parentSupplier.createParent(factory), "test", "urn:ns", "ns");
    assertTrue(element.isComplete());
    assertEquals("test", element.getLocalName());
    OMNamespace ns = factory.createOMNamespace("urn:ns", "ns");
    assertEquals(ns, element.getNamespace());
    Iterator<OMNamespace> it = element.getAllDeclaredNamespaces();
    assertTrue(it.hasNext());
    assertEquals(ns, it.next());
    assertFalse(it.hasNext());
}
Also used : OMFactory(org.apache.axiom.om.OMFactory) OMNamespace(org.apache.axiom.om.OMNamespace) OMElement(org.apache.axiom.om.OMElement)

Example 38 with OMNamespace

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

the class TestCreateOMElementWithoutNamespaceNullPrefix method runTest.

@Override
protected void runTest() throws Throwable {
    OMFactory factory = metaFactory.getOMFactory();
    OMElement element = variant.createOMElement(factory, parentSupplier.createParent(factory), "test", "", null);
    assertEquals("test", element.getLocalName());
    assertNull(element.getNamespace());
    Iterator<OMNamespace> it = element.getAllDeclaredNamespaces();
    assertFalse(it.hasNext());
}
Also used : OMFactory(org.apache.axiom.om.OMFactory) OMNamespace(org.apache.axiom.om.OMNamespace) OMElement(org.apache.axiom.om.OMElement)

Example 39 with OMNamespace

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

the class TestGetNamespaceURI method runTest.

@Override
protected void runTest() throws Throwable {
    OMFactory factory = metaFactory.getOMFactory();
    OMNamespace ns = factory.createOMNamespace("http://www.w3.org/XML/1998/namespace", "xml");
    assertEquals("http://www.w3.org/XML/1998/namespace", ns.getNamespaceURI());
}
Also used : OMFactory(org.apache.axiom.om.OMFactory) OMNamespace(org.apache.axiom.om.OMNamespace)

Example 40 with OMNamespace

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

the class TestGetPrefix method runTest.

@Override
protected void runTest() throws Throwable {
    OMFactory factory = metaFactory.getOMFactory();
    OMNamespace ns = factory.createOMNamespace("http://www.w3.org/XML/1998/namespace", "xml");
    assertEquals("xml", ns.getPrefix());
    ns = factory.createOMNamespace("", null);
    assertNull(ns.getPrefix());
}
Also used : OMFactory(org.apache.axiom.om.OMFactory) OMNamespace(org.apache.axiom.om.OMNamespace)

Aggregations

OMNamespace (org.apache.axiom.om.OMNamespace)164 OMElement (org.apache.axiom.om.OMElement)101 OMFactory (org.apache.axiom.om.OMFactory)94 QName (javax.xml.namespace.QName)33 SOAPEnvelope (org.apache.axiom.soap.SOAPEnvelope)20 OMAttribute (org.apache.axiom.om.OMAttribute)18 PullOMDataSource (org.apache.axiom.ts.om.sourcedelement.util.PullOMDataSource)16 StringWriter (java.io.StringWriter)15 SOAPHeaderBlock (org.apache.axiom.soap.SOAPHeaderBlock)13 SOAPHeader (org.apache.axiom.soap.SOAPHeader)12 OMSourcedElement (org.apache.axiom.om.OMSourcedElement)9 XMLStreamReader (javax.xml.stream.XMLStreamReader)8 OMText (org.apache.axiom.om.OMText)7 Iterator (java.util.Iterator)6 SOAPBody (org.apache.axiom.soap.SOAPBody)6 StringReader (java.io.StringReader)5 StringOMDataSource (org.apache.axiom.om.ds.StringOMDataSource)5 HashSet (java.util.HashSet)4 OMDataSource (org.apache.axiom.om.OMDataSource)4 OMNode (org.apache.axiom.om.OMNode)4