Rob & Andy responded on JIRA:
https://issues.apache.org/jira/browse/JENA-1135

TDB happens to pick it's FROM graphs from the local dataset whereas the
> general purpose dataset reads them from the web and<urn:graph> is not HTTP
> GET'able.



Fuseki makes in-memory behave like TDB though it is not a good idea to rely
> on this.
>


GRAPH, or setting up a ad-hoc dataset to query, is the way to do it.


On Tue, Feb 9, 2016 at 2:25 PM, Todd Schiller <[email protected]>
wrote:

> I'm trying to query a named graph in an in-memory dataset using SPARQL.
> What is the correct way to refer to the named graph in the FROM clause?
> Enclosing the graph's name (a URN) in braces isn't working for me (see
> reproduction below).
>
> I suspect it has something to do with how the in-memory dataset resolves
> the FROM clause (cf.
> https://jena.apache.org/tutorials/sparql_datasets.html)? I don't have
> problems when using a TDB-backed dataset.
>
> Tracking as: https://issues.apache.org/jira/browse/JENA-1135
>
> Thanks,
> Todd
>
> ======= Jena 3.0.1
>
> import org.apache.jena.query.*;
> import org.apache.jena.rdf.model.*;
> import org.apache.jena.vocabulary.RDFS;
>
> public class GraphTest {
>     public static void main(String [] args) {
>         Dataset data = DatasetFactory.create();
>
>         Model model = ModelFactory.createDefaultModel();
>         model.getResource("urn:foo").addLiteral(RDFS.label, "foobar");
>         data.addNamedModel("urn:graph", model);
>
>         String sparql = "SELECT ?s ?p ?o FROM <urn:graph> WHERE { ?s ?p ?o
> }";
>         ResultSet results = QueryExecutionFactory.create(sparql,
> data).execSelect();
>         int cnt = 0;
>         while (results.hasNext()) {
>             cnt++;
>             results.next();
>         }
>
>         // should both print 1
>         System.out.println("# results: " + cnt); // prints 0
>         System.out.println("Model size: " +
> data.getNamedModel("urn:graph").size()); // prints 1
>     }
> }
>

Reply via email to