- 
    
Bug
 - 
    Resolution: Fixed
 - 
    
  P4                     
     - 
    5.0
 
- 
        b30
 - 
        generic
 - 
        generic
 - 
        Verified
 
| Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build | 
|---|---|---|---|---|---|---|
| JDK-2073937 | 1.3.0 | Neeraj Bajaj | P4 | Closed | Fixed | 1.3 | 
                    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.
--------------------------------------------------------------------------
     
======================================================================
            
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.
--------------------------------------------------------------------------
======================================================================
- backported by
 - 
                    
JDK-2073937 createDocument() throws DOMException if all parameters are null
-         
     - Closed
 
 -         
 
- duplicates
 - 
                    
JDK-4913266 createDocument() throws DOMException if all parameters are null
-         
     - Closed
 
 -