if (filename != null) {
try {
RDFParser parser = Rio.createParser(SesameTestHelper.detectFileFormat(filename));
parser.setRDFHandler(new ContextStatementCollector(model, ValueFactoryImpl.getInstance()));
ParserConfig config = parser.getParserConfig();
config.set(BasicParserSettings.PRESERVE_BNODE_IDS, true);
config.addNonFatalError(BasicParserSettings.VERIFY_DATATYPE_VALUES);
config.addNonFatalError(BasicParserSettings.VERIFY_LANGUAGE_TAGS);
// Attempt to normalize known datatypes, including XML Schema
config.set(BasicParserSettings.NORMALIZE_DATATYPE_VALUES, true);
// Try not to fail when normalization fails
config.addNonFatalError(BasicParserSettings.NORMALIZE_DATATYPE_VALUES);
ParseErrorCollector errors = new ParseErrorCollector();
parser.setParseErrorListener(errors);
parser.parse(openStreamForResource(filename), baseUri);