Package org.apache.axiom.om

Examples of org.apache.axiom.om.OMFactory.createOMElement()


        // In order to not break existing code, this should return 2
        qName = new QName("", "sample");
        assertTrue(getChildrenCount(documentElement.getChildrenWithName(qName)) == 2);
       
        // Now add an unqualified sample element to the documentElement
        factory.createOMElement("sample", null, documentElement);
       
       
        // Repeat the tests
        qName = new QName(NS_A, "sample");
        assertTrue(getChildrenCount(documentElement.getChildrenWithName(qName)) == 1);
View Full Code Here


        super(metaFactory);
    }

    protected void runTest() throws Throwable {
        OMFactory factory = metaFactory.getOMFactory();
        OMElement element = factory.createOMElement(new QName("test"));
        assertNull(element.getNamespaceURI());
    }
}
View Full Code Here

        super(metaFactory);
    }

    protected void runTest() throws Throwable {
        OMFactory factory = metaFactory.getOMFactory();
        OMElement element = factory.createOMElement("test", null);
        OMAttribute attr1 = factory.createOMAttribute("attr", null, "value1");
        OMAttribute attr2 = factory.createOMAttribute("attr", null, "value2");
        OMAttribute attr = element.addAttribute(attr1);
        assertSame(attr1, attr);
        attr = element.addAttribute(attr2);
View Full Code Here

        super(metaFactory);
    }

    protected void runTest() throws Throwable {
        OMFactory factory = metaFactory.getOMFactory();
        OMElement element = factory.createOMElement("test", null);
        try {
            element.declareDefaultNamespace("urn:test");
            fail("Expected OMException");
        } catch (OMException ex) {
            // Expected
View Full Code Here

        super(metaFactory);
    }

    protected void runTest() throws Throwable {
        OMFactory factory = metaFactory.getOMFactory();
        OMElement parent = factory.createOMElement("parent", null);
        parent.declareNamespace("urn:ns", "p");
        OMElement child = factory.createOMElement("child", null, parent);
        child.setText("p:value");
        QName textAsQName = child.getTextAsQName();
        assertEquals(new QName("urn:ns", "value"), textAsQName);
View Full Code Here

    protected void runTest() throws Throwable {
        OMFactory factory = metaFactory.getOMFactory();
        OMElement parent = factory.createOMElement("parent", null);
        parent.declareNamespace("urn:ns", "p");
        OMElement child = factory.createOMElement("child", null, parent);
        child.setText("p:value");
        QName textAsQName = child.getTextAsQName();
        assertEquals(new QName("urn:ns", "value"), textAsQName);
        assertEquals("p", textAsQName.getPrefix());
    }
View Full Code Here

        super(metaFactory);
    }

    protected void runTest() throws Throwable {
        OMFactory factory = metaFactory.getOMFactory();
        OMElement element = factory.createOMElement("test", "urn:test", "p");
        element.setNamespace(null);
        assertNull(element.getNamespace());
        assertEquals(new QName("test"), element.getQName());
    }
}
View Full Code Here

    public void testDualNamespaces1() throws Exception {
        OMFactory factory = OMAbstractFactory.getOMFactory();
        OMNamespace ns1 = factory.createOMNamespace("bar", "x");
        OMNamespace ns2 = factory.createOMNamespace("bar", "y");
        OMElement root = factory.createOMElement("root", ns1);
        OMElement elt11 = factory.createOMElement("foo1", ns1);
        OMElement elt12 = factory.createOMElement("foo2", ns1);
        OMElement elt21 = factory.createOMElement("yuck", ns2);
        OMElement elt22 = factory.createOMElement("yuck", ns2);
        elt11.addChild(elt21);
View Full Code Here

    public void testDualNamespaces1() throws Exception {
        OMFactory factory = OMAbstractFactory.getOMFactory();
        OMNamespace ns1 = factory.createOMNamespace("bar", "x");
        OMNamespace ns2 = factory.createOMNamespace("bar", "y");
        OMElement root = factory.createOMElement("root", ns1);
        OMElement elt11 = factory.createOMElement("foo1", ns1);
        OMElement elt12 = factory.createOMElement("foo2", ns1);
        OMElement elt21 = factory.createOMElement("yuck", ns2);
        OMElement elt22 = factory.createOMElement("yuck", ns2);
        elt11.addChild(elt21);
        elt12.addChild(elt22);
View Full Code Here

        OMFactory factory = OMAbstractFactory.getOMFactory();
        OMNamespace ns1 = factory.createOMNamespace("bar", "x");
        OMNamespace ns2 = factory.createOMNamespace("bar", "y");
        OMElement root = factory.createOMElement("root", ns1);
        OMElement elt11 = factory.createOMElement("foo1", ns1);
        OMElement elt12 = factory.createOMElement("foo2", ns1);
        OMElement elt21 = factory.createOMElement("yuck", ns2);
        OMElement elt22 = factory.createOMElement("yuck", ns2);
        elt11.addChild(elt21);
        elt12.addChild(elt22);
        root.addChild(elt11);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.