Package org.openrdf.rio.helpers

Examples of org.openrdf.rio.helpers.ParseErrorCollector


        final String inputstring = "{ \"@id\":\"http://nonexistent.com/abox#Document1823812\", \"@type\":\"http://nonexistent.com/tbox#Document\" }";
        final String expectedString = "(http://nonexistent.com/abox#Document1823812, http://www.w3.org/1999/02/22-rdf-syntax-ns#type, http://nonexistent.com/tbox#Document) [null]";
        final Object input = JsonUtils.fromString(inputstring);

        final Graph graph = new LinkedHashModel();
        final ParseErrorCollector parseErrorListener = new ParseErrorCollector();
        final ParserConfig parserConfig = new ParserConfig();
        final SesameTripleCallback callback = new SesameTripleCallback(
                new StatementCollector(graph), ValueFactoryImpl.getInstance(), parserConfig,
                parseErrorListener);

        JsonLdProcessor.toRDF(input, callback);

        final Iterator<Statement> statements = graph.iterator();

        // contains only one statement (type)
        while (statements.hasNext()) {
            final Statement stmt = statements.next();

            System.out.println(stmt.toString());
            assertEquals("Output was not as expected", stmt.toString(), expectedString);
        }

        assertEquals(0, parseErrorListener.getFatalErrors().size());
        assertEquals(0, parseErrorListener.getErrors().size());
        assertEquals(0, parseErrorListener.getWarnings().size());
    }
View Full Code Here


                // 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);

                for(String nextFatalError : errors.getFatalErrors()) {
                    System.err.println("Fatal parse error was ignored : " + filename + " : "+ nextFatalError);
                }
                for(String nextError : errors.getErrors()) {
                    System.err.println("Parse error was ignored : " + filename + " : "+ nextError);
                }
                for(String nextWarning : errors.getWarnings()) {
                    System.err.println("Parse warning was ignored : " + filename + " : "+ nextWarning);
                }
            } catch (OpenRDFException e) {
                System.err.println("Fatal parse error caused failure : " + filename + " : "+ e.getMessage());
                //e.printStackTrace();
View Full Code Here

        final String inputstring = "{ \"@id\":\"http://nonexistent.com/abox#Document1823812\", \"@type\":\"http://nonexistent.com/tbox#Document\" }";
        final String expectedString = "(http://nonexistent.com/abox#Document1823812, http://www.w3.org/1999/02/22-rdf-syntax-ns#type, http://nonexistent.com/tbox#Document) [null]";
        final Object input = JSONUtils.fromString(inputstring);

        final Graph graph = new LinkedHashModel();
        final ParseErrorCollector parseErrorListener = new ParseErrorCollector();
        final ParserConfig parserConfig = new ParserConfig();
        final SesameTripleCallback callback = new SesameTripleCallback(
                new StatementCollector(graph), ValueFactoryImpl.getInstance(), parserConfig,
                parseErrorListener);

        JsonLdProcessor.toRDF(input, callback);

        final Iterator<Statement> statements = graph.iterator();

        // contains only one statement (type)
        while (statements.hasNext()) {
            final Statement stmt = statements.next();

            System.out.println(stmt.toString());
            assertEquals("Output was not as expected", stmt.toString(), expectedString);
        }

        assertEquals(0, parseErrorListener.getFatalErrors().size());
        assertEquals(0, parseErrorListener.getErrors().size());
        assertEquals(0, parseErrorListener.getWarnings().size());
    }
View Full Code Here

TOP

Related Classes of org.openrdf.rio.helpers.ParseErrorCollector

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.