I'm going to split an XML file into multiple XML files, So I need an xmlStreamReader. While using XmlStreamReader it throws Exception Limit Reached. The XML Security Manager set some limitation for reading files.
I already tried setting up property FEATURE_SECURE_PROCESSING false. But it is not recognized by XmlInputFactory
XMLInputFactory xmlInputFactory = XMLInputFactory.newFactory();
xmlInputFactory.setProperty(XMLConstants.FEATURE_SECURE_PROCESSING, false);
I expect the XML Streaming Parser with no limitation of reading huge files
I have found the answer, Use Saxparser which supports a handler to parse the XML data also FEATURE_SECURE_PROCESSING can be disabled in SaxParser.
class ParserHandler extends org.xml.sax.helpers.DefaultHandler{
@Override
public void startDocument() throws SAXException {
// your operation
}
//other methods
}
ParserHandler handler = new ParserHandler();
SAXParserFactory factory = SAXParserFactory.newInstance();
factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, false);
SAXParser saxParser = factory.newSAXParser();
saxParser.parse(file, handler);