org.openrdf.query.resultio.sparqlxml.SPARQLResultsXMLParserFactory Java Examples
The following examples show how to use
org.openrdf.query.resultio.sparqlxml.SPARQLResultsXMLParserFactory.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LDPathWrapper.java From fcrepo-camel-toolbox with Apache License 2.0 | 6 votes |
/** * Create an LDPathWrapper Object * @param backend the linkeddata backend */ public LDPathWrapper(final LDCacheBackend backend) { // Register the Sesame RDF Parsers manually // TODO: use the OSGi service registry as described in: // http://blog.osgi.org/2013/02/javautilserviceloader-in-osgi.html RDFParserRegistry.getInstance().add(new RDFXMLParserFactory()); RDFParserRegistry.getInstance().add(new NTriplesParserFactory()); RDFParserRegistry.getInstance().add(new TurtleParserFactory()); RDFParserRegistry.getInstance().add(new N3ParserFactory()); RDFParserRegistry.getInstance().add(new SesameJSONLDParserFactory()); RDFParserRegistry.getInstance().add(new RDFJSONParserFactory()); RDFParserRegistry.getInstance().add(new SesameRDFaParserFactory()); RDFParserRegistry.getInstance().add(new TriGParserFactory()); BooleanQueryResultParserRegistry.getInstance().add(new SPARQLBooleanXMLParserFactory()); TupleQueryResultParserRegistry.getInstance().add(new SPARQLResultsXMLParserFactory()); ldpath = new LDPath<Value>(backend); }
Example #2
Source File: SPARQLInferenceTest.java From neo4j-sparql-extension with GNU General Public License v3.0 | 6 votes |
@Before public void before() throws RepositoryException, IOException, RDFParseException, MalformedQueryException, QueryResultParseException, QueryResultHandlerException { repo = new SailRepository(new MemoryStore()); repo.initialize(); conn = repo.getConnection(); vf = conn.getValueFactory(); conn.add(getResource(data), "file://", RDFFormat.TURTLE); SPARQLResultsXMLParserFactory factory = new SPARQLResultsXMLParserFactory(); parser = factory.getParser(); parser.setValueFactory(vf); List<Rule> rules; rules = Rules.fromOntology(getResource(data)); QueryRewriter rewriter = new QueryRewriter(conn, rules); query = (TupleQuery) rewriter.rewrite(QueryLanguage.SPARQL, queryString); nonInfQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString); System.out.println("== QUERY (" + this.name + ") =="); System.out.println(nonInfQuery); System.out.println("== REWRITTEN QUERY (" + this.name + ") =="); System.out.println(query); }
Example #3
Source File: NanoSparqlClient.java From database with GNU General Public License v2.0 | 4 votes |
/** * Counts the #of results in a SPARQL result set. * * @param conn * The connection from which to read the results. * * @return The #of results. * * @throws Exception * If anything goes wrong. */ protected long countResults(final HttpURLConnection conn) throws Exception { final AtomicLong nsolutions = new AtomicLong(); try { final TupleQueryResultParser parser = new SPARQLResultsXMLParserFactory() .getParser(); parser .setTupleQueryResultHandler(new TupleQueryResultHandlerBase() { // Indicates the end of a sequence of solutions. @Override public void endQueryResult() { // connection close is handled in finally{} } // Handles a solution. @Override public void handleSolution(final BindingSet bset) { if (log.isDebugEnabled()) log.debug(bset.toString()); nsolutions.incrementAndGet(); } // Indicates the start of a sequence of Solutions. @Override public void startQueryResult(List<String> bindingNames) { } }); parser.parse(conn.getInputStream()); if (log.isInfoEnabled()) log.info("nsolutions=" + nsolutions); // done. return nsolutions.longValue(); } finally { // // terminate the http connection. // conn.disconnect(); } }