Package nu.xom

Examples of nu.xom.Element


    }
   
   
    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


</p>
<div></div>
</body> */
     public void testPrecedingAxis() {
     
         Element body = new Element("body");
         Element p = new Element("p");
         body.appendChild(p);
         Element span = new Element("span");
         p.appendChild(span);
         Element div = new Element("div");
         body.appendChild(div);
        
         Nodes result = div.query("preceding::*[1]");
         assertEquals(1, result.size());
         assertEquals(span, result.get(0));
        
     }
View Full Code Here

     }
   
   
     public void testRootNodeValueIsNonEmpty() {
     
         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

     }
   
   
     public void testContextPositionForParaentlessNodeIs1() {
     
         Element root = new Element("html");
        
         Nodes result = root.query("self::*[1]");
         assertEquals(1, result.size());
         assertEquals(root, result.get(0));
        
     }
View Full Code Here

     }
   
   
     public void testContextSizeForParaentlessNodeIs1() {
     
         Element root = new Element("html");
        
         Nodes result = root.query("self::*[last()=1]");
         assertEquals(1, result.size());
         assertEquals(root, result.get(0));
        
     }
View Full Code Here

     }
   
   
     public void testLastFunction() {
     
         Element root = new Element("html");
         Element child1 = new Element("child1");
         Element child2 = new Element("child2");
         root.appendChild(child1);
         root.appendChild(child2);
         new Document(root);
        
         Nodes result = child2.query("self::*[position()=last()]");
         assertEquals(1, result.size());
         assertEquals(child2, result.get(0));
        
     }
View Full Code Here

       
        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

       
        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

    }
   
   
    public void testDoubleSlashIsIncorrect() {
       
        Element root = new Element("root", "http://www.example.org");
        Document doc = new Document(root);
        root.appendChild(new Element("child"));
        root.appendChild("test");
        root.addAttribute(new Attribute("test", "test"));
       
        try {
            doc.query("//");
            fail("Queried //");
        }
View Full Code Here

    }
   

    public void testDoubleSlashIsIncorrect2() {
       
        Element root = new Element("root", "http://www.example.org");
        Document doc = new Document(root);
        root.appendChild(new Element("child"));
        root.appendChild("test");
        root.addAttribute(new Attribute("test", "test"));
       
        try {
            doc.query("// ");
            fail("Queried // ");
        }
View Full Code Here

TOP

Related Classes of nu.xom.Element

Copyright © 2018 www.massapicom. 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.