Package nu.xom

Examples of nu.xom.Comment


            System.out.println("    pi = new ProcessingInstruction(\"" +
              pi.getTarget() + "\", \"" + javaEscape(pi.getValue()) + "\");");
            System.out.println("    " + parent + ".appendChild(pi);");   
        }
        else if (node instanceof Comment) {
            Comment comment = (Comment) node;
            System.out.println("    comment = new Comment(\""
             + javaEscape(comment.getValue()) + "\");");
            System.out.println("    " + parent + ".appendChild(comment);");   
        }
        else if (node instanceof Text) {
            Text text = (Text) node;
            System.out.println("    text = new Text(\""
View Full Code Here


   
    }

    // We don't really need the comments. We just want to print them.   
    public Nodes makeComment(String data) {
        return new Nodes(new Comment(rot13(data)));
    }   
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-->";
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        Canonicalizer canonicalizer = new Canonicalizer(out);
       
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?>";
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        Canonicalizer canonicalizer = new Canonicalizer(out);
View Full Code Here

    }

   
    public void testCanonicalizeComment() throws IOException {
    
        Comment c = new Comment("pre:foo");
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        try {
            Canonicalizer serializer = new Canonicalizer(out);
            serializer.write(c);
        }
View Full Code Here

    protected void setUp() {
       
        child1 = new Element("test");
        child2 = new Text("test2");
        child3 = new Comment("test3");
        child4 = new Element("pre:test", "http://www.example.com");
        child5 = new Element("test", "http://www.example.com");
        element = new Element("name");
       
        element.appendChild(child1);
View Full Code Here

       
        e.appendChild(new Text("data"));
        assertEquals(e.getValue(), "data");
        e.appendChild(new Text(" moredata"));
        assertEquals(e.getValue(), "data moredata");
        e.appendChild(new Comment(" moredata"));
        assertEquals(e.getValue(), "data moredata");
        e.appendChild(
          new ProcessingInstruction("target", "moredata"));
        assertEquals(e.getValue(), "data moredata");
       
View Full Code Here

        }
        catch (NullPointerException success) {
            // success  
        }
        try {
            e.insertChild(new Comment("test"), 20);
            fail("Added comment after end");   
        }
        catch (IndexOutOfBoundsException success) {
            // success   
            assertNotNull(success.getMessage());
        }
        try {
            e.insertChild(new Comment("test"), -20);
            fail("Added comment before start");
        }
        catch (IndexOutOfBoundsException success) {
            // success
        }    
View Full Code Here

        Node child1 = new Text("http://www.mauve.com");
        parent.appendChild(child1);
        Node child2 = new ProcessingInstruction(
          "child", "http://www.mauve.com");
        parent.appendChild(child2);
        Node child3 = new Comment("http://www.mauve.com");
        parent.appendChild(child3);
 
        assertEquals(parent, child3.getParent());
        assertEquals(parent, child1.getParent());
        assertEquals(parent, child2.getParent());
      
        Nodes result = parent.removeChildren();
        assertEquals(0, parent.getChildCount());
        assertNull(child1.getParent());
        assertNull(child2.getParent());
        assertNull(child3.getParent());
        assertEquals(parent, a1.getParent());
       
        assertEquals(3, result.size());
        assertEquals(child1, result.get(0));
        assertEquals(child2, result.get(1));
View Full Code Here

        doc = new Document(root);
        doc.setBaseURI(base1);
        Element child = new Element("child");
        root.appendChild(child);
        child.setBaseURI(base2);
        child.appendChild(new Comment("here I am"));
       
        Element child2 = new Element("child2");
        root.appendChild(child2);
        Element child3 = new Element("child3");
View Full Code Here

TOP

Related Classes of nu.xom.Comment

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.