owlcs / owlapi

OWL API main repository
825 stars 314 forks source link

[question] Why are classes with square brackets in IRI fragments allowable in OWL/XML syntax #1131

Open jvendetti opened 6 months ago

jvendetti commented 6 months ago

We're trying to get the attached ontology file loaded into BioPortal (we're using version 4.5.18 of the OWL API). The OWL API loads the ontology without errors, e.g.:

@Test
public void testLoadHoomOrphanetOntology() throws Exception {
  String path = "src/test/resources/hoom_orphanet.owl";
  FileDocumentSource fileDocumentSource = new FileDocumentSource(new File(path));

  OWLOntologyLoaderConfiguration config = new OWLOntologyLoaderConfiguration();
  config.setStrict(true);
  config.setBannedParsers("org.semanticweb.owlapi.rio.RioTrixParserFactory");

  OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
  OWLOntology ontology = manager.loadOntologyFromOntologyDocument(fileDocumentSource, config);
  assertNotNull(ontology);
}

When we try to load the ontology into our RDF database (AllegroGraph), it's rejected due to square bracket characters in the fragment portion of some of the class IRIs. The OWL API reports the format of this ontology as OWL/XML Syntax, and doesn't seem bothered by square brackets in class IRI fragments. Continuing from the above code snippet, there's no issue with classes like this one with a square bracket character at the end of the fragment:

OWLDataFactory dataFactory = manager.getOWLDataFactory();
IRI iri = IRI.create("http://www.semanticweb.org/ontology/HOOM#20574610(PMID]");
OWLClass owlClass = dataFactory.getOWLClass(iri);
assertNotNull(owlClass);

I thought that square brackets are considered reserved characters that are only allowed in the host portion of an IRI, and am wondering why an ontology like this isn't rejected by the OWL API as invalid?

hoom_orphanet.owl.zip