Package nu.xom

Examples of nu.xom.DocType


    // well-formedness
    public void testPreserveExternalGeneralEntityDeclaration()
      throws ParsingException, IOException {
    
        Document doc = builder.build(new File(inputDir, "ge.xml"));
        DocType doctype = doc.getDocType();
        assertEquals("  <!ENTITY ccl SYSTEM \"ge.txt\">\n", doctype.getInternalDTDSubset())
    }
View Full Code Here


    // validity
    public void testPreserveExternalParameterEntityDeclaration()
      throws ParsingException, IOException {
    
        Document doc = builder.build(new File(inputDir, "pe.xml"));
        DocType doctype = doc.getDocType();
        assertEquals("  <!ENTITY % ccl SYSTEM \"pe.txt\">\n", doctype.getInternalDTDSubset())
    }
View Full Code Here

    }
   
   
    public void testDocTypeInsertion() {
       
        DocType type1 = new DocType("root");
       
        try {
            doc.insertChild(type1, 1);
            fail("inserted doctype after root element");
        }
        catch (IllegalAddException success) {
            assertNotNull(success.getMessage());
        }
       
        doc.insertChild(type1, 0);
        assertEquals(type1, doc.getDocType());
       
        DocType type2 = new DocType("test");
        try {
            doc.insertChild(type2, 1);
            fail("Inserted 2nd DocType");
        }
        catch (IllegalAddException success) {
            assertNotNull(success.getMessage());
        }
        assertEquals(type1, doc.getDocType());
        assertNull(type2.getParent());
        assertEquals(type1, doc.getChild(0));
       
        doc.setDocType(type2);
        assertEquals(doc.getDocType(), type2);
        assertNull(type1.getParent());
View Full Code Here

    }

   
    public void testSetDocType() {
       
        DocType type1 = new DocType("root");      
        doc.setDocType(type1);
        assertEquals(type1, doc.getDocType());
       
        doc.insertChild(new Comment("test"), 0);

        DocType type2 = new DocType("root", "http://www.example.com/");      
        doc.setDocType(type2);
        assertEquals(type2, doc.getDocType());
        assertEquals(1, doc.indexOf(type2));
        assertNull(type1.getParent());
        assertEquals(doc, type2.getParent());
       
        // set same doctype
        doc.setDocType(type2);
        assertEquals(type2, doc.getDocType());
        assertEquals(1, doc.indexOf(type2));
        assertEquals(doc, type2.getParent());
       
        try {
            doc.setDocType(null);
            fail("Allowed null doctype");  
        }
View Full Code Here

    }
   
   
    public void testReplaceDocTypeWithDifferentDocTypeUsingReplaceChild() {
       
        DocType newDocType = new DocType("new");
        DocType oldDocType = new DocType("old");
        doc.setDocType(oldDocType);
        doc.replaceChild(oldDocType, newDocType);
        assertEquals(newDocType, doc.getDocType());
        assertNull(oldDocType.getParent());
        assertEquals(doc, newDocType.getParent());
       
    }
View Full Code Here

    }

   
    public void testReplaceDocTypeWithParentedDocTypeUsingReplaceChild() {
       
        DocType newDocType = new DocType("new");
        DocType oldDocType = new DocType("old");
        Document temp = new Document(new Element("root"));
        temp.setDocType(newDocType);
       
        doc.setDocType(oldDocType);
        try {
            doc.replaceChild(oldDocType, newDocType);
            fail("Missed MultipleParentException");
        }
        catch (MultipleParentException success) {
            assertEquals(2, doc.getChildCount());
            assertEquals(2, temp.getChildCount());
        }
       
        assertEquals(oldDocType, doc.getDocType());
        assertNotNull(oldDocType.getParent());
        assertEquals(doc, oldDocType.getParent());
        assertEquals(newDocType, temp.getDocType());
        assertNotNull(oldDocType.getParent());
        assertEquals(temp, newDocType.getParent());
       
    }
View Full Code Here

   
    public void testReplaceNonDocTypeWithDocTypeUsingReplaceChild() {
       
        Comment c = new Comment("Not a doctype");
        DocType newDocType = new DocType("new");
        doc.insertChild(c, 0);
        doc.replaceChild(c, newDocType);
        assertEquals(newDocType, doc.getDocType());
        assertNull(c.getParent());
        assertEquals(doc, newDocType.getParent());
       
    }
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);
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();
View Full Code Here

            String data = node.getValue();
            lexicalHandler.comment(
              data.toCharArray(), 0, data.length());           
        }
        else if (node instanceof DocType && lexicalHandler != null) {
            DocType type = (DocType) node;
            lexicalHandler.startDTD(type.getRootElementName(),
              type.getPublicID(), type.getSystemID());             
            lexicalHandler.endDTD();         
        }
        // all other types are ignored
       
    }
View Full Code Here

TOP

Related Classes of nu.xom.DocType

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.