You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Andrea Gazzarini <gx...@gmail.com> on 2015/05/13 19:26:41 UTC

Help on FROM keyword

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

Re: Help on FROM keyword

Posted by Andrea Gazzarini <gx...@gmail.com>.
Hi Stian,
Many thanks for the explanation

Best,
Andrea
On 14 May 2015 21:35, "Stian Soiland-Reyes" <st...@apache.org> wrote:

> 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" <gx...@gmail.com> 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" <an...@apache.org> 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" <an...@apache.org> 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" <tm...@gmail.com>
> 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 <
> gxsubs@gmail.com>
> > >>>>> 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
> > >>>>>>
> > >>>>>>
> > >>>>>>
> > >>>>>
> > >>>>
> > >>>
> > >>
> > >
> >
>

Re: Help on FROM keyword

Posted by Stian Soiland-Reyes <st...@apache.org>.
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" <gx...@gmail.com> 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" <an...@apache.org> 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" <an...@apache.org> 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" <tm...@gmail.com> 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 <gx...@gmail.com>
> >>>>> 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
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>
> >>>>
> >>>
> >>
> >
>

Re: Help on FROM keyword

Posted by Andy Seaborne <an...@apache.org>.
On 13/05/15 21:51, Andrea Gazzarini 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.

s/FROM/GRAPH/

:-)



	Andy

>
> Thanks again
> Andrea
> On 13 May 2015 22:36, "Andy Seaborne" <an...@apache.org> 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" <an...@apache.org> 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" <tm...@gmail.com> 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 <gx...@gmail.com>
>>>>>> 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
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>


Re: Help on FROM keyword

Posted by Andrea Gazzarini <gx...@gmail.com>.
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" <an...@apache.org> 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" <an...@apache.org> 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" <tm...@gmail.com> 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 <gx...@gmail.com>
>>>>> 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
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>

Re: Help on FROM keyword

Posted by Andy Seaborne <an...@apache.org>.
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" <an...@apache.org> 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" <tm...@gmail.com> 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 <gx...@gmail.com>
>>>> 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
>>>>>
>>>>>
>>>>
>>>
>>
>


Re: Help on FROM keyword

Posted by Andrea Gazzarini <gx...@gmail.com>.
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.

Kind Regards,
Andrea
On 13 May 2015 21:05, "Andy Seaborne" <an...@apache.org> 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" <tm...@gmail.com> 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 <gx...@gmail.com>
>>> 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
>>>>
>>>>
>>>
>>
>

Re: Help on FROM keyword

Posted by Andy Seaborne <an...@apache.org>.
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" <tm...@gmail.com> 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 <gx...@gmail.com>
>> 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
>>>
>>
>


Re: Help on FROM keyword

Posted by Andrea Gazzarini <gx...@gmail.com>.
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" <tm...@gmail.com> 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 <gx...@gmail.com>
> 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
> >
>

Re: Help on FROM keyword

Posted by Trevor Donaldson <tm...@gmail.com>.
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 <gx...@gmail.com> 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
>