diff --git a/parsers/src/main/java/org/semanticweb/owlapi/rdf/rdfxml/parser/OWLRDFConsumer.java b/parsers/src/main/java/org/semanticweb/owlapi/rdf/rdfxml/parser/OWLRDFConsumer.java index 7b4925a1f6..f85b7dcd51 100644 --- a/parsers/src/main/java/org/semanticweb/owlapi/rdf/rdfxml/parser/OWLRDFConsumer.java +++ b/parsers/src/main/java/org/semanticweb/owlapi/rdf/rdfxml/parser/OWLRDFConsumer.java @@ -190,6 +190,8 @@ public class OWLRDFConsumer private final Map ontologyVersions = new HashMap<>(); /** IRIs that had a type triple to owl:Ontology */ private final Set ontologyIRIs; + /** IRIs that represent a subject for predicate owl:imports */ + private final Set ontologySubImportIRIs; /** IRIs that had a type triple to owl:Restriction */ private final Set restrictionIRIs; /** Maps rdf:next triple subjects to objects */ @@ -294,6 +296,7 @@ public OWLRDFConsumer(@Nonnull OWLOntology ontology, @Nonnull AnonymousNodeCheck propertyIRIs = CollectionFactory.createSet(); restrictionIRIs = CollectionFactory.createSet(); ontologyIRIs = CollectionFactory.createSet(); + ontologySubImportIRIs = CollectionFactory.createSet(); listFirstLiteralTripleMap = CollectionFactory.createMap(); listFirstResourceTripleMap = CollectionFactory.createMap(); listRestTripleMap = CollectionFactory.createMap(); @@ -1467,7 +1470,8 @@ private void chooseAndSetOntologyIRI() { for (OWLAnnotation anno : ontology.getAnnotations()) { if (anno.getValue() instanceof IRI) { IRI iri = (IRI) anno.getValue(); - if (ontologyIRIs.contains(iri)) { + if (ontologyIRIs.contains(iri) + && !ontologySubImportIRIs.contains(iri)) { candidateIRIs.remove(iri); } } @@ -2285,15 +2289,29 @@ protected void addFirst(IRI subject, OWLLiteral object) { /** * Adds the ontology. - * + * * @param iri the iri + * @param owlImportSubject Is the iri used as subject for predicate + * owl:imports */ - protected void addOntology(IRI iri) { + protected void addOntology(IRI iri, boolean owlImportSubject) { if (ontologyIRIs.isEmpty()) { firstOntologyIRI = iri; } + if (owlImportSubject) { + ontologySubImportIRIs.add(iri); + } ontologyIRIs.add(iri); } + /** + * Overload method of addOntology with + * no owl:import subject iri + * + * @param iri the iri + */ + protected void addOntology(IRI iri) { + addOntology(iri, false); + } /** * Adds the ontology version. diff --git a/parsers/src/main/java/org/semanticweb/owlapi/rdf/rdfxml/parser/TripleHandlers.java b/parsers/src/main/java/org/semanticweb/owlapi/rdf/rdfxml/parser/TripleHandlers.java index 94172c3eef..5d948e2784 100644 --- a/parsers/src/main/java/org/semanticweb/owlapi/rdf/rdfxml/parser/TripleHandlers.java +++ b/parsers/src/main/java/org/semanticweb/owlapi/rdf/rdfxml/parser/TripleHandlers.java @@ -1638,7 +1638,7 @@ public boolean canHandleStreaming(IRI subject, IRI predicate, IRI object) { @Override public void handleTriple(IRI subject, IRI predicate, IRI object) { consumeTriple(subject, predicate, object); - consumer.addOntology(subject); + consumer.addOntology(subject, true); consumer.addOntology(object); OWLImportsDeclaration importsDeclaration = df.getOWLImportsDeclaration(object); consumer.addImport(importsDeclaration);