2

Hi guys so I'm trying to build a project that aligns to Ontologies; and I was searching for ontology example and I found this ontology on a PDF file and wanted to use it by copying-pasting it in a .owl file, but it won't work String path="file:E:\\MSIR\\S4\\Jena Library\\PersonA.owl"; Model model = ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM); model.read(path);

but it gives me this error:

Exception in thread "main" org.apache.jena.riot.RiotException: [line: 6, col: 6 ] The processing instruction target matching "[xX][mM][lL]" is not allowed.

Please tell me what to do? Am I not supposed to just copy and paste the ontology code? should I create my ontology from scratch, and how would I do so? Thank you in advance.

dark_knight94
  • 117
  • 11
  • 1
    It looks like the processing component is complaining about the OWL file itself. All I can ask is, what is at line line 6, column 6 of the PersonA.owl file? The `[xX][mM][lL]` appears to be a regular expression, so I am guessing the word XML (or xml) appears at line 6 column 6 of this .owl file. After that, I don't know anything more about Ontologies. (Like if the OWL file accepts xml) – Michael Plautz May 23 '16 at 19:09
  • If you are searching for a .owl file, then here is one https://www.google.se/url?sa=t&rct=j&q=&esrc=s&source=web&cd=4&cad=rja&uact=8&ved=0ahUKEwi9xPO_9_DMAhWJKJoKHVKKBw8QFggvMAM&url=http%3A%2F%2Fprotege.cim3.net%2Ffile%2Fpub%2Fontologies%2Ftravel%2Ftravel.owl&usg=AFQjCNG0StxkYcLLTL9JaqP-OF_qvuuOpg&sig2=rEo4M07Ym3GrEXcJjfGhcg – likeToCode May 23 '16 at 19:36
  • There is no issue with your code, I used the same code and the above owl file, I was able to read it without an issue. Perhaps if you can post the URL of the pdf then it would be helpful to see how the owl file can be used. – likeToCode May 23 '16 at 19:37
  • It's alright guys, I found the answer; and it simply was as @Michael Plauts said, the person who made this owl file didn't write the '' as the 1st line of the file. It was THAT simple! Thanks anyways guys, I appreciate it! – dark_knight94 May 24 '16 at 00:33

1 Answers1

1

You need to put the owl file in your src folder then try with this:

String path = "src/PersonA.owl" ;
Model model = ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM);
model.read(path);
model.write(System.out) ; // print the owl file to make sure that you did      //read the file
AJS
  • 1,993
  • 16
  • 26
Reda Yahla
  • 11
  • 2