Package nu.xom

Examples of nu.xom.Document.query()


        root.appendChild(new Element("child"));
        root.appendChild("test");
        root.addAttribute(new Attribute("test", "test"));
       
        try {
            doc.query("//");
            fail("Queried //");
        }
        catch (XPathException success) {
            assertNotNull(success.getMessage());
        }
View Full Code Here


        root.appendChild(new Element("child"));
        root.appendChild("test");
        root.addAttribute(new Attribute("test", "test"));
       
        try {
            doc.query("// ");
            fail("Queried // ");
        }
        catch (XPathException success) {
            assertNotNull(success.getMessage());
        }
View Full Code Here

        Document doc = new Document(root);
        root.appendChild(new Element("child"));
        root.appendChild("test");
        root.addAttribute(new Attribute("test", "test"));
       
        Nodes nodes = doc.query("// a");
        assertEquals(0, nodes.size());
       
    }
   
   
View Full Code Here

                // XPath expressions
                if (queryUsesVars(contextElement)) continue;
               
                String xpath = contextElement.getAttributeValue("select");
                XPathContext namespaces = getXPathContext(contextElement);
                Node context = source.query(xpath).get(0);
               
                // process counts
                Elements tests = contextElement.getChildElements("test");
                for (int k = 0; k < tests.size(); k++) {
                    Element test = tests.get(k);
View Full Code Here

        name.appendChild("a");
        item.appendChild(name);
        Element value = new Element("value");
        value.appendChild("b");
        item.appendChild(value);
        Nodes result = doc.query("/item[name/text()='a']/value");
        assertEquals(1, result.size());
        assertEquals("b", result.get(0).getValue());
       
    }
View Full Code Here

    public void testSimpleTextChildInPredicate() {
       
        Element item = new Element("item");
        Document doc = new Document(item);
        item.appendChild("a");
        Nodes result = doc.query("/item[text()='a']");
        assertEquals(1, result.size());
       
    }
   
   
View Full Code Here

        child2.appendChild("bar");
        parent.appendChild(child1);
        parent.appendChild(child2);
        grandparent.appendChild(parent);
       
        Nodes result = doc.query("/Test/Test/*[12]");
        assertEquals(0, result.size());
       
    }
   

View Full Code Here

        Attribute a2 = new Attribute("pre:attribute", "http://www.example.com/", "test");
        parent.addAttribute(a2);
        grandparent.addAttribute(a1);
        grandparent.appendChild(parent);
       
        Nodes result = doc.query("descendant::*/attribute::*[name(.)='pre:attribute']");
        assertEquals(2, result.size());
        assertTrue(result.contains(a1));  
        assertTrue(result.contains(a2));
       
    }
View Full Code Here

        doc.insertChild(c1, 0);
        grandparent.insertChild(c2, 0);
        parent.insertChild(c3, 0);
        child.insertChild(c4, 0);
       
        Nodes result = doc.query("descendant::comment()");
        assertEquals(4, result.size());
        assertEquals(c1, result.get(0));  
        assertEquals(c2, result.get(1));
        assertEquals(c3, result.get(2));
        assertEquals(c4, result.get(3));
View Full Code Here

        doc.insertChild(c1, 0);
        grandparent.insertChild(c2, 0);
        parent.insertChild(c3, 0);
        child.insertChild(c4, 0);
       
        Nodes result = doc.query("descendant::comment()[.='c3']");
        assertEquals(1, result.size());
        assertEquals(c3, result.get(0));
       
    }
   
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.