I noticed, that when I include an ontology, into another ontology, with the first using the second ontology, Protege will not recognize the properties correctly. An example:
ontology A
@prefix : <http://j/some_random_ontology/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@base <http://j/some_random_ontology/> .
<http://j/some_random_ontology> rdf:type owl:Ontology ;
owl:imports <file:/C:/Users/xxxx/msc-thesis/ontologies/SDexport.n3> .
#################################################################
# Object Properties
#################################################################
### http://j/some_random_ontology/uses
:uses rdf:type owl:ObjectProperty ;
rdfs:domain :bin ;
rdfs:range :comp .
#################################################################
# Classes
#################################################################
### http://j/some_random_ontology/bin
:bin rdf:type owl:Class .
### http://j/some_random_ontology/comp
:comp rdf:type owl:Class .
#################################################################
# Individuals
#################################################################
### http://individuals/binone
<http://individuals/binone> :uses <http://individuals/compone> .
### Generated by the OWL API (version 4.5.29.2024-05-13T12:11:03Z) https://github.com/owlcs/owlapi
ontology B:
@prefix j: <http://j/some_random_ontology/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
<http://individuals/binone> a owl:NamedIndividual ;
j:uses <http://individuals/compone> .
<http://individuals/compone> a owl:NamedIndividual .
If I include ontology B into ontology A via file import (as in the code sample), binone uses
compone is recognized as an annotation property, however, when I include ontology A into ontology B, uses
is recognized correctly as an object property.
My question now is, why is that so?
My theory is, that Protege upon reaching the line during parsing with the import in ontology A, loads file ontology B and has not yet encountered the uses
property below. Can anyone confirm whether this is the case?
Your assumption that the declaration of uses
is not seen when ontology B is parsed, but that's not down to parsing the ontologies, it's the direction of the imports directive.
A imports B means B is independent of A. So, the type declaration for uses
must be in the imported ontology, if the property appears in it.
So, either B must import A, or the type declaration must move.
(Side note: import cycles are possible, but they mean the ontologies cannot be used separately and are functionally just one ontology split across different files. Also, scenarios like this don't work well with OWLAPI parsers - there are open bug reports).