Name: erR10175 Date: 12/05/2003
When the DOMConfiguration parameter 'entities' is set to false,
the method org.w3c.dom.Document.normalizeDocument() removes
an EntityReference to an Entity that is defined in the document type,
but does not put its expansion to the document.
The method description on the case, when the parameter 'entities'
is set to false, reads:
"Remove all EntityReference and Entity nodes from the document,
putting the entity expansions directly in their place."
So in the test below, the entity reference to the entity 'x' should be
changed to its expansion text 'X', but the entity reference is just
detached from the parent.
This bug affects new tests in JCK 1.5 (not integrated yet)
api/org_w3c/dom/DOMConfiguration/index.html#Params[Entities002]
The bug is found in jdk1.5.0/beta/b30.
To reproduce the bug place test.java and test.xml to your current
directory, then compile and run test.java as shown in the log below:
------------------------------ test.java
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.DOMConfiguration;
import javax.xml.parsers.DocumentBuilderFactory;
class test {
public static void main(String [] args) throws Exception {
Document doc = DocumentBuilderFactory.newInstance()
.newDocumentBuilder().parse("test.xml");
Element root = doc.getDocumentElement();
root.appendChild(doc.createEntityReference("x"));
doc.getDomConfig().setParameter("entities", Boolean.FALSE);
doc.normalizeDocument();
Node child = root.getFirstChild();
if (child == null) {
System.out.println("root has no child,"
+ " but a text node with value 'X' is expected");
} else if (child.getNodeType() != Node.TEXT_NODE
|| !"X".equals(child.getNodeValue())) {
System.out.println("root's child is "
+ child.getClass().getName()
+ "[" + child.getNodeValue()
+ "], expected a text node with value 'X'");
} else {
System.out.println("OK");
}
}
}
----------------------------------------------------
------------------------------------------- test.xml
<?xml version="1.0"?>
<!DOCTYPE root [
ELEMENT root ANY
ENTITY x 'X'
]>
<root/>
----------------------------------------------------
------------------------------------------------ log
$javac test.java && java -cp . -showversion test
java version "1.5.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b30)
Java HotSpot(TM) Client VM (build 1.5.0-beta-b30, mixed mode)
root has no child, but a text node with value 'X' is expected
----------------------------------------------------
======================================================================
###@###.### 2003-12-08
When the DOMConfiguration parameter 'entities' is set to false,
the method org.w3c.dom.Document.normalizeDocument() removes
an EntityReference to an Entity that is defined in the document type,
but does not put its expansion to the document.
The method description on the case, when the parameter 'entities'
is set to false, reads:
"Remove all EntityReference and Entity nodes from the document,
putting the entity expansions directly in their place."
So in the test below, the entity reference to the entity 'x' should be
changed to its expansion text 'X', but the entity reference is just
detached from the parent.
This bug affects new tests in JCK 1.5 (not integrated yet)
api/org_w3c/dom/DOMConfiguration/index.html#Params[Entities002]
The bug is found in jdk1.5.0/beta/b30.
To reproduce the bug place test.java and test.xml to your current
directory, then compile and run test.java as shown in the log below:
------------------------------ test.java
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.DOMConfiguration;
import javax.xml.parsers.DocumentBuilderFactory;
class test {
public static void main(String [] args) throws Exception {
Document doc = DocumentBuilderFactory.newInstance()
.newDocumentBuilder().parse("test.xml");
Element root = doc.getDocumentElement();
root.appendChild(doc.createEntityReference("x"));
doc.getDomConfig().setParameter("entities", Boolean.FALSE);
doc.normalizeDocument();
Node child = root.getFirstChild();
if (child == null) {
System.out.println("root has no child,"
+ " but a text node with value 'X' is expected");
} else if (child.getNodeType() != Node.TEXT_NODE
|| !"X".equals(child.getNodeValue())) {
System.out.println("root's child is "
+ child.getClass().getName()
+ "[" + child.getNodeValue()
+ "], expected a text node with value 'X'");
} else {
System.out.println("OK");
}
}
}
----------------------------------------------------
------------------------------------------- test.xml
<?xml version="1.0"?>
<!DOCTYPE root [
ELEMENT root ANY
ENTITY x 'X'
]>
<root/>
----------------------------------------------------
------------------------------------------------ log
$javac test.java && java -cp . -showversion test
java version "1.5.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b30)
Java HotSpot(TM) Client VM (build 1.5.0-beta-b30, mixed mode)
root has no child, but a text node with value 'X' is expected
----------------------------------------------------
======================================================================
###@###.### 2003-12-08