我有以下代码:
L2SchemaHandler handler = getSchemaHandler();
// validate
XMLFormatValidator validator = new XMLFormatValidator(handler.elements, handler.types, handler.root);
InputStream schemaInput = new FileInputStream(new File(xmlFilePath));
SAXParserFactory spfactory = SAXParserFactory.newInstance();
spfactory.setFeature("http://xml.org/sax/features/namespaces", true);
SAXParser parser = spfactory.newSAXParser();
//this line gives the null pointer Exception
parser.parse(schemaInput, validator);
report.addAll(validator.getReport());
this.objectsList = validator.getObjectList();
// When we know objects are valid, get duplicate objects from db
if(report.isEmpty())
duplicateObjectsMap = validateObjectID(validator.getObjects(),report);
// here we need to check whether object id's exists in db
if(report.isEmpty()){//if no errors have occurred
// if(validateObjectID(validator.getObjects(),report))
validateObjectsFromFile(validator.getObjects(), report , msgreport);
}
标记的行给出Null 指针 Exception while parser
,schemaInput
并且validator
包含不是空值的对象。
为什么这一行给出空指针异常?