You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by kumar rohit <ku...@gmail.com> on 2016/06/30 20:43:20 UTC

Adding individual to a jena file

I have an rdf file on c:/users/desktop/std.rdf. I have the following jena
code

*String personURI = "c://users/desktop/rohit/std.rdf";*
* String fullName = "rohit kumar";*
*// create an empty Model*
*Model model = ModelFactory.createDefaultModel();*
*// create the resource*
*Resource res1 = model.createResource(personURI)..addProperty(VCARD.FN,
fullName);*

What happens after this code? Is this save "rohit kumar" in the file
std.rdf?

I can not find this resource after running this code and open the file in
Protege?

Re: Adding individual to a jena file

Posted by Lorenz Buehmann <bu...@informatik.uni-leipzig.de>.
There is no need for SPARQL Update. Again, I'd suggest to read docs and 
tutorial[1].

[1] https://jena.apache.org/tutorials/rdf_api.html

On 01.07.2016 20:47, kumar rohit wrote:
> Thank you for your reply.
> Is there any need for SPARQL update query or things will be happily done
> with Jena code?
> thanks
>
> On Fri, Jul 1, 2016 at 1:53 AM, Lorenz B. <
> buehmann@informatik.uni-leipzig.de> wrote:
>
>> When you're modifying the model, all happens in-memory. You have to
>> write the model back to file, as Andy suggest, there is a good Jena API
>> tutorial.
>>
>>> I am sorry but I used model.read method but did not mention it in the
>> code.
>>> I mean the rdf file is readed successfully but still I could not find the
>>> individual when I open the file in Protege.
>>>
>>>
>>> On Thu, Jun 30, 2016 at 1:51 PM, Andy Seaborne <an...@apache.org> wrote:
>>>
>>>> On 30/06/16 21:43, kumar rohit wrote:
>>>>
>>>>> I have an rdf file on c:/users/desktop/std.rdf. I have the following
>> jena
>>>>> code
>>>>>
>>>> which does not read the file.
>>>>
>>>>
>>>>> *String personURI = "c://users/desktop/rohit/std.rdf";*
>>>>>
>>>> There is no connection between using a URI and a file.  That is just a
>>>> string used as a URI.  If you change it ... you don't get "file not
>> found"
>>>> * String fullName = "rohit kumar";*
>>>>> *// create an empty Model*
>>>>> *Model model = ModelFactory.createDefaultModel();*
>>>>>
>>>> Empty model.
>>>>
>>>> *// create the resource*
>>>>> *Resource res1 = model.createResource(personURI)..addProperty(VCARD.FN,
>>>>> fullName);*
>>>>>
>>>>> What happens after this code? Is this save "rohit kumar" in the file
>>>>> std.rdf?
>>>>>
>>>> No.
>>>>
>>>> read the file into a model (RDFDataMgr or model.read), change it, write
>> it
>>>> out again.
>>>>
>>>> See the tutorials.
>>>>
>>>>
>>>>
>>>>
>>>>> I can not find this resource after running this code and open the file
>> in
>>>>> Protege?
>>>>>
>>>>>
>>>>          Andy
>>>>
>> --
>> Lorenz B�hmann
>> AKSW group, University of Leipzig
>> Group: http://aksw.org - semantic web research center
>>
>>


Re: Adding individual to a jena file

Posted by kumar rohit <ku...@gmail.com>.
Thank you for your reply.
Is there any need for SPARQL update query or things will be happily done
with Jena code?
thanks

On Fri, Jul 1, 2016 at 1:53 AM, Lorenz B. <
buehmann@informatik.uni-leipzig.de> wrote:

> When you're modifying the model, all happens in-memory. You have to
> write the model back to file, as Andy suggest, there is a good Jena API
> tutorial.
>
> > I am sorry but I used model.read method but did not mention it in the
> code.
> > I mean the rdf file is readed successfully but still I could not find the
> > individual when I open the file in Protege.
> >
> >
> > On Thu, Jun 30, 2016 at 1:51 PM, Andy Seaborne <an...@apache.org> wrote:
> >
> >> On 30/06/16 21:43, kumar rohit wrote:
> >>
> >>> I have an rdf file on c:/users/desktop/std.rdf. I have the following
> jena
> >>> code
> >>>
> >>
> >> which does not read the file.
> >>
> >>
> >>> *String personURI = "c://users/desktop/rohit/std.rdf";*
> >>>
> >> There is no connection between using a URI and a file.  That is just a
> >> string used as a URI.  If you change it ... you don't get "file not
> found"
> >>
> >> * String fullName = "rohit kumar";*
> >>> *// create an empty Model*
> >>> *Model model = ModelFactory.createDefaultModel();*
> >>>
> >> Empty model.
> >>
> >> *// create the resource*
> >>> *Resource res1 = model.createResource(personURI)..addProperty(VCARD.FN,
> >>> fullName);*
> >>>
> >>> What happens after this code? Is this save "rohit kumar" in the file
> >>> std.rdf?
> >>>
> >> No.
> >>
> >> read the file into a model (RDFDataMgr or model.read), change it, write
> it
> >> out again.
> >>
> >> See the tutorials.
> >>
> >>
> >>
> >>
> >>> I can not find this resource after running this code and open the file
> in
> >>> Protege?
> >>>
> >>>
> >>         Andy
> >>
> --
> Lorenz Bühmann
> AKSW group, University of Leipzig
> Group: http://aksw.org - semantic web research center
>
>

Re: Adding individual to a jena file

Posted by "Lorenz B." <bu...@informatik.uni-leipzig.de>.
When you're modifying the model, all happens in-memory. You have to
write the model back to file, as Andy suggest, there is a good Jena API
tutorial.

> I am sorry but I used model.read method but did not mention it in the code.
> I mean the rdf file is readed successfully but still I could not find the
> individual when I open the file in Protege.
>
>
> On Thu, Jun 30, 2016 at 1:51 PM, Andy Seaborne <an...@apache.org> wrote:
>
>> On 30/06/16 21:43, kumar rohit wrote:
>>
>>> I have an rdf file on c:/users/desktop/std.rdf. I have the following jena
>>> code
>>>
>>
>> which does not read the file.
>>
>>
>>> *String personURI = "c://users/desktop/rohit/std.rdf";*
>>>
>> There is no connection between using a URI and a file.  That is just a
>> string used as a URI.  If you change it ... you don't get "file not found"
>>
>> * String fullName = "rohit kumar";*
>>> *// create an empty Model*
>>> *Model model = ModelFactory.createDefaultModel();*
>>>
>> Empty model.
>>
>> *// create the resource*
>>> *Resource res1 = model.createResource(personURI)..addProperty(VCARD.FN,
>>> fullName);*
>>>
>>> What happens after this code? Is this save "rohit kumar" in the file
>>> std.rdf?
>>>
>> No.
>>
>> read the file into a model (RDFDataMgr or model.read), change it, write it
>> out again.
>>
>> See the tutorials.
>>
>>
>>
>>
>>> I can not find this resource after running this code and open the file in
>>> Protege?
>>>
>>>
>>         Andy
>>
-- 
Lorenz B�hmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center


Re: Adding individual to a jena file

Posted by kumar rohit <ku...@gmail.com>.
I am sorry but I used model.read method but did not mention it in the code.
I mean the rdf file is readed successfully but still I could not find the
individual when I open the file in Protege.


On Thu, Jun 30, 2016 at 1:51 PM, Andy Seaborne <an...@apache.org> wrote:

> On 30/06/16 21:43, kumar rohit wrote:
>
>> I have an rdf file on c:/users/desktop/std.rdf. I have the following jena
>> code
>>
>
>
> which does not read the file.
>
>
>> *String personURI = "c://users/desktop/rohit/std.rdf";*
>>
>
> There is no connection between using a URI and a file.  That is just a
> string used as a URI.  If you change it ... you don't get "file not found"
>
> * String fullName = "rohit kumar";*
>> *// create an empty Model*
>> *Model model = ModelFactory.createDefaultModel();*
>>
>
> Empty model.
>
> *// create the resource*
>> *Resource res1 = model.createResource(personURI)..addProperty(VCARD.FN,
>> fullName);*
>>
>> What happens after this code? Is this save "rohit kumar" in the file
>> std.rdf?
>>
>
> No.
>
> read the file into a model (RDFDataMgr or model.read), change it, write it
> out again.
>
> See the tutorials.
>
>
>
>
>> I can not find this resource after running this code and open the file in
>> Protege?
>>
>>
>         Andy
>

Re: Adding individual to a jena file

Posted by Andy Seaborne <an...@apache.org>.
On 30/06/16 21:43, kumar rohit wrote:
> I have an rdf file on c:/users/desktop/std.rdf. I have the following jena
> code


which does not read the file.

>
> *String personURI = "c://users/desktop/rohit/std.rdf";*

There is no connection between using a URI and a file.  That is just a 
string used as a URI.  If you change it ... you don't get "file not found"

> * String fullName = "rohit kumar";*
> *// create an empty Model*
> *Model model = ModelFactory.createDefaultModel();*

Empty model.

> *// create the resource*
> *Resource res1 = model.createResource(personURI)..addProperty(VCARD.FN,
> fullName);*
>
> What happens after this code? Is this save "rohit kumar" in the file
> std.rdf?

No.

read the file into a model (RDFDataMgr or model.read), change it, write 
it out again.

See the tutorials.


>
> I can not find this resource after running this code and open the file in
> Protege?
>

	Andy