That resolves the issue, thanks for your help! —Brad
On Feb 19, 2014, at 3:45 PM, Andy Seaborne <[email protected]> wrote: > On 19/02/14 19:50, Brad Moran wrote: >> Thanks for your prompt reply. I see what you are saying, so I tried: >> >> tdbloader —set http://jena.hpl.hp.com/TDB#unionDefaultGraph=true >> —loc=TDBLocation —graph=‘<graph/named#graphName1>’ rdfFile.ttl > > "--graph=http://example/graph/named#graphName1" > >> >> then tried to query it: >> >> “PREFIX GRAPH: <graph/named#> SELECT * FROM NAMED graph:graphName1 WHERE{ >> GRAPH graph:graphName1 {?s ?p ?o} }” >> >> But still receive an empty result set. So two questions remain: >> >> 1. Am I not creating the absolute URI correctly? > > Absolute URIs start with a scheme, > >> 2. Is there a commonly used base URI for named graphs that I could be >> using or should I just make my own as I tried to do? > > Are you going to be letting this data out to other apps? > > If not, then anything that does not clash with the data. > > Andy > >> >> >> Thanks, >> Brad >> >> On Feb 18, 2014, at 4:29 AM, Andy Seaborne <[email protected]> wrote: >> >>> On 18/02/14 00:35, Brad Moran wrote: >>>> Hi, >>>> >>>> I am loading data into a TDB as named graphs via command line tdbloader >>>> utility with unionDefaultGraph flag specified true for example: >>>> >>>> tdbloader —set http://jena.hpl.hp.com/TDB#unionDefaultGraph=true >>>> —loc=TDBLocation —graph=‘graphName1’ rdfFile.ttl >>>> tdbloader —set http://jena.hpl.hp.com/TDB#unioncDefaultGraph=true >>>> —loc=TDBLocation —graph=‘graphName2’ rdfFile2.ttl >>>> >>>> Then I can successfully query to get everything from the union graph with >>>> the following SPARQL: >>>> “SELECT ?s ?p ?o ?g WHERE{ GRAPH ?g{ ?s ?p ?o} }" >>>> >>>> But now I want to query for data from just one of the named graphs. From >>>> the SPARQL tutorial in Jena documentation I tried: >>>> >>>> “SELECT ?s ?p ?o FROM NAMED <graphName1> WHERE{ GRAPH <graphName1> {?s >>>> ?p ?o} }” >>>> >>>> However, it returns 0 results. >>>> >>>> I also tried: >>>> >>>> “SELECT ?s ?p ?o FROM NAMED <graphName1> WHERE{ ?s ?p ?o }” >>>> >>>> and >>>> >>>> “SELECT ?s ?p ?o WHERE{ GRAPH <graphName1> {?s ?p ?o} }” >>>> >>>> and >>>> >>>> “SELECT ?s ?p ?o ?g FROM NAMED <graphName1> WHERE{ GRAPH ?g {?s ?p ?o} >>>> }” >>>> >>>> But none of the queries produce any results. I am wondering if maybe >>>> setting the flag unionDefaultGraph to true is incorrect for my purpose? I >>>> want to be able to query all graphs at once, but also be able to query >>>> individual named graphs. >>>> >>>> Thanks, >>>> Brad >>> >>> This is not related to unionDefaultGraph. >>> >>> When the SPARQL parser sees >>> >>> SELECT * FROM NAMED <graphName1> WHERE{ GRAPH ?g {?s ?p ?o} } >>> >>> then <graphName1> will be resolved against the base URI. There is always a >>> base URI but if you don't specify it it is something unhelpful like the >>> file: URI of the current directory. >>> >>> The loader, seeing —graph="graphName1", isn't going near a parser so that >>> is the URI and it is not resolved. The URI is just "graphName1" and does >>> not match <graphName1> >>> >>> Example: >>> Printing queries respects implicit the base URI so it get turned back into >>> <g> but the algebra printing does not >>> >>> qparse --print=op 'SELECT * { GRAPH <g> { ?s ?p ?o } }' >>> >>> which gives, for me: >>> >>> (graph <file:///home/afs/g> >>> (bgp (triple ?s ?p ?o))) >>> >>> <g> ==> <file:///home/afs/g> >>> >>> >>> Use an absolute URI for the graph name in tdbloader operation and a prefix >>> in the query to make the GRAPH .. look nice. >>> >>> Andy >>> >> >
