Discussion:
Adding individual to a jena file
kumar rohit
2016-06-30 20:43:20 UTC
Permalink
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?
Andy Seaborne
2016-06-30 20:51:05 UTC
Permalink
Post by kumar rohit
I have an rdf file on c:/users/desktop/std.rdf. I have the following jena
code
which does not read the file.
Post by kumar rohit
*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"
Post by kumar rohit
* String fullName = "rohit kumar";*
*// create an empty Model*
*Model model = ModelFactory.createDefaultModel();*
Empty model.
Post by kumar rohit
*// 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.
Post by kumar rohit
I can not find this resource after running this code and open the file in
Protege?
Andy
kumar rohit
2016-07-01 08:52:12 UTC
Permalink
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.
Post by Andy Seaborne
Post by kumar rohit
I have an rdf file on c:/users/desktop/std.rdf. I have the following jena
code
which does not read the file.
Post by kumar rohit
*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";*
Post by kumar rohit
*// create an empty Model*
*Model model = ModelFactory.createDefaultModel();*
Empty model.
*// create the resource*
Post by kumar rohit
*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.
Post by kumar rohit
I can not find this resource after running this code and open the file in
Protege?
Andy
Lorenz B.
2016-07-01 08:53:57 UTC
Permalink
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.
Post by kumar rohit
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.
Post by Andy Seaborne
Post by kumar rohit
I have an rdf file on c:/users/desktop/std.rdf. I have the following jena
code
which does not read the file.
Post by kumar rohit
*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";*
Post by kumar rohit
*// create an empty Model*
*Model model = ModelFactory.createDefaultModel();*
Empty model.
*// create the resource*
Post by kumar rohit
*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.
Post by kumar rohit
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
kumar rohit
2016-07-01 18:47:22 UTC
Permalink
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. <
Post by Lorenz B.
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.
Post by kumar rohit
I am sorry but I used model.read method but did not mention it in the
code.
Post by kumar rohit
I mean the rdf file is readed successfully but still I could not find the
individual when I open the file in Protege.
Post by Andy Seaborne
Post by kumar rohit
I have an rdf file on c:/users/desktop/std.rdf. I have the following
jena
Post by kumar rohit
Post by Andy Seaborne
Post by kumar rohit
code
which does not read the file.
Post by kumar rohit
*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"
Post by kumar rohit
Post by Andy Seaborne
* String fullName = "rohit kumar";*
Post by kumar rohit
*// create an empty Model*
*Model model = ModelFactory.createDefaultModel();*
Empty model.
*// create the resource*
Post by kumar rohit
*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
Post by kumar rohit
Post by Andy Seaborne
out again.
See the tutorials.
Post by kumar rohit
I can not find this resource after running this code and open the file
in
Post by kumar rohit
Post by Andy Seaborne
Post by kumar rohit
Protege?
Andy
--
Lorenz BÃŒhmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center
Lorenz Buehmann
2016-07-02 08:38:20 UTC
Permalink
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
Post by kumar rohit
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. <
Post by Lorenz B.
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.
Post by kumar rohit
I am sorry but I used model.read method but did not mention it in the
code.
Post by kumar rohit
I mean the rdf file is readed successfully but still I could not find the
individual when I open the file in Protege.
Post by Andy Seaborne
Post by kumar rohit
I have an rdf file on c:/users/desktop/std.rdf. I have the following
jena
Post by kumar rohit
Post by Andy Seaborne
Post by kumar rohit
code
which does not read the file.
Post by kumar rohit
*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"
Post by kumar rohit
Post by Andy Seaborne
* String fullName = "rohit kumar";*
Post by kumar rohit
*// create an empty Model*
*Model model = ModelFactory.createDefaultModel();*
Empty model.
*// create the resource*
Post by kumar rohit
*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
Post by kumar rohit
Post by Andy Seaborne
out again.
See the tutorials.
Post by kumar rohit
I can not find this resource after running this code and open the file
in
Post by kumar rohit
Post by Andy Seaborne
Post by kumar rohit
Protege?
Andy
--
Lorenz Bühmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center
Loading...