Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Duplicate
-
None
-
None
-
None
Description
Parsing a document with a big CDATA section (about 25MB) with the feature "http://apache.org/xml/features/dom/defer-node-expansion" set to false, cause an infinite loop.
Use this test class on the attachment.
package test;
import java.io.File;
import java.io.FileInputStream;
import java.util.concurrent.TimeUnit;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.xpath.XPathExpression;
import javax.xml.xpath.XPathFactory;
import org.w3c.dom.Document;
public class BigCData {
public static void main(String[] args) throws Exception {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(
"org.apache.xerces.jaxp.DocumentBuilderFactoryImpl", BigCData.class.getClassLoader());
factory.setNamespaceAware(true);
factory.setValidating(false);
try
catch (Throwable ex)
{ System.err.println("Cannot set IGNORE DTD feature. You can have performace problems."); }XPathExpression xpath = XPathFactory.newInstance().newXPath().compile("//style");
long t0 = System.nanoTime();
File file = new File("/Users/maurizio/Downloads/web_dossier_mars.xml");
Document doc = factory.newDocumentBuilder().parse(new FileInputStream(file));
long dt = System.nanoTime() - t0;
System.out.println(TimeUnit.NANOSECONDS.toMillis(dt) + " parse > " + doc);
String nodeValue = xpath.evaluate(doc);
dt = System.nanoTime() - t0;
System.out.println(TimeUnit.NANOSECONDS.toMillis(dt) + " xpath > " + nodeValue.length());
}
}
Attachments
Attachments
Issue Links
- duplicates
-
XERCESJ-1382 Performance problem in org.apache.xerces.dom.CharacterDataImpl appendData
- Open