views:

154

answers:

2

i do some development with jena ontology API.my ontology file in my local machine..when i'm going to read the model.. there is an error.. and i made ontology with protege and tried to read that file.

String SOURCE = "http://www.owl-ontologies.com/Ontology1275995702";(it's XML:base value)
        //String NS = SOURCE + "#";
        //InputStream in = FileManager.get().open("tourism.owl");
        OntModel model = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
        model.read(SOURCE,"RDF/XML");

        OntClass paper = model.getOntClass( SOURCE + "srilanka" );

how can i fix this?

A: 

I'm not sure exactly what you are trying to do here. It seems that the string is not formatted correctly first off.

But what type or error are you having. Could you post the error text.

If you reformat it it will look something like:

String SOURCE = "http://www.owl-ontologies.com/Ontology1275995702";

//This line will cause an error (is it actually part of the code?)
(it's XML:base value)

//String NS = SOURCE + "#";
//InputStream in = FileManager.get().open("tourism.owl");
OntModel model = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
model.read(SOURCE,"RDF/XML");

OntClass paper = model.getOntClass( SOURCE + "srilanka" );
gruntled
hi,this is a error...ERROR [main] (RDFDefaultErrorHandler.java:40) - http://www.owl-ontologies.com/Ontology1275995702(line 1 column 103): {E213} Server returned HTTP response code: 503 for URL: http://www.w3.org/TR/html4/loose.dtdi want to get all the classes/subclasses/ property values in my ontology. but there is a error of my source...i got that string in my xml:base xml:base="http://www.owl-ontologies.com/Ontology1275995702.owl">HOW CAN I FIX THIS:::thanks
well a HTTP response code 503 means that the service was unavailable. This would usually mean that the server you are speaking to is either configured incorrectly or overloaded.Try checking each step of your program to ensure you are getting the correct value and then sending out the correct value to the server.For example when i visit the link http://www.owl-ontologies.com/Ontology1275995702.owl i do not receive any xml values.
gruntled
A: 

What is this owl-ontologies.com URL? Is this just some URL you made up when you created the ontology in Protégé? And then you try reading the ontology from that URL? How should that work if you haven't published the ontology to the web?

Try this:

InputStream in = FileManager.get().open("tourism.owl");
OntModel model = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
model.read(in, "RDF/XML");

Iterator<OntClass> it = model.listClasses();
while (it.hasNext()) {
  OntClass class = it.next();
  System.out.println(class.getLabel(null));
}
cygri
ANY WAY THANKS.. THAT'S THE THING I WANT TO KNOW...THEN CAN'T DO ANY DEVELOPING WITH JENA API WITHOUT PUBLISH ONTOLOGY TO THE WEB.? HOW CAN I DO DEVELOPMENT WITHOUT PUBLISH IT IN TO WEB...THANKS
Dude, read the code that I posted. It loads the ontology from a local file, `tourism.owl`, and not from the web.
cygri
thanks for your quick reply....i got it. it works. fine.. now i need to how to get property values for given class.. all the tutorials are belongs toOntClass name = model.getontclass(uri) .. thanks...