Package nu.xom

Examples of nu.xom.Element.removeAttribute()


        Element element = new Element("test");
        element.addAttribute(a1);
        assertEquals(element, a1.getParent());
        assertEquals(a1, element.getAttribute("test"));

        element.removeAttribute(a1);
        assertNull(element.getAttribute("test"));

    }
   
   
View Full Code Here


    public void testDoubleAdd() {
       
        Element e = new Element("test");
        Attribute a = new Attribute("foo", "bar");
        e.addAttribute(a);
        e.removeAttribute(a);
        Element copy = new Element(e);
        copy.addAttribute(new Attribute("a", "newvalue"));
        assertEquals(1, copy.getAttributeCount());
       
    }
View Full Code Here

       
        a1.detach();
        assertNull(a1.getParent());
        assertNull(e.getAttribute("name"));
       
        Attribute removed = e.removeAttribute(a2);
        assertNull(a2.getParent());
        assertEquals(a2, removed);
        assertNull( e.getAttribute("green", "http://www.green.com/"));
       
    }
View Full Code Here

        e.addAttribute(a1);
        e.addAttribute(a2);

        try {
            e.removeAttribute(null);
            fail("Removed Null Attribute");
        }
        catch (NullPointerException success) {
            assertNotNull(success.getMessage());
        }
View Full Code Here

        Element e = new Element(name, uri);

        Attribute a1 = new Attribute("name", "simple");

        try {
            e.removeAttribute(a1);
            fail("Removed Attribute that didn't belong");
        }
        catch (NoSuchAttributeException success) { 
            assertTrue(success.getMessage().indexOf(a1.getQualifiedName()) > 0);
        }
View Full Code Here

        Element e = new Element(name, uri);
        e.addAttribute(new Attribute("name", "value"));
        Attribute a1 = new Attribute("name", "simple");

        try {
            e.removeAttribute(a1);
            fail("Removed Attribute that didn't belong");
        }
        catch (NoSuchAttributeException success) {
            assertTrue(success.getMessage().indexOf(a1.getQualifiedName()) > 0);
        }
View Full Code Here

       );
       Builder builder = new Builder(filter);
       String data ="<a/>";
       Document doc = builder.build(data, null);
       Element root = doc.getRootElement();
       root.removeAttribute(root.getAttribute(0));
       assertNull(root.getNamespaceURI("pre"));
      
    }

   
View Full Code Here

  public static void removeNodes(Nodes remove) {
    for (int i = 0; i < remove.size(); i++) {
      Node node = remove.get(i);
      if(node instanceof Attribute) {
        Element elem = (Element) node.getParent();
        elem.removeAttribute((Attribute)node);
      }else {
        node.getParent().removeChild(node);
     
     
    }
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.