Package org.apache.axiom.om

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


        OMFactory factory = OMAbstractFactory.getOMFactory();
        OMNamespace ns = factory.createOMNamespace("http://www.me.com", "axiom");

        //code line to be tested
        OMAttribute at = factory.createOMAttribute("id", ns, "value");
        doc.addAttribute(at);

        return doc.toString();
    }
View Full Code Here


    public void testImportOMAttribute() {
        //Convert from OM to DOOM.
        OMFactory omf = OMAbstractFactory.getOMFactory();
        OMNamespace ns1 = omf.createOMNamespace("http://nsurl", "prefix");
        OMAttribute attr1 = omf.createOMAttribute("attr1", ns1, "attr1value");

        OMFactory doomf = OMAbstractFactory.getMetaFactory(OMAbstractFactory.FEATURE_DOM).getOMFactory();
        OMElement ome1 = doomf.createOMElement("element", ns1.getNamespaceURI(), ns1.getPrefix());
        AttributeHelper.importOMAttribute(attr1, ome1);
        assertNotSame(attr1, ome1.getAttribute(attr1.getQName()));
View Full Code Here

        assertEquals(attr1.getAttributeValue(),
                     ome1.getAttribute(attr1.getQName()).getAttributeValue());

        //Convert from DOOM to OM.
        OMNamespace ns2 = doomf.createOMNamespace("http://nsurl", "prefix");
        OMAttribute attr2 = doomf.createOMAttribute("attr2", ns2, "attr2value");

        OMElement ome2 = omf.createOMElement("element", ns2.getNamespaceURI(), ns2.getPrefix());
        AttributeHelper.importOMAttribute(attr2, ome2);
        assertNotSame(attr2, ome2.getAttribute(attr2.getQName()));
        assertEquals(attr2.getAttributeValue(),
View Full Code Here

        AttributeHelper.importOMAttribute(attr3, ome3);
        assertSame(attr3, ome3.getAttribute(attr3.getQName()));

        //DOOM only.
        OMNamespace ns4 = doomf.createOMNamespace("http://nsurl", "prefix");
        OMAttribute attr4 = doomf.createOMAttribute("attr4", ns4, "attr4value");

        OMElement ome4 = doomf.createOMElement("element", ns4.getNamespaceURI(), ns4.getPrefix());
        AttributeHelper.importOMAttribute(attr4, ome4);
        assertSame(attr4, ome4.getAttribute(attr4.getQName()));
    }
View Full Code Here

        OMNamespace mime = fac.createOMNamespace(
                "http://www.w3.org/2003/06/xmlmime", "mime");

        OMElement text = fac.createOMElement("name", dataName);
        OMAttribute cType1 = fac.createOMAttribute("contentType", mime,
                                                 "text/plain");
        text.addAttribute(cType1);
        byte[] byteArray = new byte[] { 13, 56, 65, 32, 12, 12, 7, -3, -2, -1,
                98 };
        dataHandler = new DataHandler(new ByteArrayDataSource(byteArray));
View Full Code Here

        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

        OMFactory factory = metaFactory.getOMFactory();
        // Use same namespace URI but different prefixes
        OMNamespace ns1 = factory.createOMNamespace("urn:ns", "p1");
        OMNamespace ns2 = factory.createOMNamespace("urn:ns", "p2");
        OMElement element = factory.createOMElement(new QName("test"));
        OMAttribute att1 = factory.createOMAttribute("test", ns1, "test");
        OMAttribute att2 = factory.createOMAttribute("test", ns2, "test");
        element.addAttribute(att1);
        element.addAttribute(att2);
        Iterator it = element.getAllAttributes();
        assertTrue(it.hasNext());
View Full Code Here

        // Use same namespace URI but different prefixes
        OMNamespace ns1 = factory.createOMNamespace("urn:ns", "p1");
        OMNamespace ns2 = factory.createOMNamespace("urn:ns", "p2");
        OMElement element = factory.createOMElement(new QName("test"));
        OMAttribute att1 = factory.createOMAttribute("test", ns1, "test");
        OMAttribute att2 = factory.createOMAttribute("test", ns2, "test");
        element.addAttribute(att1);
        element.addAttribute(att2);
        Iterator it = element.getAllAttributes();
        assertTrue(it.hasNext());
        assertSame(att2, it.next());
View Full Code Here

        OMNamespace attrNS1 =
                omFactory.createOMNamespace("http://test-attributes-1.org", "myAttr1NS");
        OMNamespace attrNS2 =
                omFactory.createOMNamespace("http://test-attributes-2.org", "myAttr2NS");
        OMElement omElement = omFactory.createOMElement("AttributeTester", null);
        omElement.addAttribute(omFactory.createOMAttribute("attrNumber", attrNS1, "1"));
        omElement.addAttribute(omFactory.createOMAttribute("attrNumber", attrNS2, "2"));
   
        int nsCount = 0;
        for (Iterator iterator = omElement.getAllDeclaredNamespaces(); iterator.hasNext();) {
            iterator.next();
View Full Code Here

                omFactory.createOMNamespace("http://test-attributes-1.org", "myAttr1NS");
        OMNamespace attrNS2 =
                omFactory.createOMNamespace("http://test-attributes-2.org", "myAttr2NS");
        OMElement omElement = omFactory.createOMElement("AttributeTester", null);
        omElement.addAttribute(omFactory.createOMAttribute("attrNumber", attrNS1, "1"));
        omElement.addAttribute(omFactory.createOMAttribute("attrNumber", attrNS2, "2"));
   
        int nsCount = 0;
        for (Iterator iterator = omElement.getAllDeclaredNamespaces(); iterator.hasNext();) {
            iterator.next();
            nsCount++;
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.