It doesn't look like the ReadHook is applied on the cache key, unfortunately.

The problematic OntDocumentManager code is here:
https://github.com/apache/jena/blob/main/jena-core/src/main/java/org/apache/jena/ontology/OntDocumentManager.java#L983

On Sat, Mar 26, 2022 at 5:09 PM Martynas Jusevičius
<marty...@atomgraph.com> wrote:
>
> Could OntDocumentManager.ReadHook be used for this?
> https://jena.apache.org/documentation/javadoc/jena/org/apache/jena/ontology/OntDocumentManager.ReadHook.html
>
> On Sat, Mar 26, 2022 at 4:46 PM Martynas Jusevičius
> <marty...@atomgraph.com> wrote:
> >
> > Hi,
> >
> > Using the ontology API, if one owl:imports an ontology URI such as
> > <http://www.w3.org/ns/org#> into ontology model, the imported model
> > gets cached under the "http://www.w3.org/ns/org#"; key.
> >
> > However, given
> >
> >     <http://www.w3.org/ns/org#> a owl:Ontology
> >
> > one can argue that this URI is of the ontology resource, but what gets
> > loaded and cached is more than that -- it is the ontology *document*.
> > This relates to the old debate whether ontology instances should
> > contain the trailing # in their URIs, i.e. whether ontology and its
> > document is the same resource or distinct resources.
> >
> > The problem is that despite the ontology being cached, code that
> > attempts to dereference its document URI will not be able to make use
> > of it as "http://www.w3.org/ns/org"; will not match the
> > "http://www.w3.org/ns/org#"; cache key.
> >
> > My questions are:
> > 1. How can I work around this? Using some kind of post-loadImports()
> > hook to make cache entries for both URIs?
> > 2. Shouldn't the OWL import code be aware of this and cache the
> > document URI while using it as a base for all relative URIs (of
> > ontology terms)?
> >
> > Martynas
> > atomgraph.com

Reply via email to