Package nu.xom

Examples of nu.xom.DocType


      throws ParsingException, IOException {
       
        String data = "<!DOCTYPE root [ <!ELEMENT root EMPTY> ]><test/>";  
        Builder builder = new Builder();
        Document doc = builder.build(data, "http://www.example.com");
        DocType doctype = doc.getDocType();
        assertEquals("root", doctype.getRootElementName());
        String internalSubset =   doctype.getInternalDTDSubset();
        assertEquals("  <!ELEMENT root EMPTY>\n", internalSubset);
        assertTrue(doctype.toXML().indexOf("[") > 0);
        assertTrue(doctype.toXML().indexOf("]") > 0);
        assertTrue(doctype.toXML().indexOf("<!ELEMENT root EMPTY>") > 0);
       
    }
View Full Code Here


   
    public void testConstructor1Arg() {

        String name = "MyName";
        DocType doctype = new DocType(name);
        assertEquals(name, doctype.getRootElementName());
        assertEquals("", doctype.getInternalDTDSubset());
        assertNull(doctype.getSystemID());
        assertNull(doctype.getPublicID());

        // legal to have a colon here
        name = "try:MyName";
        doctype = new DocType(name);
        assertEquals("", doctype.getInternalDTDSubset());
        assertEquals(name, doctype.getRootElementName());
        assertNull(doctype.getSystemID());
        assertNull(doctype.getPublicID());

        // illegal name
        try {
            name = "try MyName";
            doctype = new DocType(name);
            fail("allowed root element name to contain spaces");
        }
        catch (IllegalNameException success) {
            assertNotNull(success.getMessage());
        }
View Full Code Here

   
    public void testNullRootElementName() {
       
        try {
            new DocType((String) null);
            fail("Allowed null root element name");
        }
        catch (IllegalNameException success) {
            assertNotNull(success.getMessage());
        }
View Full Code Here

   
    public void testRootElementNameBeginsWithDigit() {
       
        try {
            new DocType("1Data");
            fail("Allowed non-namestart character in root element name");
        }
        catch (IllegalNameException success) {
            assertNotNull(success.getMessage());
        }
View Full Code Here

   
    public void testRootElementNameBeginsWithColon() {
       
        try {
            new DocType(":Data");
            fail("Allowed colon to begin root element name");
        }
        catch (IllegalNameException success) {
            assertNotNull(success.getMessage());
        }
View Full Code Here

    }

   
    public void testSetRootElementName() {
       
        DocType doctype = new DocType("root");
        doctype.setRootElementName("newname");
        assertEquals("newname", doctype.getRootElementName());
        doctype.setRootElementName("new:name");
        assertEquals("new:name", doctype.getRootElementName());
        try {
            doctype.setRootElementName(":Data");
            fail("Allowed colon to begin root element name");
        }
        catch (IllegalNameException success) {
            assertNotNull(success.getMessage());
        }
View Full Code Here

    }

   
    public void testAllowEmptyInternalDTDSubset() {
       
        DocType doctype = new DocType("root");
        doctype.setInternalDTDSubset("");
        assertEquals("", doctype.getInternalDTDSubset());
       
    }
View Full Code Here

    }

   
    public void testAllowNullInternalDTDSubset() {
       
        DocType doctype = new DocType("root");
        doctype.setInternalDTDSubset(null);
        assertEquals("", doctype.getInternalDTDSubset());
       
    }
View Full Code Here

    }

   
    public void testSetInternalDTDSubset() {
       
        DocType doctype = new DocType("root");
        doctype.setInternalDTDSubset("<!ELEMENT test (PCDATA)>");
        assertEquals("<!ELEMENT test (PCDATA)>", doctype.getInternalDTDSubset());
       
    }
View Full Code Here

    public void testSetInternalDTDSubsetWithEntityThatPointsToNonExistentURL() {
       
        String subset =
          "<!ENTITY % test SYSTEM 'http://www.example.com/notexists.dtd'>\n"
          + "%test;\n";
        DocType doctype = new DocType("root");
        doctype.setInternalDTDSubset(subset);
        assertEquals(subset, doctype.getInternalDTDSubset());
       
    }
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.