我使用StAX解析器解析非常大的XML文件,這個我已經寫禁用功能安全處理XML的
public class XmlWrite {
public static void main(String[] args) throws
IOException,XMLStreamException {
FileWriter fw = null;
FileReader page = new FileReader("pages142");
XMLInputFactory factory = XMLInputFactory.newInstance();
//factory.setProperty(XMLConstants.FEATURE_SECURE_PROCESSING,false);
XMLEventReader eventReader = factory.createXMLEventReader(page);
boolean flag = false;
int no = 1;
while(eventReader.hasNext()) {
XMLEvent event = eventReader.nextEvent();
.........
此代碼工作正常上一個小的輸入文件,但對於代碼一個大的文件時,它提供了以下錯誤
Exception in thread "main" javax.xml.stream.XMLStreamException:
ParseError at [row,col]:[44018907,204]
Message: JAXP00010004: The accumulated size of entities is
"50,000,001" that exceeded the "50,000,000" limit set by
"FEATURE_SECURE_PROCESSING".
at com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.next(XMLStreamReaderImpl.java:604) at com.sun.xml.internal.stream.XMLEventReaderImpl.nextEvent(XMLEventReaderImpl.java:83) at XmlWrite.main(XmlWrite.java:28)
我試過factory.setProperty,但同樣是不working.Is有在整個使用JVM禁用安全處理任何手段?
我有同樣的問題。我找到了答案:[這裏](https://stackoverflow.com/questions/42991043/error-xml-sax-saxparseexception-while-parsing-a-xml-file-using-wikixmlj) –