On 3/27/2012 1:49, Martynas Jusevicius wrote:
Hey all,
I'm reading an ontology file into OntModel, and it includes imports
which are processed.
It's all fine when I'm operating on the OntModel level. However I need
to pass a certain Resource to the SPIN API, and the statements about
it are both in the base model and in the imported one. If I'm simply
passing that Resource retrieved from the OntModel, SPIN throws an
exception and won't build a Query out of it.
The exception probably has something to do with certain system variables
from the SPIN/SP namespaces not found, so you may be right that it
expects the full imports at query parsing time.
What I do not understand why the import resolution does not pick up
those namespaces (as it should), so if my response doesn't help then I
need more info (stack trace).
I think it's because it
is operating on the Model level and does not see the imports.
Am I possibly right? In that case, what is to be done in such
situation? Should I just manually add the imported Model before
passing Resource to SPIN?
What I sometimes do in such cases is to create yet another MultiUnion
that imports your model. E.g. (untested)
MultiUnion union = new MultiUnion(new Graph[] {
myQueryModel.getGraph(),
SP.getModel().getGraph(),
SPIN.getModel().getGraph()
});
Model newModel = ModelFactory.createModelForGraph(union);
Then parse the SPIN queries based on newModel.
HTH
Holger