Package nu.xom

Examples of nu.xom.DocType


    }
   
   
    public void testSetMalformedInternalDTDSubset() {
       
        DocType doctype = new DocType("root");
        try {
            doctype.setInternalDTDSubset("<!ELEMENT test (PCDATA>");
            fail("Allowed malformed internal DTD subset");
        }
        catch (WellformednessException success) {
            assertNotNull(success.getMessage());
        }
View Full Code Here


   
    public void testEmptyRootElementName() {
       
        try {
            new DocType("");
            fail("Allowed empty string to be root element name");
        }
        catch (IllegalNameException success) {
            assertNotNull(success.getMessage());
        }
View Full Code Here

   
    public void testConstructor2Arg() {

        String name = "MyName";
        String systemID = "http://www.w3.org/TR/some.dtd";
        DocType doctype = new DocType(name, systemID);
        assertEquals(name, doctype.getRootElementName());
        assertEquals("", doctype.getInternalDTDSubset());
        assertEquals(systemID, doctype.getSystemID());
        assertNull(doctype.getPublicID());

        // empty system ID
        name = "try:MyName";
        systemID = "";
        doctype = new DocType(name, systemID);
        assertEquals(name, doctype.getRootElementName());
        assertEquals("", doctype.getInternalDTDSubset());
        assertEquals(systemID, doctype.getSystemID());
        assertNull(doctype.getPublicID());

    }
View Full Code Here

    public void testConstructor3Arg() {

        String name = "MyName";
        String systemID = "http://www.w3.org/TR/some.dtd";
        String publicID = "-//Me//some public ID";
        DocType doctype = new DocType(name, publicID, systemID);
        assertEquals(name, doctype.getRootElementName());
        assertEquals("", doctype.getInternalDTDSubset());
        assertEquals(systemID, doctype.getSystemID());
        assertEquals(publicID, doctype.getPublicID());

    }
View Full Code Here

    public void testEmptyStringForPublicID() {

        String name = "MyName";
        String systemID = "http://www.w3.org/TR/some.dtd";
        String publicID = "";
        DocType doctype = new DocType(name, publicID, systemID);
        assertEquals(name, doctype.getRootElementName());
        assertEquals("", doctype.getInternalDTDSubset());
        assertEquals(systemID, doctype.getSystemID());
        assertEquals(publicID, doctype.getPublicID());

    }
View Full Code Here

    public void testEmptyStringForSystemID() {

        String name = "MyName";
        String systemID = "";
        String publicID = "-//Me//some public ID";
        DocType doctype = new DocType(name, publicID, systemID);
        assertEquals(name, doctype.getRootElementName());
        assertEquals("", doctype.getInternalDTDSubset());
        assertEquals(systemID, doctype.getSystemID());
        assertEquals(publicID, doctype.getPublicID());

    }
View Full Code Here

        String data = "<!DOCTYPE a><a></a>";
        Builder builder = new Builder(new NodeFactory() {
           
            public Nodes makeDocType(String name, String publicID, String systemID) {
                Nodes result = new Nodes();
                result.append(new DocType(name, publicID, systemID));
                result.append(new Comment("sajdha"));
                result.append(new DocType(name, publicID, systemID));
                return result;
            }
           
        });
        try {
View Full Code Here

    public void testSpaceContainingPublicIDs() {

        // According to section 4.2.2 of the XML spec, public IDs are
        // normalized like attribute values of non-CDATA type
        try {
            new DocType("root", " test", "http://www.example.org");
            fail("allowed initial space in public ID");
        }
        catch (WellformednessException success) {
            assertNotNull(success.getMessage());
        }

        try {
            new DocType("root", "test ", "http://www.example.org");
            fail("allowed trailing space in public ID");
        }
        catch (WellformednessException success) {
            assertNotNull(success.getMessage());
        }

        try {
            new DocType("root", "test\ntest", "http://www.example.org");
            fail("allowed linefeed public ID");
        }
        catch (WellformednessException success) {
            assertNotNull(success.getMessage());
        }

        try {
            new DocType("root", "test\rtest", "http://www.example.org");
            fail("allowed carriage return in public ID");
        }
        catch (WellformednessException success) {
            assertNotNull(success.getMessage());
        }

        try {
            new DocType("root", "test\r\ntest", "http://www.example.org");
            fail("allowed carriage return linefeed pair public ID");
        }
        catch (WellformednessException success) {
            assertNotNull(success.getMessage());
        }

        try {
            new DocType("root", "test  test", "http://www.example.org");
            fail("allowed multiple consecutive spaces in public ID");
        }
        catch (WellformednessException success) {
            assertNotNull(success.getMessage());
        }
       
        // one space is legal
        DocType test = new DocType("root", "test test", "http://www.example.org");
        assertEquals(test.getPublicID(), "test test");

    }
View Full Code Here

   
   
    public void testSystemIDWithDollarSignAndComma() {

        String systemID = "http://www.example.com/test$red/limit,data.xml";
        DocType doctype = new DocType("root", systemID);
        assertEquals(systemID, doctype.getSystemID());
       
    }
View Full Code Here

   
   
    public void testSystemIDWithSemicolon() {

        String systemID = "smb://domain;user:pass@server/share/path/to/file";
        DocType doctype = new DocType("root", systemID);
        assertEquals(systemID, doctype.getSystemID());
       
    }
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.