Package com.volantis.mcs.eclipse.common.odom.xpath

Examples of com.volantis.mcs.eclipse.common.odom.xpath.ODOMXPath.create()


                     new ODOMXPath(newNode).getExternalForm());

        // Test creation of single additional step
        path = new ODOMXPath("a/text()");

        newNode = path.create(context, factory);

        assertTrue("New node not text (is a " +
                   newNode.getClass().getName() + ")",
                   newNode instanceof Text);
View Full Code Here


        // This should cause the creation of a second page with a number
        // attribute
        ODOMXPath path = new ODOMXPath("catalogue/page[2]/@number");

        ODOMObservable newNode = path.create((ODOMElement) root, factory);

        assertTrue("New node not an attribute (is a " +
                   newNode.getClass().getName() + ")",
                   newNode instanceof Attribute);
View Full Code Here

        // This should cause the creation of a new item with nested name
        // element
        path = new ODOMXPath("catalogue/page[2]/item/name");

        newNode = path.create((ODOMElement) root, factory);

        assertTrue("New node not an element (is a " +
                   newNode.getClass().getName() + ")",
                   newNode instanceof Element);
View Full Code Here

        // This should cause the creation of a text node within the previously
        // created item's name element
        path = new ODOMXPath(path, "text()");

        newNode = path.create((ODOMElement) root, factory);

        assertTrue("New node not a text (is a " +
                   newNode.getClass().getName() + ")",
                   newNode instanceof Text);
View Full Code Here

    public void testCreateWithAbsolutePath() throws Exception {
        ODOMXPath path = new ODOMXPath("/catalog/cd[6]/title/text()");

        // This should cause the creation of CD nodes 5 and 6 and a title
        // node within CD 6 with a nested text node
        ODOMObservable newNode = path.create((ODOMElement) root, factory);

        assertTrue("New CD title text not a text (is a " +
                   newNode.getClass().getName() + ")",
                   newNode instanceof Text);
View Full Code Here

        // This will demonstrate invalid application of an absolute path
        // (the context is not appropriate to the absolute path because its
        // name doesn't match the first step in the absolute path)
        try {
            ODOMElement cd = (ODOMElement) root.getChild("cd");
            path.create(cd, factory);

            fail("Should have received an XPathException");
        } catch (XPathException e) {
            // Expected condition
        }
View Full Code Here

     */
    public void testCreateSimple() throws Exception {
        // Check when element does not exist.
        String elementName = "newElement";
        ODOMXPath path = new ODOMXPath(elementName);
        ODOMObservable result = path.create((ODOMElement) root, factory);
        assertNotNull("Result should not be null", result);
        assertTrue("Type should match", result instanceof Element);
        assertEquals("Value should match", elementName,
                     ((Element) result).getName());

View Full Code Here

        assertEquals("Value should match", elementName,
                     ((Element) result).getName());

        // Check when attribute does not exist.
        path = new ODOMXPath("newElement/@attribute");
        result = path.create((ODOMElement) root, factory);
        assertNotNull("Result should not be null", result);
        assertTrue("Type should match", result instanceof Attribute);
        assertEquals("Value should match", "attribute",
                     ((Attribute) result).getName());
        assertEquals("Value should match", "",
View Full Code Here

        assertEquals("Value should match", "",
                     ((Attribute) result).getValue());

        // Check when text does not exist.
        path = new ODOMXPath("newElement/text()");
        result = path.create((ODOMElement) root, factory);

        assertNotNull("Result should not be null", result);
        assertTrue("Type should match", result instanceof Text);
        assertEquals("Value should match", "",
                     ((Text) result).getText());
View Full Code Here

        // Check when element does not exist.
        String elementName = "ns1:newElement/notNamespaced/ns1:namespaced";
        ODOMXPath path = new ODOMXPath(elementName);
        ODOMObservable result = null;
        try {
            result = path.create((ODOMElement) root, factory);
            fail("Expected IllegalStateException (no namespaces set)");
        } catch (IllegalStateException e) {
        }
        path = new ODOMXPath(elementName, NAMESPACES);
        result = path.create((ODOMElement) root, factory);
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.