Package nu.xom

Examples of nu.xom.Document.insertChild()


                            if (child instanceof Element) {
                                doc.setRootElement((Element) child);
                                break;  
                            }
                            else {
                                doc.insertChild(
                                  child, doc.indexOf(element)
                                );
                            }

                        }
View Full Code Here


                        }
                        // epilog
                        Element root = doc.getRootElement();
                        int position = doc.indexOf(root);
                        for (int j=i; j < replacements.size(); j++) {
                            doc.insertChild(
                              replacements.get(j), position+1+j-i
                            );                            
                        }
                    }
                }
View Full Code Here

                if (n instanceof Element) {
                    xomDocument.setRootElement((Element) n);
                    beforeRoot = false;
                }
                else {
                    xomDocument.insertChild(n, p++);
                }
            }
            else {
                xomDocument.appendChild(n);
            }
View Full Code Here

             current.getNodeType() != org.w3c.dom.Node.ELEMENT_NODE;
             current = current.getNextSibling()) {
            Nodes nodes = convert(current, factory);
            // FIXME fix for multiples
            for (int i = 0; i < nodes.size(); i++) {
                xomDocument.insertChild(nodes.get(i), position++);
            }
        }
        // root element      
        current = current.getNextSibling();
       
View Full Code Here

   
    public void testInsertionAllowed() {
       
        Document doc = new Document(new Element("root"));
        Comment original = new Comment("original");
        doc.insertChild(original, 0);
       
        Element temp = new Element("temp");
        Comment c2 = new Comment("new comment");
        temp.appendChild(c2);
       
View Full Code Here

        catch (IllegalAddException success) {
            assertNotNull(success.getMessage());
        }
       
        try {
            doc.insertChild(new Element("test"), 0);
            fail("inserted element");
        }  
        catch (IllegalAddException success) {
            assertNotNull(success.getMessage());
        }
View Full Code Here

    public void testCanonicalizeCommentsInPrologAndEpilog() throws IOException {
       
        Element pdu = new Element("doc");
       
        Document doc = new Document(pdu);
        doc.insertChild(new Comment("comment 1"), 0);
        doc.insertChild(new Comment("comment 2"), 1);
        doc.appendChild(new Comment("comment 3"));
        doc.appendChild(new Comment("comment 4"));
       
        String expected = "<!--comment 1-->\n<!--comment 2-->\n\n<!--comment 3-->\n<!--comment 4-->";
View Full Code Here

       
        Element pdu = new Element("doc");
       
        Document doc = new Document(pdu);
        doc.insertChild(new Comment("comment 1"), 0);
        doc.insertChild(new Comment("comment 2"), 1);
        doc.appendChild(new Comment("comment 3"));
        doc.appendChild(new Comment("comment 4"));
       
        String expected = "<!--comment 1-->\n<!--comment 2-->\n\n<!--comment 3-->\n<!--comment 4-->";
       
View Full Code Here

    public void testCanonicalizePrologAndEpilog() throws IOException {
       
        Element pdu = new Element("doc");
       
        Document doc = new Document(pdu);
        doc.insertChild(new ProcessingInstruction("target", "value"), 0);
        doc.insertChild(new Comment("comment 2"), 1);
        doc.appendChild(new Comment("comment 3"));
        doc.appendChild(new ProcessingInstruction("target", "value"));
       
        String expected = "<?target value?>\n<!--comment 2-->\n<doc></doc>\n<!--comment 3-->\n<?target value?>";
View Full Code Here

       
        Element pdu = new Element("doc");
       
        Document doc = new Document(pdu);
        doc.insertChild(new ProcessingInstruction("target", "value"), 0);
        doc.insertChild(new Comment("comment 2"), 1);
        doc.appendChild(new Comment("comment 3"));
        doc.appendChild(new ProcessingInstruction("target", "value"));
       
        String expected = "<?target value?>\n<!--comment 2-->\n<doc></doc>\n<!--comment 3-->\n<?target value?>";
       
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.