Excuse my pickiness... Your code would have been clearer as: checkValid( m0, "m0, before" ); checkValid( m1, "m1, before" ); m1.addSubModel( m0 ); checkValid( m0, "m0, after" ); checkValid( m1, "m1, after" );
With the following output: Model m0, before isValid() => null Model m1, before isValid() => true Model m0, after isValid() => null Model m1, after isValid() => false So what does it mean for validate() to return a null? You cannot tell from the documentation, it implies it always returns an instance of ValidityReport. If it can return null, the javadoc should state so with a reason why. From your example, it appears that m0 is null because there is only a single statement, m0.add( c0, OWL.disjointWith, c1 ); In the first case, it is completely separate from m1 and in the second case because m1 contains m0, so m1 knows about m0 but m0 does not know about m1. Is that correct? -----Original Message----- From: Ian Dickinson [mailto:[email protected]] Sent: Thursday, April 25, 2013 2:24 PM To: [email protected] Subject: Re: OntModel.validate( ) question On 25/04/13 18:27, Joshua TAYLOR wrote: > On Thu, Apr 25, 2013 at 11:46 AM, David Jordan <[email protected]> > wrote: >> I am writing a little performance benchmark test to ascertain the >> overhead in determining whether a given update is a valid. It was >> recommended before on this forum that the best way to do this >> efficiently is create a new OntModel A, have it import the associated >> ontology, then perform the few updates in this new OntModel A, and >> then call A.validate().isValid(). >> >> Is an imported model simply a submodel, added by just calling the add >> method? I don’t see any specific method for importing a model, but >> some documentation suggests that a submodel is an imported model. > > OntModels can have submodels, which are added with > OntModel#addSubModel [1]. However, OWL ontologies can also import > other ontologies via owl:imports, and this is a different concept than > OntModel and submodels. Not really. Sub-models are what OntModel uses to keep track of imports. An ontology with imported ontologies is a composite document, sub-models are the composite pattern analogue of that for OntModels. If you read an ontology into an OntModel, and that ontology owl:imports another ontology, the import will end up in a sub-model. Or you can add a sub-model directly using the Java API. Either way, you end up with the same composite model structure. > To add an owl:imports to an ontology, > use OntModel#getOntology to get the ontology object for the ontology > that the OntModel represents, and use Ontology#addImport to add the > import. If you go down this road, you'll might need to be aware of > OntDocumentManagers [2] and import processing (whether to load > imported ontologies and the like). > > [1] > http://jena.apache.org/documentation/javadoc/jena/com/hp/hpl/jena/onto > logy/OntModel.html#addSubModel(com.hp.hpl.jena.rdf.model.Model) > > [2] http://jena.apache.org/documentation/javadoc/jena/com/hp/hpl/jena/ontology/OntDocumentManager.html > >> When the A.validate() is called, it is just going to validate model >> A, or will it also validate the submodel, which would include the >> potentially large associated ontology? Validation, and inferencing in general, will work on the whole model. To demonstrate this, I hacked up a quick gist: https://gist.github.com/ephemerian/5461867 Before adding the sub-model, the base model is consistent. After adding a sub-model containing the disjointness axiom, the base model is not consistent: Model m0, before isValid() => null Model m0, before isValid() => true Model m0, after isValid() => null Model m0, after isValid() => false Ian
