You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by bu...@apache.org on 2001/12/10 16:15:25 UTC
DO NOT REPLY [Bug 5338] New: -
Element.getElementByTagName() does not return all nodes
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=5338>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=5338
Element.getElementByTagName() does not return all nodes
Summary: Element.getElementByTagName() does not return all nodes
Product: Xerces-J
Version: 1.4.4
Platform: All
OS/Version: All
Status: NEW
Severity: Critical
Priority: Other
Component: DOM
AssignedTo: xerces-j-dev@xml.apache.org
ReportedBy: epietrig@w3.org
I've written a very simple test that parses a big SVG document as a DOM.
I then asks all "path" elements from the root element using
getElementByTagName("path"). On small documents (e.g. containing 621 "path"
elements, it works fine). On bigger documents (e.g. 1303 occurences of "path"),
I only get 709 of them).
I was able to reproduce this bug with the following versions of Xerces-J 1.3.1,
1.4.0, 1.4.4 (I haven't tried others).
using Sun's JVM, both versions 1.3.1_01 and 1.4.0beta3 (b84)
I can provide you with the SVG document on which to run the test if you want it
(it's about 600 Kb).
Here's the source code for my test.
This is huge! Hope you can solve it.
Emmanuel
//Author: Emmanuel Pietriga (emmanuel.pietriga@xrce.xerox.com,epietrig@w3.org)
//Created: 12/10/2001
import org.apache.xerces.parsers.DOMParser;
import org.w3c.dom.*;
import org.xml.sax.*;
public class Test {
DOMParser parser;
static String argFile;
Test(){
System.err.println("Parsing "+argFile);
Document d=parse(argFile,true);
Element svgRoot=d.getDocumentElement();
NodeList l1=svgRoot.getElementsByTagName("a");
NodeList l2=svgRoot.getElementsByTagName("ellipse");
NodeList l3=svgRoot.getElementsByTagName("path");
System.out.println("a="+l1.getLength());
System.out.println("ellipse="+l2.getLength());
System.out.println("path="+l3.getLength());
}
Document parse(String xmlFile,boolean validation) {
try {
parser = new DOMParser();
if (validation)
{parser.setFeature("http://xml.org/sax/features/validation",true);}
else
{parser.setFeature("http://xml.org/sax/features/validation",false);}
parser.setFeature("http://apache.org/xml/features/dom/include-ignorable-whitespa
ce", false);
try {
parser.parse(xmlFile);
}
catch (SAXException se) {
//se.printStackTrace();
}
catch (java.io.IOException ioe) {
ioe.printStackTrace();
}
Document document = parser.getDocument();
document.normalize();
return document;
}
catch (Exception e){
System.err.println(e);
return null;
}
}
public static void main(String[] args){
System.out.println("JVM version:
"+System.getProperty("java.vm.vendor")+" "+System.getProperty("java.vm.name")+"
"+System.getProperty("java.vm.version"));
argFile=args[0];
Test appli=new Test();
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org