Package nu.xom

Examples of nu.xom.Comment


        Element newRoot = new Element("newRoot");
        doc.setRootElement(newRoot);
        assertEquals(newRoot, doc.getRootElement());
        assertEquals(1, doc.getChildCount());
       
        doc.appendChild(new Comment("test"));
        assertEquals(2, doc.getChildCount());

        doc.insertChild(new Comment("prolog comment"), 0);
        assertEquals(3, doc.getChildCount());
        assertTrue(doc.getChild(0) instanceof Comment);
        assertTrue(doc.getChild(1) instanceof Element);
        assertTrue(doc.getChild(2) instanceof Comment);
View Full Code Here


    }
   
   
    public void testCopyConstructor() {
       
        doc.insertChild(new Comment("text"), 0);
        doc.insertChild(new ProcessingInstruction("text", "data"), 1);
        doc.insertChild(new DocType("text"), 2);
        root.appendChild("some data");
        doc.appendChild(new Comment("after"));
        doc.appendChild(new ProcessingInstruction("text", "after"));
       
        Document doc2 = new Document(doc);
        assertEquals(doc, doc2);
       
View Full Code Here

    }
   
   
    public void testCopy() {
       
        doc.insertChild(new Comment("text"), 0);
        doc.insertChild(new ProcessingInstruction("text", "data"), 1);
        doc.insertChild(new DocType("text"), 2);
        root.appendChild("some data");
        doc.appendChild(new Comment("after"));
        doc.appendChild(new ProcessingInstruction("text", "after"));
       
        Document doc2 = (Document) doc.copy();
        assertEquals(doc, doc2);
       
View Full Code Here

        catch (IllegalAddException success) {
            assertNotNull(success.getMessage());
        }
       
        try {
            doc.appendChild(new Comment("test"));
            doc.appendChild(new Element("test"));
            fail("appended element");
        }  
        catch (IllegalAddException 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);
        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

     *
     * @throws XMLException if the DOM comment is not a well-formed
     *     XML comment
     */
    public static Comment convert(org.w3c.dom.Comment comment) {      
        return new Comment(comment.getNodeValue());
    }
View Full Code Here

        Element root = new Element("test");         
        xomDocument = new Document(root);
        xomDocument.insertChild(type, 0);
        xomDocument.insertChild(new ProcessingInstruction(
         "xml-stylesheet", "href=\"file.css\" type=\"text/css\""), 1);
        xomDocument.insertChild(new Comment(" test "), 2);
        xomDocument.appendChild(new Comment("epilog"));
        root.addNamespaceDeclaration("xlink",
          "http://www.w3.org/TR/1999/xlink");
        root.appendChild("Hello dear\r\n");
        Element em = new Element("em");
        root.appendChild(em);
View Full Code Here

        byte[] data = "<element><!--data--></element>".getBytes();
        org.w3c.dom.Document doc = builder.parse(new ByteArrayInputStream(data));
         
        org.w3c.dom.Element root = doc.getDocumentElement();
        org.w3c.dom.Comment comment = (org.w3c.dom.Comment) (root.getChildNodes().item(0));
        Comment xomComment = DOMConverter.convert(comment);
        assertEquals(comment.getNodeValue(), xomComment.getValue());
                
    }
View Full Code Here

        Element first = (Element) result.get(0);
        assertEquals("name", first.getQualifiedName());
        assertEquals("name", first.getAttribute("name").getQualifiedName());
        assertEquals("value", first.getAttribute("name").getValue());
       
        Comment second = (Comment) result.get(1);
        assertEquals("data", second.getValue());
       
        Text third = (Text) result.get(2);
        assertEquals("text", third.getValue());
       
    }
View Full Code Here

   
   
    private static class TextToComment extends NodeFactory {
       
        public Nodes makeText(String data) {
            return new Nodes(new Comment(data));
        }
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.