[英]Null pointer Exception in Uploading the xml file
I have the following code: 我有以下代码:
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);
}
The marked line gives Null pointer Exception while parser
, schemaInput
and validator
contaning the objects not the null value. 标记行给出空指针异常而
parser
, schemaInput
和validator
contaning对象不为空值。
Why this line gives the null pointer exception? 为什么这一行给出空指针异常?
To use the validating parser, make the following changes: 要使用验证解析器,请进行以下更改:
spfactory.setValidating(true);
By default the value of this is set to false. 默认情况下,此值设置为false。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.