-
Bug
-
Resolution: Duplicate
-
P5
-
None
-
1.4.1
-
generic
-
generic
Name: eaR10174 Date: 06/22/2001
This bug is created specially for JCK Merlin-beta, because this version of JCK is
based on jdk1.4.0beta-b65 and the bug is found in this version of jdk. The bug has not
been found in version of jdk since jdk1.4.0beta-b66.
Method org.w3c.dom.Node.normalize() changes data of Text nodes when it is used to
normalize an Element node which has Text node children. All new-line, return and tab
symbols are replaced with space symbols and the sequence of space symbols are replaced
with a one space symbol (See test.java below). But the definition of this method doesn't
declare this
(http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-1950641247):
"normalize modified in DOM Level 2
Puts all Text nodes in the full depth of the sub-tree underneath this Node,
including attribute nodes, into a "normal" form where only structure (e.g.,
elements, comments, processing instructions, CDATA sections, and entity
references) separates Text nodes, i.e., there are neither adjacent Text nodes
nor empty Text nodes..."
This bug affects a new JCK Merlin-beta test:
api/org_w3c/dom/Node/index.html#Normalize[Normalize001]
------------------------------------ test.java ----------------------------
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
import org.w3c.dom.Document;
import org.w3c.dom.Text;
import org.w3c.dom.Element;
public class test {
public static void main(String argv[]) {
try {
Document doc = DocumentBuilderFactory.newInstance()
.newDocumentBuilder().newDocument();
Text text1 = doc.createTextNode("a \t\n");
Text text2 = doc.createTextNode(" b");
Element element = doc.createElement("test");
element.appendChild(text1);
element.appendChild(text2);
System.out.println("Before: " + text1.getData() + text2.getData());
element.normalize();
System.out.println("After: " + element.getFirstChild().getNodeValue());
} catch (Exception e) {
System.out.println(e.toString());
}
}
}
---------------------------------------------------------------------------
-------------------------- log of run -------------------------------------
% java -showversion test
java version "1.4.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b65)
Java HotSpot(TM) Client VM (build 1.4.0-beta-b65, mixed mode)
Before: a
b
After: a b
% java -showversion test
java version "1.4.0-beta_refresh"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta_refresh-b66)
Java HotSpot(TM) Client VM (build 1.4.0-beta_refresh-b66, mixed mode)
Before: a
b
After: a
b
---------------------------------------------------------------------------
======================================================================
- duplicates
-
JDK-4452425 DOM Element.normalize() normalizes whitespace when it should not
- Closed