-
Bug
-
Resolution: Not an Issue
-
P3
-
None
-
1.2.0
-
generic
-
generic
Name: eaR10174 Date: 02/12/2002
An empty DocumentFragment is appended to the DocumentType node (see test.java
below). The DocumentType node is readonly according to DOM Level 2 spec. So no nodes
can be appended to the DocumentType node.
This bug is found in jaxp-1.2.0-beta-b06-06_feb_2002 and affects the test in the
JAXP 1.2 TCK (same as in JCK Merlin):
api/org_w3c/dom/Node/index.html#AppendChild[AppendChild007]
------------------------------------test.java-----------------------------
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.DocumentType;
import org.w3c.dom.DocumentFragment;
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
import java.io.StringReader;
public class test {
private static final String data =
"<?xml version=\"1.0\" ?>"
+ "<!DOCTYPE root ["
+ "<!ELEMENT root ANY>"
+ "<!ENTITY ent \"foo\">"
+ "<!NOTATION not PUBLIC \"http://xxx.xxx.xx/x.txt\">"
+ "]>"
+ "<root>"
+ "</root>";
public static void main (String[] args) {
Document document = null;
try {
DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance()
.newDocumentBuilder();
document =
docBuilder.parse(new InputSource(new StringReader(data)));
DocumentType docType = document.getDoctype();
DocumentFragment docFragment = document.createDocumentFragment();
docType = (DocumentType)docType.cloneNode(false);
docType.appendChild(docFragment);
System.out.println("Exception not thrown.");
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
}
}
--------------------------------------------------------------------------
% echo $CLASSPATH
.:/home/evg/lib/dom.jar:/home/evg/lib/sax.jar:/home/evg/lib/jaxp-api.jar:/home/evg/lib
/xalan.jar:/home/evg/lib/xercesImpl.jar
% java -showversion test
java version "1.3.1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-b24)
Java HotSpot(TM) Client VM (build 1.3.1-b24, mixed mode)
Exception not thrown.
---------------------------------------------------------------------------
======================================================================