Examples of ODOMXPath


Examples of com.volantis.mcs.eclipse.common.odom.xpath.ODOMXPath

     */
    public void testRemoveMultiStepGrandchildElement() throws Exception {
        ODOMElement root = (ODOMElement) factory.element("root");
        ODOMElement child = (ODOMElement) factory.element("child");
        ODOMElement grandchild = (ODOMElement) factory.element("grandchild");
        ODOMXPath path = new ODOMXPath("child/grandchild");

        root.addContent(child.addContent(grandchild));

        ODOMObservable deleted = path.remove(root);

        assertNotNull("The deleted grandchild should have been found",
                      deleted);

        assertTrue("The returned node should have been an element",
View Full Code Here

Examples of com.volantis.mcs.eclipse.common.odom.xpath.ODOMXPath

    public void testRemoveMultiStepGrandchildAttribute() throws Exception {
        ODOMElement root = (ODOMElement) factory.element("root");
        ODOMElement child = (ODOMElement) factory.element("child");
        ODOMAttribute grandchild = (ODOMAttribute) factory.attribute(
                "grandchild", "value");
        ODOMXPath path = new ODOMXPath("child/@grandchild");

        root.addContent(child);
        child.setAttribute(grandchild);

        ODOMObservable deleted = path.remove(root);

        assertNotNull("The deleted grandchild should have been found",
                      deleted);

        assertTrue("The returned node should have been an element",
View Full Code Here

Examples of com.volantis.mcs.eclipse.common.odom.xpath.ODOMXPath

     */
    public void testRemoveMultiStepGrandchildText() throws Exception {
        ODOMElement root = (ODOMElement) factory.element("root");
        ODOMElement child = (ODOMElement) factory.element("child");
        ODOMText grandchild = (ODOMText) factory.text("grandchild");
        ODOMXPath path = new ODOMXPath("child/text()");

        root.addContent(child.addContent(grandchild));

        ODOMObservable deleted = path.remove(root);

        assertNotNull("The deleted grandchild should have been found",
                      deleted);

        assertTrue("The returned node should have been an element",
View Full Code Here

Examples of com.volantis.mcs.eclipse.common.odom.xpath.ODOMXPath

            if (node instanceof Element) {
                Element element = (Element) node;
                List attList = element.getAttributes();
                for (int i = 0; attList != null && i < attList.size(); i++) {
                    Attribute attribute = (Attribute) attList.get(i);
                    System.out.println(new ODOMXPath(attribute).getExternalForm() +
                                       "-->" + attribute.getValue());
                }
                children = element.getChildren();
                for (int i = 0; (children != null) && (i < children.size()); i++) {
                    depthFirstTraversal((ODOMObservable) children.get(i));
                }
                List list = ((Element) node).getContent(filter);
                if ((list != null) && (list.size() > 0)) {
                    for (int i = 0; i < list.size(); i++) {
                        Text text = (Text) list.get(i);
                        if (text.getText().trim().length() > 0) {
                            System.out.println(new ODOMXPath(text).getExternalForm() +
                                               "-->" + text.getText());
                        }
                    }
                }
            }
            System.out.println(new ODOMXPath(node).getExternalForm());
        }
    }
View Full Code Here

Examples of com.volantis.mcs.eclipse.common.odom.xpath.ODOMXPath

    /**
     * Test the equals method for reflexive, symmetric, transitive and null
     * comparisons (amongst others).
     */
    public void testExternalFormsEqual() throws Exception {
        ODOMXPath xpath1 = new ODOMXPath(".");
        ODOMXPath xpath2 = new ODOMXPath(".");
        ODOMXPath xpath3 = new ODOMXPath(".");
        ODOMXPath xpath4 = new ODOMXPath("catalog");

        // Reflexive.
        assertTrue(xpath1.externalFormsEqual(xpath1));

        // Symmetric
        assertTrue(xpath1.externalFormsEqual(xpath2));
        assertTrue(xpath2.externalFormsEqual(xpath1));

        // Transitive
        assertTrue(xpath1.externalFormsEqual(xpath2));
        assertTrue(xpath2.externalFormsEqual(xpath3));
        assertTrue(xpath1.externalFormsEqual(xpath3));

        // Null value.
        assertFalse(xpath1.externalFormsEqual(null));

        // Not equals
        assertFalse(xpath1.externalFormsEqual(xpath4));
        assertFalse(xpath4.externalFormsEqual(xpath1));
        assertFalse(xpath2.externalFormsEqual(xpath4));
    }
View Full Code Here

Examples of com.volantis.mcs.eclipse.common.odom.xpath.ODOMXPath

        Namespace namespaces[] = {
            Namespace.getNamespace(prefix, uri)
        };

        final ODOMXPath xpath = new ODOMXPath(ns + "staff/" + ns + "director",
                                      namespaces);
        final Element child = doc.getRootElement().getChild("company",
                                                            namespaces[0]);

        List elements;
        if (isODOMObservable) {
            elements = xpath.selectNodes(child);
        } else {
            elements = xpath.selectNodes(child);
        }
        assertEquals("Number of elements should match", 1, elements.size());
        assertEquals("Name should match", "bert",
                     ((Element) elements.get(0)).getAttributeValue(
                             "directorName"));
View Full Code Here

Examples of com.volantis.mcs.eclipse.common.odom.xpath.ODOMXPath

     * Tests the {@link ODOMXPath#getParentStr} method
     *
     * @throws Exception if an error occurs
     */
    public void testGetParentStr() throws Exception {
        ODOMXPath path = new ODOMXPath("/lpdm:a/lpdm:b/@c",
                               new Namespace[]{MCSNamespace.LPDM});

        assertEquals("parent not as", "/lpdm:a/lpdm:b", path.getParentStr());
    }
View Full Code Here

Examples of com.volantis.mcs.eclipse.common.odom.xpath.ODOMXPath

     * have a parent
     *
     * @throws Exception if an error occurs
     */
    public void testGetParentStrWhenNoParent() throws Exception {
        ODOMXPath path = new ODOMXPath("lpdm:b",
                               new Namespace[]{MCSNamespace.LPDM});

        assertEquals("parent not as ", null, path.getParentStr());
    }
View Full Code Here

Examples of com.volantis.mcs.eclipse.common.odom.xpath.ODOMXPath

     *
     * @throws Exception if an error occurs
     */
    public void testGetParentStrWhenNoParentAndAbsolutePath()
            throws Exception {
        ODOMXPath path = new ODOMXPath("/lpdm:a",
                               new Namespace[]{MCSNamespace.LPDM});

        assertEquals("parent not as ", null, path.getParentStr());
    }
View Full Code Here

Examples of com.volantis.mcs.eclipse.common.odom.xpath.ODOMXPath

     * a parent
     *
     * @throws Exception if an error occurs
     */
    public void testGetParentWhenNoParent() throws Exception {
        ODOMXPath path = new ODOMXPath("lpdm:b",
                               new Namespace[]{MCSNamespace.LPDM});

        assertEquals("parent not as ", null, path.getParent());
    }
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.