Code example for DocumentType

Methods: getNamegetPublicIdgetSystemId

0
        document = builder.parse(new InputSource(new StringReader(
                " <!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\"" 
                        + " \"http://www.w3.org/TR/html4/strict.dtd\">" 
                        + "<html></html>"))); 
        doctype = document.getDoctype();
        assertEquals("html", doctype.getName());
        assertEquals("-//W3C//DTD HTML 4.01//EN", doctype.getPublicId());
        assertEquals("http://www.w3.org/TR/html4/strict.dtd", doctype.getSystemId());
    } 
 
    public void testSystemIdOnly() throws Exception { 
        document = builder.parse(new InputSource(new StringReader(
                " <!DOCTYPE html SYSTEM \"http://www.w3.org/TR/html4/strict.dtd\">" 
                        + "<html></html>"))); 
        doctype = document.getDoctype();
        assertEquals("html", doctype.getName());
        assertNull(doctype.getPublicId());
        assertEquals("http://www.w3.org/TR/html4/strict.dtd", doctype.getSystemId());
    } 
 
    public void testSingleQuotedPublicIdAndSystemId() throws Exception {