Package nu.xom

Examples of nu.xom.Document.removeChild()


    if (node instanceof Document) {
      // remove all children except root element (XOM docs must have a root element)
      Document doc = (Document) node;
      Element root = doc.getRootElement();
      for (int k = doc.getChildCount(); --k >= 0; ) {
        if (doc.getChild(k) != root) doc.removeChild(k);
      }
      node = root; // replace root element's content
    }

    if (node instanceof Element) {
View Full Code Here


            // and then serializing into a byte array. This caches
            // the document and removes any dependence on the DTD.
            Document doc = parser.build(args[0]);
            DocType type = doc.getDocType();
            if (type != null) {
                doc.removeChild(type);  
            }
            ByteArrayOutputStream out = new ByteArrayOutputStream();
            Serializer serializer = new Serializer(out);
            serializer.write(doc);
            serializer.flush();
View Full Code Here

            // and then serializing into a byte array.
            // This caches the and removes any dependence on the DTD.
            Document doc = parser.build(args[0]);
            DocType type = doc.getDocType();
            if (type != null) {
                doc.removeChild(type);  
            }
            ByteArrayOutputStream out = new ByteArrayOutputStream();
            Serializer serializer = new Serializer(out);
            serializer.write(doc);
            serializer.flush();
View Full Code Here

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

        catch (WellformednessException success) {
            assertNotNull(success.getMessage());
        }
       
        try {
            doc.removeChild(0);
            fail("removed root element");
        }  
        catch (WellformednessException success) {
            assertNotNull(success.getMessage());
        }
View Full Code Here

        catch (WellformednessException success) {
            assertNotNull(success.getMessage());
        }
       
        doc.appendChild(new Comment("test"));
        doc.removeChild(1);
        assertEquals(1, doc.getChildCount());
       
        Comment test = new Comment("test");
        doc.appendChild(test);
        doc.removeChild(test);
View Full Code Here

        doc.removeChild(1);
        assertEquals(1, doc.getChildCount());
       
        Comment test = new Comment("test");
        doc.appendChild(test);
        doc.removeChild(test);
        assertEquals(1, doc.getChildCount());
       
        try {
            Comment something = new Comment("sd");
            doc.removeChild(something);
View Full Code Here

        doc.removeChild(test);
        assertEquals(1, doc.getChildCount());
       
        try {
            Comment something = new Comment("sd");
            doc.removeChild(something);
            fail("Removed nonchild");
        }
        catch (NoSuchChildException success) {
            assertNotNull(success.getMessage());
        }
View Full Code Here

        catch (NoSuchChildException success) {
            assertNotNull(success.getMessage());
        }

        try {
            doc.removeChild(20);
            fail("removed overly sized element");
        }  
        catch (IndexOutOfBoundsException success) {
            assertNotNull(success.getMessage());
        }
View Full Code Here

                         expected.removeChild(doctype);
                         assertEquals("Error when processing  "
                          + input, expected, doc);                 
                      }
                      else if (actualDoctype != null) {
                         doc.removeChild(actualDoctype);
                          assertEquals("Error when processing  "
                          + input, expected, doc);
                      }
                      else {
                          fail();
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.