Examples of LangRIOT


Examples of org.apache.jena.riot.lang.LangRIOT

            URI baseURI = step.getNode().getBaseURI();
            URL url = baseURI.resolve(href).toURL();
            URLConnection conn = url.openConnection();

            StreamRDF dest = StreamRDFLib.dataset(dataset.asDatasetGraph());
            LangRIOT parser = RiotReader.createParser(conn.getInputStream(), lang, href, dest);
            ErrorHandler handler = new ParserErrorHandler(href);
            ParserProfile prof = RiotLib.profile(lang, href, handler);
            parser.setProfile(prof);
            try {
                parser.parse();
            } catch (Exception e) {
                logger.warn("Parse error in RDFLoad document; processing partial document");
                logger.debug(e.getMessage(), e);
            }
            conn.getInputStream().close();
View Full Code Here

Examples of org.apache.jena.riot.lang.LangRIOT

           
            outStream.println("<h1>RIOT Parser Report</h1>") ;
            outStream.println("<p>Line and column numbers refer to original input</p>") ;
            outStream.println("<p>&nbsp;</p>") ;
            try {
                LangRIOT parser = setupParser(tokenizer, language, errorHandler, outStream) ;
                startFixed(outStream) ;
                RiotException exception = null ;
                try {
                    parser.parse() ;
                    System.out.flush() ;
                    System.err.flush() ;
                } catch (RiotException ex) { exception = ex ; }
            } finally
            {
View Full Code Here

Examples of org.apache.jena.riot.lang.LangRIOT

            public void flush() {}
            String formatNode(Node n) { return FmtUtils.stringForNode(n, sCxt) ; }
        } ;

        StreamRDF dest = StreamRDFLib.sinkQuads(sink) ;
        @SuppressWarnings("deprecation")
        LangRIOT parser = RiotReader.createParser(tokenizer, language, null, dest) ;
        // Don't resolve IRIs.  Do checking.
        parser.setProfile(RiotLib.profile(null, false, true, errorHandler)) ;
        return parser ;
    }
View Full Code Here

Examples of org.apache.jena.riot.lang.LangRIOT

        action.beginWrite() ;
        try {
            String name = action.request.getRequestURL().toString() ;
            DatasetGraph dsg = action.getActiveDSG() ;
            StreamRDF dest = StreamRDFLib.dataset(dsg) ;
            LangRIOT parser = RiotReader.createParser(action.request.getInputStream(), lang, name , dest) ;
            parser.parse() ;
            action.commit();
            success(action) ;
        } catch (IOException ex) { action.abort() ; }
        finally { action.endWrite() ; }
    }
View Full Code Here

Examples of org.apache.jena.riot.lang.LangRIOT

            // This should not be anythign other than the datasets name via this route. 
            String name = action.request.getRequestURL().toString() ;
            //log.info(format("[%d] ** Content-length: %d", action.id, action.request.getContentLength())) ; 
            Graph g = dsg.getDefaultGraph() ;
            StreamRDF dest = StreamRDFLib.graph(g) ;
            LangRIOT parser = RiotReader.createParser(action.request.getInputStream(), lang, name , dest) ;
            parser.parse() ;
            action.commit();
            success(action) ;
        } catch (IOException ex) { action.abort() ; }
        finally { action.endWrite() ; }
    }
View Full Code Here

Examples of org.apache.jena.riot.lang.LangRIOT

                name = name+ "/"  ;
            name = name+(++counter) ;
            Node gn = NodeFactory.createURI(name) ;
            Graph g = dsg.getGraph(gn) ;
            StreamRDF dest = StreamRDFLib.graph(g) ;
            LangRIOT parser = RiotReader.createParser(action.request.getInputStream(), lang, name , dest) ;
            parser.parse() ;
            log.info(format("[%d] Location: %s", action.id, name)) ;
            action.response.setHeader("Location",  name) ;
            action.commit();
            successCreated(action) ;
        } catch (IOException ex) { action.abort() ; }
View Full Code Here

Examples of org.openjena.riot.lang.LangRIOT

       
        // --- Or create a parser and do the parsing as separate steps.
        String baseURI = "http://example/base" ;
           
        in = new FileInputStream("data.trig") ;
        LangRIOT parser = RiotReader.createParserQuads(in, Lang.TRIG, "http://example/base", noWhere) ;
       
        // Parser to first error or warning.
        ErrorHandler errHandler = ErrorHandlerFactory.errorHandlerStrict ;

        // Now enable stricter checking, even N-TRIPLES must have absolute URIs.
        ParserProfile profile = RiotLib.profile(baseURI, true, true, errHandler) ;

        // Just set the error handler.
        parser.getProfile().setHandler(errHandler) ;
       
        // Or replave the whole parser profile.
        parser.setProfile(profile) ;

        // Do the work.
        parser.parse() ;
    }
View Full Code Here

Examples of org.openjena.riot.lang.LangRIOT

      
        Lang lang = FusekiLib.langFromContentType(ts.getMediaType()) ;
        if ( lang == null )
            throw new FusekiException("Unknown lang for "+ts.getMediaType()) ;
        Sink<Triple> sink = new SinkTriplesToGraph(graph) ;
        LangRIOT parser = RiotReader.createParserTriples(ts, lang, base, sink) ;
        parser.parse() ;
        IO.close(ts) ;
    }   
View Full Code Here

Examples of org.openjena.riot.lang.LangRIOT

        sink = new SinkLimited<Triple>(sink, limit) ;
       
        // TODO Conneg - awaiting RIOT code upgrade.
        InputStream input = Fuseki.webFileManager.open(uri) ;
       
        LangRIOT parser = RiotReader.createParserTriples(input, lang, uri, sink) ;
        try {
            parser.parse() ;
        } catch (RiotException ex) { throw ex ; }
    }
View Full Code Here

Examples of org.openjena.riot.lang.LangRIOT

                   
                    String base = "http://example/upload-base/" ;
                    // We read into a in-memory graph, then (if successful) update the dataset.
                    // This isolates errors.
                    Sink<Triple> sink = new SinkTriplesToGraph(graphTmp) ;
                    LangRIOT parser = RiotReader.createParserTriples(stream, lang, base, sink) ;
                    parser.getProfile().setHandler(errorHandler) ;
                    try {
                        parser.parse() ;
                    }
                    catch (RiotException ex) { errorBadRequest("Parse error: "+ex.getMessage()) ; }
                    finally { sink.close() ; }
                   
                    tripleCount = graphTmp.size() ;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.