Hallo,
ich mache gerade meine ersten SAX Schritte und bekomme beim einlesen einer XML-Datei immer eine Exception und das egal wie groß die XML-Datei ist. Ich habe keine Ahnung wie ich dieses Problem beheben soll, weil ich keinen Fehler sehe, auch nicht beim debuggen.
Mein simpler Code sieht so aus:
DIe Exception sieht so aus:
Habe auch schon mit -Xms und -Xmx Variablen herumexperimentiert, aber das klappt auch nicht.
Wäre super wenn mir jemand weiterhelfen könnte. Danke schon mal im voraus.
Viele Grüße,
Edfred
ich mache gerade meine ersten SAX Schritte und bekomme beim einlesen einer XML-Datei immer eine Exception und das egal wie groß die XML-Datei ist. Ich habe keine Ahnung wie ich dieses Problem beheben soll, weil ich keinen Fehler sehe, auch nicht beim debuggen.
Mein simpler Code sieht so aus:
Java:
import javax.xml.parsers.*;
import org.xml.sax.*;
import org.xml.sax.helpers.*;
import java.util.*;
import java.io.*;
public class XMLTest extends DefaultHandler{
private String filename = "blah.xml";
private HashMap<Object, Object> services;
private boolean dtdValidation = false;
public static void main(String[] args) {
new ProcessContent();
}
@Override
public void startDocument() throws SAXException{
System.out.println("Begin of Document");
services = new HashMap<Object, Object>();
}
@Override
public void startElement(String namespaceURI, String localName,
String qName, Attributes atts) throws SAXException {
System.out.println( "namespaceURI: " + namespaceURI );
System.out.println( "localName: " + localName );
System.out.println( "qName: " + qName );
// Attribute ausgeben
for( int i = 0; i < atts.getLength(); i++ ) {
System.out.print(" " + atts.getQName(i) + "=\"" + atts.getValue(i) + "\"");
}
}
@Override
public void endDocument() throws SAXException {
System.out.println("End of Document");
}
public XMLTest() {
SAXParserFactory parserFactory = SAXParserFactory.newInstance();
parserFactory.setNamespaceAware(true);
parserFactory.setValidating(dtdValidation);
File xmlFile = new File(filename);
try {
SAXParser parser = parserFactory.newSAXParser();
parser.parse(xmlFile, new XMLTest());
} catch (ParserConfigurationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SAXException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
DIe Exception sieht so aus:
Code:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at java.util.Vector.<init>(Vector.java:113)
at java.util.Vector.<init>(Vector.java:126)
at java.util.Vector.<init>(Vector.java:135)
at java.util.Stack.<init>(Stack.java:30)
at com.sun.org.apache.xerces.internal.xinclude.XIncludeHandler.<init>(XIncludeHandler.java:336)
at com.sun.org.apache.xerces.internal.parsers.XIncludeParserConfiguration.<init>(XIncludeParserConfiguration.java:155)
at com.sun.org.apache.xerces.internal.parsers.XIncludeParserConfiguration.<init>(XIncludeParserConfiguration.java:106)
at com.sun.org.apache.xerces.internal.parsers.JAXPConfiguration.<init>(JAXPConfiguration.java:30)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.<init>(SAXParserImpl.java:125)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl.newSAXParser(SAXParserFactoryImpl.java:98)
at XMLTest.<init>(XMLTest.java:49)
at XMLTest.<init>(XMLTest.java:50)
at XMLTest.<init>(XMLTest.java:50)
at XMLTest.<init>(XMLTest.java:50)
at XMLTest.<init>(XMLTest.java:50)
at XMLTest.<init>(XMLTest.java:50)
at XMLTest.<init>(XMLTest.java:50)
at XMLTest.<init>(XMLTest.java:50)
at XMLTest.<init>(XMLTest.java:50)
at XMLTest.<init>(XMLTest.java:50)
at XMLTest.<init>(XMLTest.java:50)
at XMLTest.<init>(XMLTest.java:50)
at XMLTest.<init>(XMLTest.java:50)
at XMLTest.<init>(XMLTest.java:50)
at XMLTest.<init>(XMLTest.java:50)
at XMLTest.<init>(XMLTest.java:50)
at XMLTest.<init>(XMLTest.java:50)
at XMLTest.<init>(XMLTest.java:50)
at XMLTest.<init>(XMLTest.java:50)
at XMLTest.<init>(XMLTest.java:50)
at XMLTest.<init>(XMLTest.java:50)
Habe auch schon mit -Xms und -Xmx Variablen herumexperimentiert, aber das klappt auch nicht.
Wäre super wenn mir jemand weiterhelfen könnte. Danke schon mal im voraus.
Viele Grüße,
Edfred