Package nu.xom

Examples of nu.xom.Document.query()


        doc.insertChild(p1, 0);
        grandparent.insertChild(p2, 0);
        parent.insertChild(p3, 0);
        child.insertChild(p4, 0);
       
        Nodes result = doc.query("descendant::processing-instruction()[.='3']");
        assertEquals(1, result.size());
        assertEquals(p3, result.get(0));
       
    }
   
View Full Code Here


        ProcessingInstruction pi = new ProcessingInstruction("appendix", "text");
        doc.appendChild(pi);
        ProcessingInstruction pi2 = new ProcessingInstruction("test", "text");
        parent.appendChild(pi2);
       
        Nodes result = doc.query("descendant::processing-instruction('test')");
        assertEquals(1, result.size());
        assertEquals(pi2, result.get(0));
       
    }
   
View Full Code Here

        parent.appendChild(child1);
        parent.appendChild(child2);
        parent.appendChild(child3);
        Document doc = new Document(parent);
       
        Nodes result = doc.query("id('anchor')");
        assertEquals(1, result.size());    
        assertEquals(child2, result.get(0));
       
    }
   
View Full Code Here

    public void testNaNEvaluatesToFalse() {
       
        Element root = new Element("root");
        Document doc = new Document(root);
       
        Nodes result = doc.query("/*[boolean(0 div 0)]");
        assertEquals(0, result.size());
       
    }
   
   
View Full Code Here

     
         Element root = new Element("html");
         Document doc = new Document(root);
         root.appendChild("test");
        
         Nodes result = doc.query("/*[string(/) != '']");
         assertEquals(1, result.size());
         assertEquals(root, result.get(0));
        
     }
   
View Full Code Here

             + "</servlet-mapping>\n</root>";
        
         Builder builder = new Builder();
         Document doc = builder.build(data, null);
        
         Nodes result = doc.query("//*[./../servlet-name = 'DeviceInfoServlet']");
         assertEquals(2, result.size());
      
     }        


View Full Code Here

            + "   </e1>\n"
            + "</doc>";
       
        Document doc = (new Builder()).build(input, null);
        String xpath = "(/*/* | /*/*/namespace::*)\n";
        Nodes result = doc.query(xpath);
        assertEquals(4, result.size());
        Element parent = (Element) result.get(0);
        for (int i = 1; i < 4; i++) {
            Namespace namespace = (Namespace) result.get(i);
            assertEquals(parent, namespace.getParent());
View Full Code Here

            + "   </e1>\n"
            + "</document>";
       
        Document doc = (new Builder()).build(input, null);
        String xpath = "(/*/* | /*/*/attribute::*)\n";
        Nodes result = doc.query(xpath);
        assertEquals(4, result.size());
        Element parent = (Element) result.get(0);
        for (int i = 1; i < 4; i++) {
            Attribute attribute = (Attribute) result.get(i);
            assertEquals(parent, attribute.getParent());
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

        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

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.