Package nu.xom

Examples of nu.xom.Element.detach()


   
        Element root = new Element("root");
        Document doc = new Document(root);

        try {
            root.detach();
            fail("detached root element");
        }  
        catch (WellformednessException success) {
            assertNotNull(success.getMessage());
        }
View Full Code Here


       
        Element child = new Element("test");
        empty.appendChild(child);
        assertEquals(1, empty.getChildCount());
        assertEquals(empty.getChild(0), child);
        child.detach();
       
        notEmpty.appendChild(child);
        assertFalse(notEmpty.getChild(0).equals(child));
        assertTrue(notEmpty.getChild(1).equals(child));
       
View Full Code Here

        Elements tests = doc.getRootElement().getChildElements("test");
        int size = tests.size();
        for (int i = 0; i < size; i++) {
            // System.out.println(i);
            Element test = tests.get(i);
            test.detach();
            Document testdoc = new Document(test);
            ByteArrayOutputStream out = new ByteArrayOutputStream();
            Serializer serializer = new Serializer(out);
            serializer.setUnicodeNormalizationFormC(true);
            serializer.write(testdoc);
View Full Code Here

        Element root = new Element("root");
        Document doc = new Document(root);
        doc.setBaseURI("http://www.example.com");
        Element child = new Element("child");
        root.appendChild(child);
        child.detach();
        assertEquals("http://www.example.com", child.getBaseURI());
       
    }
   
   
View Full Code Here

            current = null;
        }
        else {
            Nodes nodes = factory.finishMakingElement(element);
            ParentNode parent = element.getParent();
            element.detach();
            for (int i = 0; i < nodes.size(); i++) {
                Node node = nodes.get(i);
                if (node instanceof Attribute) {
                    ((Element) parent).addAttribute((Attribute) node);
                }
View Full Code Here

    ParentNode parent = toReplace.getParent();
    int pos = parent.indexOf(toReplace);
    Elements toInsert = addChildren.getChildElements();
    for (int j = 0; j < toInsert.size(); j++) {
      Element child = toInsert.get(j);
      child.detach();
      parent.insertChild(child, ++pos);
    }
    parent.removeChild(toReplace);           
  }
 
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.