It does but not if the URI are given as you've shown. Both URIs can't be
resolved to ontology files.
> Hi Andreas,
>
> Yes, I had not read in the import ontology. I thought that would be
> automatic.
>
> Thanks, Jos
>
>
> -----Ursprüngliche Nachricht-----
> Von: Andreas Prieß [mailto:[email protected]]
> Gesendet: Samstag, 14. Januar 2017 19:47
> An: [email protected]
> Betreff: Re: Listing all individuals of an ontology, including those defined
> in the ontology as individuals of classes coming from import ontology
>
> Hi,
>
> you probably should check explicitly whether the second ontology was actually
> imported.
>
> Have a look at
>
> OntModel.hasLoadedImport(String uri)
> or
> OntModel.listSubModels(boolean withImports)
>
> I suppose there is a problem importing the second ontology since the URL
> seems not to be resolvable.
>
>
> ~ Andreas
>
>
> On 12.01.2017 16:30, Jos Lehmann wrote:
>> Hi there
>>
>> SITUATION
>>
>> -- A
>>
>> I am working with ontology L (denoted as Ontology_input_file in Code below)
>> with URI:
>> http://www.b-l.net/ontologies/2016/L_Ontology.owl#
>>
>>
>> -- B
>>
>> This ontology imports an ontology PS with URI:
>> http://www.b-l.net/ontologies/2016/PS_Ontology.owl#
>>
>> Note that I have added a number of indivuduals to L, as individuals of
>> classes coming from import ontology PS. I.e. these individuals have L's URI
>> but are of types defined in PS.
>>
>> PROBLEM
>>
>> In order to get the complete list of individuals I use the following code:
>>
>> OntModel model = ModelFactory.createOntologyModel();
>> model.read(Ontology_input_file);
>>
>> ExtendedIterator individuals = model.listIndividuals();
>> while (individuals.hasNext()) {
>> Individual thisIndividual = (Individual) individuals.next();
>> System.out.println(thisIndividual.toString())
>> }
>>
>>
>> With this code I only get individuals defined in L as instances of classes
>> that have L's URI.
>>
>> How do I get the entire list of individuals, including those described in B
>> above?
>>
>>
>> Thanks, Jos
>
>
--
Lorenz Bühmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center