Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4913260

createDocument() throws DOMException if all parameters are null

    XMLWordPrintable

Details

    • b30
    • generic
    • generic
    • Verified

    Backports

      Description

        Name: eaR10174 Date: 08/27/2003


          The method DOMImplementation.createDocument() throws DOMException with the error code
        INVALID_CHARACTER_ERR in case when the all parameters are null (see test.java below).
        According to the method javadoc:
          
          Returns:
            A new Document object with its document element. If the NamespaceURI, qualifiedName,
            and doctype are null, the returned Document is empty with no document element.

        the method should return a Document object.

          The bug appears in jdk1.5.0beta-b16 and affects a new JCK1.5 test:

             api/org_w3c/dom/DOMImplementation/index.html#CreateDocument[CreateDocument012]

        ------------------------------------test.java-----------------------------
        import javax.xml.parsers.DocumentBuilderFactory;
        import org.w3c.dom.DOMImplementation;
        import org.w3c.dom.Document;
        import org.w3c.dom.DOMException;

        public class test {

            public static void main(String argv[]) {
                new test().run();
            }
            
            public void run() {
                Document document = null;
                try {
                    document = DocumentBuilderFactory.newInstance()
                               .newDocumentBuilder().newDocument();
                } catch (Exception e) {
                    System.out.println("Can't create an empty document.");
                    return;
                }
            
                DOMImplementation implementation = document.getImplementation();

                try {
                    document = implementation.createDocument(null, null, null);
                
                    System.out.println("Method does not throw an exception.");
                } catch (DOMException e) {
                    if (e.code == DOMException.NAMESPACE_ERR) {
                        System.out.println("OK");
                    } else {
                        System.out.println("Unexpected error code of exception: " + e );
                    }
                }
            }
        }
        --------------------------------------------------------------------------
        % java -showversion test
        java version "1.5.0-beta"
        Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b16)
        Java HotSpot(TM) Client VM (build 1.5.0-beta-b16, mixed mode)

        Unexpected error code of exception: org.w3c.dom.DOMException: INVALID_CHARACTER_ERR: An
        invalid or illegal XML character is specified.
        --------------------------------------------------------------------------
             
        ======================================================================

        Attachments

          Issue Links

            Activity

              People

                nbajajsunw Neeraj Bajaj (Inactive)
                evgsunw Evg Evg (Inactive)
                Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: