Package org.apache.axiom.om

Examples of org.apache.axiom.om.OMNamespace


public class OMChildrenWithSpecificAttributeIteratorTest extends TestCase {
    public void testChildrenRetrievalWithDetaching() {

        OMFactory factory = OMAbstractFactory.getOMFactory();
        OMNamespace testNamespace = factory.createOMNamespace("http://test.ws.org", "test");
        OMElement documentElement = getSampleDocumentElement(testNamespace);

        Iterator childrenIter = new OMChildrenWithSpecificAttributeIterator(
                documentElement.getFirstOMChild(),
                new QName(testNamespace.getNamespaceURI(), "myAttr",
                          testNamespace.getPrefix()), "Axis2", true);

        int childCount = getChidrenCount(childrenIter);
        assertEquals("Iterator must return 5 children with the given attribute", childCount, 5);

        Iterator children = documentElement.getChildren();
View Full Code Here


    }

    public void testChildrenRetrievalWithNoDetaching() {

        OMFactory factory = OMAbstractFactory.getOMFactory();
        OMNamespace testNamespace = factory.createOMNamespace("http://test.ws.org", "test");
        OMElement documentElement = getSampleDocumentElement(testNamespace);

        Iterator childrenIter = new OMChildrenWithSpecificAttributeIterator(
                documentElement.getFirstOMChild(),
                new QName(testNamespace.getNamespaceURI(), "myAttr",
                          testNamespace.getPrefix()), "Axis2", false);

        int childCount = getChidrenCount(childrenIter);
        assertEquals("Iterator must return 5 children with the given attribute", childCount, 5);

        Iterator children = documentElement.getChildren();
View Full Code Here

    protected void runTest() throws Throwable {
        OMFactory factory = metaFactory.getOMFactory();
        OMElement element = factory.createOMElement("test", "urn:test", "");
        // Retrieve the namespace declaration generated by createOMElement
        OMNamespace ns = (OMNamespace)element.getAllDeclaredNamespaces().next();
        OMAttribute att = factory.createOMAttribute("test", null, "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();
        OMElement parent = factory.createOMElement("parent", "urn:ns1", "");
        OMElement child = factory.createOMElement(new QName("urn:ns2", "child", "p"), parent);
        OMNamespace ns = child.getDefaultNamespace();
        assertNotNull(ns);
        assertEquals("", ns.getPrefix());
        assertEquals("urn:ns1", ns.getNamespaceURI());
    }
View Full Code Here

        // Create a PEDS with the indicated behavior
        ParserInputStreamDataSource peds = new ParserInputStreamDataSource(is, "UTF-8", behavior);
       
        // Create a OM tree with a root that contains an OMSourcedElement with a PADS
        OMFactory factory = OMAbstractFactory.getOMFactory();
        OMNamespace ns = factory.createOMNamespace("urn://sample", "my");
        OMElement om = factory.createOMElement(peds, "payload", ns);
       
        QName rootQName = new QName("urn://root", "root", "pre");
        OMElement root = factory.createOMElement(rootQName);
        root.addChild(om);
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");
        OMAttribute att = factory.createOMAttribute("test", ns, "test");
        element.addAttribute(att);
        assertEquals(ns, element.findNamespace(ns.getNamespaceURI(), ns.getPrefix()));
        Iterator it = element.getAllDeclaredNamespaces();
        assertTrue(it.hasNext());
        assertEquals(ns, it.next());
        assertFalse(it.hasNext());
    }
View Full Code Here

            if (!(parent instanceof OMElement)) {
                return;
            }
            current = (OMElement)parent;
            for (Iterator it = current.getAllDeclaredNamespaces(); it.hasNext(); ) {
                OMNamespace ns = (OMNamespace)it.next();
                if (seenPrefixes.add(ns.getPrefix())) {
                    generatePrefixMappingEvents(ns, start);
                }
            }
        }
    }
View Full Code Here

        }
    }
   
    private void generateEvents(OMElement omElement) throws SAXException {
        generatePrefixMappingEvents(omElement, true);
        OMNamespace omNamespace = omElement.getNamespace();
        String uri;
        String prefix;
        if (omNamespace != null) {
            uri = omNamespace.getNamespaceURI();
            prefix = omNamespace.getPrefix();
        } else {
            uri = "";
            prefix = null;
        }
        String localName = omElement.getLocalName();
View Full Code Here

    protected void runTest() throws Throwable {
        OMElement element = AXIOMUtil.stringToOM(metaFactory.getOMFactory(),
                "<a xmlns:p='urn:ns1'><b xmlns:p='urn:ns2'/></a>");
        Iterator it = element.getFirstElement().getNamespacesInScope();
        assertTrue(it.hasNext());
        OMNamespace ns = (OMNamespace)it.next();
        assertEquals("p", ns.getPrefix());
        assertEquals("urn:ns2", ns.getNamespaceURI());
        assertFalse(it.hasNext());
    }
View Full Code Here

    protected void runTest() throws Throwable {
        OMFactory f = metaFactory.getOMFactory();

        // Create OMSE with an unknown prefix
        OMNamespace rootNS = f.createOMNamespace("http://sampleroot", "rootPrefix");
        OMNamespace ns = f.createOMNamespace("http://www.sosnoski.com/uwjws/library", null);
        OMElement element =
                f.createOMElement(new TestDataSource(testDocument2), "library", ns);
        OMElement root = f.createOMElement("root", rootNS);
        root.addChild(element);
View Full Code Here

TOP

Related Classes of org.apache.axiom.om.OMNamespace

Copyright © 2018 www.massapicom. 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.