Package nu.xom

Examples of nu.xom.Element


    }
   

    public void testUnionOfNodesWithInts() {
       
        Element parent = new Element("Test");
        Element child = new Element("child");
        parent.appendChild(child);
       
        try {
            parent.query("* | count(/*)");
            fail("Allowed query returning non-node-set");
View Full Code Here


    } */
   

    public void testQueryThatReturnsNumber() {
       
        Element parent = new Element("Test");
        Element child = new Element("child");
        parent.appendChild(child);
       
        try {
            parent.query("count(*)");
            fail("Allowed query to return number");
View Full Code Here

    }
   

    public void testStartsWith() {
       
        Element parent = new Element("Test");
        Element child = new Element("child");
        child.addAttribute(new Attribute("foo", "bar"));
        parent.appendChild(child);
        Element child2 = new Element("child");
        child2.addAttribute(new Attribute("foo", "big"));
        parent.appendChild(child2);
       
        Nodes result = parent.query(".//*[starts-with(@foo, 'ba')]");
        assertEquals(1, result.size());
        assertEquals(child, result.get(0));
View Full Code Here

   

    // a jaxen extension function
    public void testEndsWith() {
       
        Element parent = new Element("Test");
        Element child = new Element("child");
        child.addAttribute(new Attribute("foo", "bar"));
        parent.appendChild(child);
       
        try {
            parent.query(".//*[ends-with(@foo, 'ar')]");
            fail("Allowed Jaxen extension function");
View Full Code Here

    }
   

    public void testEmptyTextNodesDontCount() {
       
        Element parent = new Element("Test");
        Element child1 = new Element("child1");
        parent.appendChild(child1);
        parent.appendChild(new Text(""));
        parent.appendChild(new Text(""));
        Element child2 = new Element("child2");
        parent.appendChild(child2);
       
        Nodes result = parent.query("*");
        assertEquals(2, result.size());
        assertEquals(child1, result.get(0));  
View Full Code Here

    }
   

    public void testEmptyTextNodesDontCount2() {
       
        Element parent = new Element("Test");
        parent.appendChild(new Text(""));
        Element child1 = new Element("child1");
        parent.appendChild(child1);
        Element child2 = new Element("child2");
        parent.appendChild(child2);
       
        Nodes result = parent.query("node()");
        assertEquals(2, result.size());
        assertEquals(child1, result.get(0));  
View Full Code Here

    }
   

    public void testEmptyTextNodesAtEndOfParent() {
       
        Element parent = new Element("Test");
        Element child1 = new Element("child1");
        parent.appendChild(child1);
        Element child2 = new Element("child2");
        parent.appendChild(child2);
        parent.appendChild(new Text(""));
        parent.appendChild(new Text(""));
        parent.appendChild(new Text(""));
       
View Full Code Here

    }
   

    public void testEmptyTextNodeNextToNonEmptyTextNode() {
       
        Element parent = new Element("Test");
        Text empty = new Text("");
        parent.appendChild(empty);
        Text nonempty = new Text("value");
        parent.appendChild(nonempty);
        Element child1 = new Element("child1");
        parent.appendChild(child1);
        Element child2 = new Element("child2");
        parent.appendChild(child2);
       
        Nodes result = parent.query("node()");
        assertEquals(4, result.size());
        assertEquals(empty, result.get(0));  
View Full Code Here

    }
   

    public void testBasicPredicate() {
       
        Element parent = new Element("Test");
        Element child1 = new Element("child");
        child1.appendChild("1");
        parent.appendChild(child1);
        Element child2 = new Element("child");
        child2.appendChild("2");
        parent.appendChild(child2);
        Element child3 = new Element("child");
        child3.appendChild("3");
        parent.appendChild(child3);
       
        Nodes result = parent.query("*[.='2']");
        assertEquals(1, result.size());
        assertEquals(child2, result.get(0));  
View Full Code Here

    }
   

    public void testXMLLang() {
       
        Element parent = new Element("Test");
        Element child1 = new Element("child");
        child1.addAttribute(new Attribute("xml:lang",
          "http://www.w3.org/XML/1998/namespace", "en"));
        parent.appendChild(child1);
        Element child2 = new Element("child");
        child2.appendChild("2");
        child2.addAttribute(new Attribute("xml:lang",
          "http://www.w3.org/XML/1998/namespace", "fr"));
        parent.appendChild(child2);
        Element child3 = new Element("child");
        child3.appendChild("3");
        parent.appendChild(child3);
        Element child4 = new Element("child");
        child4.appendChild("4");
        child4.addAttribute(new Attribute("xml:lang",
          "http://www.w3.org/XML/1998/namespace", "en-US"));
        parent.appendChild(child4);
       
        Nodes result = parent.query("child::*[lang('en')]");
        assertEquals(2, result.size());
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.