Fix #1080: preserve ontology IRI when it is both import subject and annotation value - #1179
Closed
Artemis-IA wants to merge 1 commit into
Closed
Fix #1080: preserve ontology IRI when it is both import subject and annotation value#1179Artemis-IA wants to merge 1 commit into
Artemis-IA wants to merge 1 commit into
Conversation
…and annotation value When an ontology declares owl:imports and has a self-referencing annotation (an annotation whose IRI value equals the ontology IRI, e.g. rdfs:isDefinedBy → <ontology-iri>), the RDF/XML parser incorrectly assigns an imported ontology's IRI as the main ontology IRI. Root cause: in OWLRDFConsumer.chooseAndSetOntologyIRI(), when multiple ontology IRI candidates exist, the parser removes any candidate that appears as the value of an ontology annotation. However, the subject of an owl:imports triple (i.e. the importing ontology itself) should never be removed from candidates, even if it also appears as an annotation value. Fix: track IRIs that are subjects of owl:imports triples in a new ontologySubImportIRIs set. In chooseAndSetOntologyIRI(), skip removal of candidates that are in this set. The TPImportsHandler is updated to call addOntology(s, true) to mark import subjects. Self-referencing annotations (rdfs:isDefinedBy, omv:URI, omv:resourceLocator, rdfs:seeAlso) are valid and standard semantic web practice. This fix allows ontologies that use them to be parsed correctly without removing the annotations. Tests: 7 regression tests in SelfReferenceAnnotationImportsTestCase. 3 tests fail without the fix and pass with it; 4 pass in both cases. Verified against 3 OSO ontology versions (1.0.0, 1.1.0, 1.2.0) and 9 real-world ontologies (DCAT2, SSN, PROV-O, GeoNames, GoodRelations, FOAF, IAO, RO, BFO) with no regressions.
Artemis-IA
pushed a commit
to Artemis-IA/OWL2VOWL
that referenced
this pull request
Sep 2, 2026
Use JitPack build of Artemis-IA/owlapi fix-1080-clean branch which patches OWL API issue #1080: ontology IRI was incorrectly set to an imported ontology's IRI when the ontology had both owl:imports and self-referencing annotations (e.g. rdfs:isDefinedBy → ontology IRI). This fixes WebVOWL displaying the wrong ontology IRI for affected ontologies such as OSO 1.1.0 and 1.2.0. The JitPack artifact is com.github.Artemis-IA.owlapi:owlapi-distribution:f39fc42 built from the same OWL API 5.1.1 source with only the #1080 fix applied. Once the upstream PR (owlcs/owlapi#1179) is merged, this dependency should be updated to the official release.
Artemis-IA
pushed a commit
to Artemis-IA/WebVOWL
that referenced
this pull request
Sep 2, 2026
Build OWL2VOWL from Artemis-IA/OWL2VOWL fix-owlapi-1080 branch which uses a patched OWL API 5.1.1 that fixes issue #1080: ontology IRI was incorrectly set to an imported ontology's IRI when the ontology had both owl:imports and self-referencing annotations. This fixes WebVOWL displaying the wrong ontology IRI for affected ontologies such as OSO 1.1.0 and 1.2.0. End-to-end validation: - OSO 1.0.0: IRI=https://w3id.org/earthsemantics/OSO, 205 classes, 285 properties - OSO 1.1.0: IRI=https://w3id.org/earthsemantics/OSO, 199 classes, 286 properties (was prov-o) - OSO 1.2.0: IRI=https://w3id.org/earthsemantics/OSO, 192 classes, 280 properties (was prov-o) Once the upstream PRs are merged (owlcs/owlapi#1179 and VisualDataWeb/OWL2VOWL#76), this should be reverted to use the official OWL2VOWL master branch.
Author
|
Closing this PR as the fix has already been merged upstream in commit b1768cd ("Fixed ontology iri parsing when annotation imports same iri") by @chavez-bermudez. The upstream fix uses the same approach as this PR:
The regression tests in this PR may still be useful for validation. Thank you. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1080 — when an ontology declares
owl:importsand has a self-referencing annotation (an annotation whose IRI value equals the ontology IRI, e.g.rdfs:isDefinedBy → <ontology-iri>), the RDF/XML parser incorrectly assigns an imported ontology's IRI as the main ontology IRI.Problem
When parsing RDF/XML,
OWLRDFConsumer.chooseAndSetOntologyIRI()selects the ontology IRI from candidate IRIs. When multiple candidates exist (the ontology IRI + imported ontology IRIs), it removes any candidate that also appears as the value of an ontology annotation:This is meant to avoid picking an IRI that is merely an annotation value. However, the subject of an
owl:importstriple (i.e. the importing ontology itself) is also added toontologyIRIsbyTPImportsHandler. If that same IRI appears as an annotation value (a self-referencing annotation), it gets incorrectly removed from candidates, and an imported ontology's IRI is chosen instead.Self-referencing annotations are valid and standard semantic web practice:
rdfs:isDefinedBy → <ontology-iri>omv:URI → <ontology-iri>omv:resourceLocator → <ontology-iri>rdfs:seeAlso → <ontology-iri>Root Cause Analysis
The bug requires both conditions simultaneously:
owl:importsdeclarationIf only one condition is met, the bug does not trigger (verified by tests).
Why some ontologies are not affected
OSO 1.0.0 has both conditions but is not affected by coincidence: its imports (
rdfs#,owl#,skos/core#,foaf/) are also declared as values ofomv:useImportsannotations with exactly the same IRIs. This causes all candidates to be removed, leavingcandidateIRIsempty — in which case the parser does not change the ontology IRI (it stays correct).OSO 1.1.0 and 1.2.0 have imports (
prov-o,wgs84_pos,skos/core,foaf/) that do not all appear as annotation values, so some candidates survive and an imported IRI is wrongly selected.Fix
Three minimal changes across two files:
OWLRDFConsumer.javaontologySubImportIRIsto track IRIs that are subjects ofowl:importstriples.addOntology(IRI, boolean isImportSubject)that adds toontologySubImportIRIswhenisImportSubjectis true.chooseAndSetOntologyIRI(), skip removal of candidates that are inontologySubImportIRIs:TripleHandlers.javaTPImportsHandler.handleTriple()callsconsumer.addOntology(s, true)instead ofconsumer.addOntology(s)to mark the import subject.Tests
7 regression tests in
SelfReferenceAnnotationImportsTestCase:testSelfReferenceWithImportstestMultipleSelfReferencesWithImportstestVersionIRIPreservedWithSelfReftestImportsWithoutSelfReferencetestSelfReferenceWithoutImportstestSelfReferenceAsLiteraltestAnnotationWithDifferentIRI3 tests fail without the fix and pass with it. 4 pass in both cases (no regression).
Broader Validation
Beyond unit tests, the fix was validated against:
prov-oinstead ofOSO), now fixed. 1.0.0 was unaffected by coincidence, remains correct.Impact
This bug affects any OWL API consumer that loads ontologies with both
owl:importsand self-referencing annotations. Known affected consumers include:Test plan