BTW, for arbitrary "dummy" or example graphs it might be better to name
them using example.com and friends (.org, .net) which are exactly for that
purpose. E.g.

SELECT ?s  WHERE {
GRAPH <http://example.com/graph1> {
  ?s ?p ?o .
}

That way it is more obvious to future readers of your code (e.g. your
future self!) that you deliberately did not mean the actual location on the
web.

In production, for similar arbitrary graphs which do not have a
corresponding web namespace, you can generate graph names like urn:uuid:
b213bf89-92be-42b9-9a6c-2566519c710c (see java.util.UUID) - which admitedly
are less fun for debugging, but unique, at least in the current solar
system.

These also have the "advantage" of not working at all with FROM.
On 13 May 2015 21:51, "Andrea Gazzarini" <[email protected]> wrote:

> Ok I got you, many thanks.
> I thought I could create a named graph with an arbitrary URI, put some data
> and then use that URI in the FROM keyword.
>
> Thanks again
> Andrea
> On 13 May 2015 22:36, "Andy Seaborne" <[email protected]> wrote:
>
> > On 13/05/15 20:16, Andrea Gazzarini wrote:
> >
> >> Hi Andy,
> >> Thank you very much for the explanation. But I still miss the point: as
> >> you
> >> said, the FROM keyword set / fills the default graph so assuming I
> >> previously loaded a triple under http://graph1.com
> >>
> >> Running
> >>
> >> SELECT ?s FROM <http://graph1.com> { ?s ?p ?o }
> >>
> >> I should get the subject of that triple. Is that correct? Because the
> code
> >> above is running under this exact scenario and I'm getting no result.
> >>
> >
> > It will do an HTTP GET on http://graph1.com -- it does not get it from
> > the dataset because its the dataset to be queried that is being
> described.
> >
> > (graph1.com happens to exist and it returns junk.)
> >
> >         Andy
> >
> >
> >> Kind Regards,
> >> Andrea
> >> On 13 May 2015 21:05, "Andy Seaborne" <[email protected]> wrote:
> >>
> >>  FROM describes the dataset to use.
> >>>
> >>> GRAPH accesses the data.
> >>>
> >>> FROM <http://example/data> set the default graph from the contents of
> >>> http://example/data by reading that URL. (This is for the general
> >>> purpose
> >>> dataset - TDB is slightly different but the principle is the same)
> >>>
> >>>          Andy
> >>>
> >>> On 13/05/15 18:57, Andrea Gazzarini wrote:
> >>>
> >>>  Hi Trevor,
> >>>> Thanks, yes that works...but I would like to understand what is wrong
> >>>> with
> >>>> my example
> >>>>
> >>>> Thanks again
> >>>> Andrea
> >>>> On 13 May 2015 19:54, "Trevor Donaldson" <[email protected]> wrote:
> >>>>
> >>>>   Hi Andrea,
> >>>>
> >>>>>
> >>>>> Can I suggest trying this ..
> >>>>>
> >>>>> SELECT ?s
> >>>>> WHERE {
> >>>>>     GRAPH <http://graph1.com> {
> >>>>>     ?s ?p ?o
> >>>>>    }
> >>>>> }
> >>>>>
> >>>>> On Wed, May 13, 2015 at 1:26 PM, Andrea Gazzarini <[email protected]>
> >>>>> wrote:
> >>>>>
> >>>>>   Hi,
> >>>>>
> >>>>>> A question about the FROM keyword. I have the following data
> >>>>>>
> >>>>>> <http://graph1.com> = { <http://a.b.c/s1> <http://a.b.c/p1> <
> >>>>>> http://a.b.c/o1>
> >>>>>> . }
> >>>>>> <http://graph2.com> = { <http://a.b.c/s2> <http://a.b.c/p2> <
> >>>>>> http://a.b.c/o2>
> >>>>>> . }
> >>>>>>
> >>>>>> For simplicity, I created a file for each triple (file1.nt and
> >>>>>> file2.nt).
> >>>>>> Then, I loaded those data using the following code:
> >>>>>>
> >>>>>> Dataset memoryDataset = DatasetFactory.createMem();
> >>>>>> Model memoryModel = ModelFactory.createDefaultModel();
> >>>>>> memoryModel.read(new FileReader("file1.nt"), "http://e.org";,
> >>>>>>
> >>>>>>  "N-TRIPLE");
> >>>>>
> >>>>>  memoryDataset.addNamedModel("http://graph1.com";, memoryModel);
> >>>>>>
> >>>>>> memoryModel = ModelFactory.createDefaultModel();
> >>>>>> memoryModel.read(new FileReader("file2.nt"), "http://e.org";,
> >>>>>>
> >>>>>>  "N-TRIPLE");
> >>>>>
> >>>>>  memoryDataset.addNamedModel("http://graph2.com";, memoryModel);
> >>>>>>
> >>>>>> I'm not understanding the results coming from the following query:
> >>>>>>
> >>>>>> SELECT ?s FROM <http://graph1.com> { ?s ?p ?o }
> >>>>>>
> >>>>>> ?s = <nothing>
> >>>>>>
> >>>>>> I was expecting
> >>>>>>
> >>>>>> ?s=<http://a.b.c/s1>
> >>>>>>
> >>>>>> Am I missing something? I'm using Jena 2.12.1
> >>>>>>
> >>>>>> Thanks in advance for your help
> >>>>>> Andrea
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>
> >>>>
> >>>
> >>
> >
>

Reply via email to