owl-apiturtle-rdfopenrdf

Use of namespace prefixes in import statements for Turtle documents causes failures when using OWLAPI


If an ontology being saved (using OWLAPI) in Turtle format uses a set of prefixes, the import statements for the imported ontologies, use the declared prefixes. The ontology thus saved using the prefixes cannot be read back by the OWLAPI Turtle parser. The import statement is flagged as source of the problem.

Lets say Onto2 imports Onto1 and Onto3 (see below for declarations). Saving Onto2 results in following:

@prefix : <http://example.com/ontology/Onto2#> .
@prefix OT1: <http://example.com/ontology/Onto1> .
@prefix OT2: <http://example.com/ontology/Onto2> .
@prefix OT3: <http://example.com/ontology/Onto3> .

<http://example.com/ontology/Onto2> rdf:type owl:Ontology ;
                                     owl:imports OT1:# ,
                                                 OT3:# .

When Onto2 is read back by the OWLAPI Turtle parser, it complains

org.openrdf.rio.RDFParseException: Expected '.', found 'O' [line 13]

The import statement is on line 13.


Solution

  • From the Turtle language specs, I think the problem is the hash character. It is not allowed in that position, where it will be interpreted as the start of a comment. See here for details.