Package nu.xom

Examples of nu.xom.Element.query()


    public void testParentAxisWithNodeMatchingDocument() {
       
        Element root = new Element("Test");
        Document doc = new Document(root);
       
        Nodes result = root.query("parent::node()");
        assertEquals(1, result.size());
        assertEquals(doc, result.get(0));
       
    }
   
View Full Code Here


    public void testSubstringFunction() {
       
        Element root = new Element("Test");
        new Document(root);
       
        Nodes result = root.query("/*[substring('12345', 0, 3)='12']");
        assertEquals(1, result.size());
        assertEquals(root, result.get(0));
       
    }
   
View Full Code Here

   
    public void testGetNamespaceStringValue() {
       
        Element test = new Element("Test", "http://www.example.com/");
       
        Nodes result = test.query("self::*[contains(namespace::*, 'http://')]");
        assertEquals(1, result.size());
        assertEquals(test, result.get(0));
       
    }
   
View Full Code Here

       
        Element element = new Element("test");
        File f = new File(inputDir, "prettyxml.xml");
        String url = f.toURL().toExternalForm();
        try {
            element.query("document('" + url + "')/*");
            fail("allowed document() function");
        }
        catch(XPathException success) {
            assertTrue(success.getMessage().indexOf("document") >= 0);
        }
View Full Code Here

       
        Element element = new Element("test");
        File f = new File(inputDir, "prettyxml.xml");
        String url = f.toURL().toExternalForm();
        try {
            element.query("document('" + url + "')//*");
            fail("allowed document() function");
        }
        catch(XPathException success) {
            assertTrue(success.getMessage().indexOf("document") >= 0);
        }
View Full Code Here

        File f1 = new File(inputDir, "prettyxml.xml");
        String url1 = f1.toURL().toExternalForm();
        File f2 = new File(inputDir, "test.xml");
        String url2 = f2.toURL().toExternalForm();
        try {
            element.query("document('" + url1 + "')/* | "
              + "document('" + url2 + "')/*");
            fail("allowed document() function");
        }
        catch(XPathException success) {
            assertTrue(success.getMessage().indexOf("document") >= 0);
View Full Code Here

    public void testGetNonExistentDocument() {
       
        Element element = new Element("test");
        try {
            element.query("document('http://www.ibiblio.org/aksdjhk/')/*");
            fail("That file doesn't exist!");
        }
        catch (XPathException success) {
            assertNotNull(success.getMessage());
        }
View Full Code Here

    public void testMalformedDocument() {
       
        Element element = new Element("test");
        try {
            element.query("document('http://www.cafeaulait.org/formatter/Formatter.java')/*");
            fail("Queried malformed document!");
        }
        catch (XPathException success) {
            assertNotNull(success.getMessage());
        }
View Full Code Here

    public void testGetDocumentNode() {
       
        Element element = new Element("test");
        Document doc = new Document(element);
        Nodes result = element.query("/");
        assertEquals(1, result.size());
        assertEquals(doc, result.get(0));
       
    }
   
View Full Code Here

        Element parent = new Element("Test");
        Element child = new Element("child");
        parent.appendChild(child);
        grandparent.appendChild(parent);
       
        Nodes result = child.query("ancestor-or-self::*");
        assertEquals(3, result.size());
        assertEquals(child, result.get(2));  
        assertEquals(parent, result.get(1));  
        assertEquals(grandparent, 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.