Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2116265 | 5.0 | Ramesh Mandava | P3 | Resolved | Fixed | b30 |
Name: apR10229 Date: 09/24/2003
Filed By : SPB JCK team (###@###.###)
JDK : java full version "1.5.0-beta-b20"
JCK : 1.5
Platform[s] : Solaris
switch/Mode :
JCK test owner : http://javaweb.eng/jct/sqe/JCK-tck/usr/owners.jto
Failing Test [s] : N/A
Problem description
===================
DOMParser implementation call DOMParserFilter.acceptNode() twice.
For the following xml source:
<ROOT><CHILD/></ROOT>
when we implement DOMParserFilter and set it to a DOMParser,
implementation of DOMParser call acceptNode() twice for element CHILD.
This looks like an undefined behavior of DOMParser implementation.
Minimized test:
===============
------- Test.java -------
import java.io.*;
import org.w3c.dom.ls.*;
import org.w3c.dom.*;
import javax.xml.parsers.*;
import org.xml.sax.*;
import org.w3c.dom.traversal.*;
public class Test {
public static void main(String[] argv) {
String xml = "<ROOT><CHILD/></ROOT>";
System.out.println("Applying filter to: "+xml);
DocumentBuilder parser = null;
Document doc = null;
try {
parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
doc = parser.parse(new StringBufferInputStream(xml));
} catch (Throwable e) {
e.printStackTrace();
}
DOMImplementationLS implLS = (DOMImplementationLS) doc.getImplementation().getFeature("LS","3.0");
DOMParser dp = implLS.createDOMParser(DOMImplementationLS.MODE_SYNCHRONOUS,null);
DOMInput src = implLS.createDOMInput();
src.setStringData(xml);
dp.setFilter(
new DOMParserFilter() {
public short startElement(Element elt) {
System.out.println("StartElement: "+elt.getTagName());
return FILTER_ACCEPT;
}
public short acceptNode(Node enode) {
System.out.println("AcceptNode: "+enode.getNodeName());
return FILTER_ACCEPT;
}
public int getWhatToShow() {
return NodeFilter.SHOW_ALL;
}
}
);
dp.parse(src);
}
}
------- end-of-Test.java -------
Minimized test output:
======================
<pav@hammer(pts/3).258> java Test
Applying filter to: <ROOT><CHILD/></ROOT>
StartElement: ROOT
StartElement: CHILD
AcceptNode: CHILD
AcceptNode: CHILD
AcceptNode: ROOT
JCK test source location:
==========================
/java/re/jck/1.5/promoted/latest/JCK-runtime-15/tests
Specific Machine Info:
=====================
SunOS orion 5.9 Generic_112233-03 sun4u sparc SUNW,Ultra-Enterprise
======================================================================
Filed By : SPB JCK team (###@###.###)
JDK : java full version "1.5.0-beta-b20"
JCK : 1.5
Platform[s] : Solaris
switch/Mode :
JCK test owner : http://javaweb.eng/jct/sqe/JCK-tck/usr/owners.jto
Failing Test [s] : N/A
Problem description
===================
DOMParser implementation call DOMParserFilter.acceptNode() twice.
For the following xml source:
<ROOT><CHILD/></ROOT>
when we implement DOMParserFilter and set it to a DOMParser,
implementation of DOMParser call acceptNode() twice for element CHILD.
This looks like an undefined behavior of DOMParser implementation.
Minimized test:
===============
------- Test.java -------
import java.io.*;
import org.w3c.dom.ls.*;
import org.w3c.dom.*;
import javax.xml.parsers.*;
import org.xml.sax.*;
import org.w3c.dom.traversal.*;
public class Test {
public static void main(String[] argv) {
String xml = "<ROOT><CHILD/></ROOT>";
System.out.println("Applying filter to: "+xml);
DocumentBuilder parser = null;
Document doc = null;
try {
parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
doc = parser.parse(new StringBufferInputStream(xml));
} catch (Throwable e) {
e.printStackTrace();
}
DOMImplementationLS implLS = (DOMImplementationLS) doc.getImplementation().getFeature("LS","3.0");
DOMParser dp = implLS.createDOMParser(DOMImplementationLS.MODE_SYNCHRONOUS,null);
DOMInput src = implLS.createDOMInput();
src.setStringData(xml);
dp.setFilter(
new DOMParserFilter() {
public short startElement(Element elt) {
System.out.println("StartElement: "+elt.getTagName());
return FILTER_ACCEPT;
}
public short acceptNode(Node enode) {
System.out.println("AcceptNode: "+enode.getNodeName());
return FILTER_ACCEPT;
}
public int getWhatToShow() {
return NodeFilter.SHOW_ALL;
}
}
);
dp.parse(src);
}
}
------- end-of-Test.java -------
Minimized test output:
======================
<pav@hammer(pts/3).258> java Test
Applying filter to: <ROOT><CHILD/></ROOT>
StartElement: ROOT
StartElement: CHILD
AcceptNode: CHILD
AcceptNode: CHILD
AcceptNode: ROOT
JCK test source location:
==========================
/java/re/jck/1.5/promoted/latest/JCK-runtime-15/tests
Specific Machine Info:
=====================
SunOS orion 5.9 Generic_112233-03 sun4u sparc SUNW,Ultra-Enterprise
======================================================================
- backported by
-
JDK-2116265 DOMParser implementation calls DOMParserFilter.acceptNode() twice
-
- Resolved
-