Followup question to Big XML File:
First thanks a lot for yours answers. After… what I do wrong? This is my class which uses SAX:
public class SAXParserXML extends DefaultHandler {
public static void ParcourXML() {
DefaultHandler handler = new SAXParserXML();
SAXParserFactory factory = SAXParserFactory.newInstance();
try {
String URI = "dblp.xml";
SAXParser saxParser = factory.newSAXParser();
saxParser.parse(URI,handler);
} catch (Throwable t) {
t.printStackTrace ();
}
}
public void startElement (String namespaceURI,String simpleName,String qualifiedName,Attributes attrs) throws SAXException {
}
public void endElement (String namespaceURI,String simpleName,String qualifiedName) throws SAXException {
}
}
You can see that I do nothing with my XML file but it gives this error:
java.lang.OutOfMemoryError: Java heap space
at com.sun.org.apache.xerces.internal.util.XMLStringBuffer.append(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.refresh(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.invokeListeners(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.peekChar(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at SAXParserXML.ParcourXML(SAXParserXML.java:30)
at Main.main(Main.java:28)
I tried also Stax…the same error… what can I do? Also I increased the Java heap size up to 1260M
java -Xmx1260M SAXParserXML
the XML file has this form:
<dblp>
<incollection>
<author>... </author>
....
<author>... </author>
#other tags-i'm interested only by <author>#
...
</incollection>
<incollection>
# the same thing#
</incollection>
....
</dblp>
You can find the original file: http://dblp.uni-trier.de/xml/
Thanks