Hi Dave,

Than you very much for your reply.

In jena 2.6.4, class ModelFactory provides the following methods:

static ModelMaker createModelRDBMaker(IDBConnection c)
Answer a ModelMaker that accesses database-backed Models on the database
at the other end of the connection c with the usual Standard reification
style.

static ModelMaker createModelRDBMaker(IDBConnection c, ReificationStyle
style)
Answer a ModelMaker that accesses database-backed Models on the database
at the other end of the connection c with the given reification style.

but they have been removed in the later Jena versions.

I have modified my code according to the ways you provide and it works
very well.

Thank you again.

Deyan

于 2013年08月28日 16:07, Dave Reynolds 写道:
> On 28/08/13 04:00, Deyan Chen wrote:
>> Hi all,
>>
>> I want to read an ontology file which imports several other ontology
>> files to a TDB store.
>>
>> The test code is as follows:
>>
>> Dataset ds = TDBFactory.createDataset(location);
>> Model base = ds.getDefaultModel();
>> OntModel model =
>> ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM, base);
>> // need to process imports
>> model.read(sourceURL);
>> ds.close();
>>
>> I can get imported model from the ontology model by:
>>
>> ...
>> OntModel model1 = model.getImportedModel(uri);
>> ...
>>
>> But I can't get it from the TDB store. Although I can add these imported
>> models to TDB by method:
>>
>> ds.addNamedModel(uri, model);
>>
>> but it's very inconvenient. Are there any good methods can be used to
>> achieve it automatically?
> When you read an OntModel which does imports processing then it reads
> only the base model into the underlying model and loads the imported
> models separately. How those imported models are stored is defined by
> the OntDocumentManager settings and associated ModelMaker.
>
> It is possible to arrange for the imported models to be persisted in a
> store like TDB (e.g. as separate graphs). However, the documentation for
> that is a little out of date and doesn't directly cover the TDB case
> specifically. Have a look at:
> http://jena.apache.org/documentation/ontology/index.html#working-with-persistent-ontologies
>
> [The link to the example code is not working, I suspect because it used
> a now-obsolete persistence module.]
>
> The alternative would be to merge all your data into one model. If you
> don't need the separate submodel mechanism then once your ontology is
> loaded you could list all the submodels and add each of those to your
> base model so that the dataset default graph would then contain the
> union of your ontology and all its imports. When you reopen that TDB
> store in another jvm instance then switch off import processing.
>
> Dave
>
>

---------------------------------------------------------------------------------------------------
Confidentiality Notice: The information contained in this e-mail and any 
accompanying attachment(s) 
is intended only for the use of the intended recipient and may be confidential 
and/or privileged of 
Neusoft Corporation, its subsidiaries and/or its affiliates. If any reader of 
this communication is 
not the intended recipient, unauthorized use, forwarding, printing,  storing, 
disclosure or copying 
is strictly prohibited, and may be unlawful.If you have received this 
communication in error,please 
immediately notify the sender by return e-mail, and delete the original message 
and all copies from 
your system. Thank you. 
---------------------------------------------------------------------------------------------------

Reply via email to