Package org.apache.axiom.om

Examples of org.apache.axiom.om.OMElement.declareNamespace()


    }

    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


    public void testDualNamespaces2() throws Exception {
        OMFactory factory = OMAbstractFactory.getOMFactory();
        OMNamespace ns1 = factory.createOMNamespace("bar", "x");
        OMElement root = factory.createOMElement("root", ns1);
        OMNamespace ns2 = root.declareNamespace("bar", "y");
        OMElement elt1 = factory.createOMElement("foo", ns1);
        OMElement elt2 = factory.createOMElement("yuck", ns2);
        OMText txt1 = factory.createOMText(elt2, "blah");
        elt2.addChild(txt1);
        elt1.addChild(elt2);
View Full Code Here

    protected void runTest() throws Throwable {
        OMFactory factory = metaFactory.getOMFactory();
        OMElement element = factory.createOMElement(new QName("test"));
        OMNamespace ns = factory.createOMNamespace("urn:ns", "p");
        element.declareNamespace(ns);
        OMAttribute att = factory.createOMAttribute("test", ns, "test");
        element.addAttribute(att);
        Iterator it = element.getAllDeclaredNamespaces();
        assertTrue(it.hasNext());
        assertEquals(ns, it.next());
View Full Code Here

    protected void runTest() throws Throwable {
        OMFactory factory = metaFactory.getOMFactory();
       
        // Create a root element on which we declare the namespaces
        OMElement root = factory.createOMElement("root", null);
        OMNamespace ns1 = root.declareNamespace("urn:ns1", "ns1");
        OMNamespace ns2 = root.declareNamespace("urn:ns2", "ns2");
        root.declareNamespace("urn:ns3", "ns3");
       
        // Create a child that uses these namespaces (in the element name and in the name of an attribute)
        OMElement child = factory.createOMElement("child", ns1, root);
View Full Code Here

        OMFactory factory = metaFactory.getOMFactory();
       
        // Create a root element on which we declare the namespaces
        OMElement root = factory.createOMElement("root", null);
        OMNamespace ns1 = root.declareNamespace("urn:ns1", "ns1");
        OMNamespace ns2 = root.declareNamespace("urn:ns2", "ns2");
        root.declareNamespace("urn:ns3", "ns3");
       
        // Create a child that uses these namespaces (in the element name and in the name of an attribute)
        OMElement child = factory.createOMElement("child", ns1, root);
        child.addAttribute("attr", "value", ns2);
View Full Code Here

       
        // Create a root element on which we declare the namespaces
        OMElement root = factory.createOMElement("root", null);
        OMNamespace ns1 = root.declareNamespace("urn:ns1", "ns1");
        OMNamespace ns2 = root.declareNamespace("urn:ns2", "ns2");
        root.declareNamespace("urn:ns3", "ns3");
       
        // Create a child that uses these namespaces (in the element name and in the name of an attribute)
        OMElement child = factory.createOMElement("child", ns1, root);
        child.addAttribute("attr", "value", ns2);
       
View Full Code Here

    protected void runTest() throws Throwable {
        OMFactory factory = metaFactory.getOMFactory();
        OMElement root = factory.createOMElement(new QName("test"));
        OMNamespace ns = factory.createOMNamespace("urn:ns", "p");
        root.declareNamespace(ns);
        OMElement child = factory.createOMElement(new QName("test"), root);
        OMAttribute att = factory.createOMAttribute("test", ns, "test");
        child.addAttribute(att);
        Iterator it = child.getAllDeclaredNamespaces();
        assertFalse(it.hasNext());
View Full Code Here

    }

    protected void runTest() throws Throwable {
        OMFactory factory = metaFactory.getOMFactory();
        OMElement element = factory.createOMElement("test", null);
        element.declareNamespace("urn:a", "a");
        element.declareNamespace("urn:b", "b");
        element.declareNamespace("urn:c", "c");
        for (Iterator it = element.getAllDeclaredNamespaces(); it.hasNext(); ) {
            OMNamespace ns = (OMNamespace)it.next();
            if (ns.getPrefix().equals("b")) {
View Full Code Here

    protected void runTest() throws Throwable {
        OMFactory factory = metaFactory.getOMFactory();
        OMElement element = factory.createOMElement("test", null);
        element.declareNamespace("urn:a", "a");
        element.declareNamespace("urn:b", "b");
        element.declareNamespace("urn:c", "c");
        for (Iterator it = element.getAllDeclaredNamespaces(); it.hasNext(); ) {
            OMNamespace ns = (OMNamespace)it.next();
            if (ns.getPrefix().equals("b")) {
                it.remove();
View Full Code Here

    protected void runTest() throws Throwable {
        OMFactory factory = metaFactory.getOMFactory();
        OMElement element = factory.createOMElement("test", null);
        element.declareNamespace("urn:a", "a");
        element.declareNamespace("urn:b", "b");
        element.declareNamespace("urn:c", "c");
        for (Iterator it = element.getAllDeclaredNamespaces(); it.hasNext(); ) {
            OMNamespace ns = (OMNamespace)it.next();
            if (ns.getPrefix().equals("b")) {
                it.remove();
                break;
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.