Discussion:
Resource cant add to rdf file
kumar rohit
2016-07-09 10:43:21 UTC
Permalink
After executing this code, I can not find the resource (Ranjani) in my
Protege owl file. Where is the mistake in code?




public class rdffile {
public static void main(String[] args) throws IOException {

String ns = "
http://www.semanticweb.org/ontologies/2016/7/my-ontology-54#Ranjani";



Model model=ModelFactory.createDefaultModel();
InputStream in = FileManager.get().open("C:/User/Desktop/first.owl");
if (in==null) {
throw new IllegalArgumentException(
"File: " + " not found ");
}
model.read(in, "");


Resource ranjani = model.createResource(ns+"Ranjani");

String ss= "C:/Users/Desktop/first.owl";
FileWriter out = new FileWriter( ss );

model.write(out, "RDF/XML-ABBREV");
Lorenz B.
2016-07-09 11:35:55 UTC
Permalink
The problem is that you still did not learn enough about RDF, OWL and
SPARQL...

If you create a resource with JENA, what do you think is it? An
individual, a class, a property? JENA, and I'm talking here about the
methods you used, creates RDF, not OWL. Protege on the other hand reads
and works on OWL ontologies(ok, it also supports OBO, but that's another
topic). Please read the tutorial [1] about JENA and OWL, then I think
you will make it

[1] https://jena.apache.org/documentation/ontology/

Kind regards,
Lorenz
Post by kumar rohit
After executing this code, I can not find the resource (Ranjani) in my
Protege owl file. Where is the mistake in code?
public class rdffile {
public static void main(String[] args) throws IOException {
String ns = "
http://www.semanticweb.org/ontologies/2016/7/my-ontology-54#Ranjani";
Model model=ModelFactory.createDefaultModel();
InputStream in = FileManager.get().open("C:/User/Desktop/first.owl");
if (in==null) {
throw new IllegalArgumentException(
"File: " + " not found ");
}
model.read(in, "");
Resource ranjani = model.createResource(ns+"Ranjani");
String ss= "C:/Users/Desktop/first.owl";
FileWriter out = new FileWriter( ss );
model.write(out, "RDF/XML-ABBREV");
--
Lorenz Bühmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center
kumar rohit
2016-07-09 11:48:32 UTC
Permalink
I am sorry sir, I have read this file so many times but I do not know why
things are going well for me still.
Let me read it again.

On Sat, Jul 9, 2016 at 4:35 AM, Lorenz B. <
Post by Lorenz B.
The problem is that you still did not learn enough about RDF, OWL and
SPARQL...
If you create a resource with JENA, what do you think is it? An
individual, a class, a property? JENA, and I'm talking here about the
methods you used, creates RDF, not OWL. Protege on the other hand reads
and works on OWL ontologies(ok, it also supports OBO, but that's another
topic). Please read the tutorial [1] about JENA and OWL, then I think
you will make it
[1] https://jena.apache.org/documentation/ontology/
Kind regards,
Lorenz
Post by kumar rohit
After executing this code, I can not find the resource (Ranjani) in my
Protege owl file. Where is the mistake in code?
public class rdffile {
public static void main(String[] args) throws IOException {
String ns = "
http://www.semanticweb.org/ontologies/2016/7/my-ontology-54#Ranjani";
Model model=ModelFactory.createDefaultModel();
InputStream in = FileManager.get().open("C:/User/Desktop/first.owl");
if (in==null) {
throw new IllegalArgumentException(
"File: " + " not found ");
}
model.read(in, "");
Resource ranjani = model.createResource(ns+"Ranjani");
String ss= "C:/Users/Desktop/first.owl";
FileWriter out = new FileWriter( ss );
model.write(out, "RDF/XML-ABBREV");
--
Lorenz BÃŒhmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center
kumar rohit
2016-07-09 12:28:26 UTC
Permalink
I have updated the code and now it works. thanks for your support sir

OntClass student = model.createClass(ns + "Student");
Post by kumar rohit
I am sorry sir, I have read this file so many times but I do not know why
things are going well for me still.
Let me read it again.
On Sat, Jul 9, 2016 at 4:35 AM, Lorenz B. <
Post by Lorenz B.
The problem is that you still did not learn enough about RDF, OWL and
SPARQL...
If you create a resource with JENA, what do you think is it? An
individual, a class, a property? JENA, and I'm talking here about the
methods you used, creates RDF, not OWL. Protege on the other hand reads
and works on OWL ontologies(ok, it also supports OBO, but that's another
topic). Please read the tutorial [1] about JENA and OWL, then I think
you will make it
[1] https://jena.apache.org/documentation/ontology/
Kind regards,
Lorenz
Post by kumar rohit
After executing this code, I can not find the resource (Ranjani) in my
Protege owl file. Where is the mistake in code?
public class rdffile {
public static void main(String[] args) throws IOException {
String ns = "
http://www.semanticweb.org/ontologies/2016/7/my-ontology-54#Ranjani";
Model model=ModelFactory.createDefaultModel();
InputStream in = FileManager.get().open("C:/User/Desktop/first.owl");
if (in==null) {
throw new IllegalArgumentException(
"File: " + " not found ");
}
model.read(in, "");
Resource ranjani = model.createResource(ns+"Ranjani");
String ss= "C:/Users/Desktop/first.owl";
FileWriter out = new FileWriter( ss );
model.write(out, "RDF/XML-ABBREV");
--
Lorenz BÃŒhmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center
Loading...