Hey,

sorry Holger... I double-checked everything and found a missing
namespace prefix, because of which the query resource was referenced
incorrectly. Typical :/

Martynas
graphity.org

On Wed, Mar 28, 2012 at 3:04 AM, Holger Knublauch <[email protected]> wrote:
> Hi Martynas,
>
> no sorry I still don't see what could be wrong. I look at the source code of
> the SPIN API and in the end it will call ImplementationBytype.canWrap in the
> SPINFactory.asQuery() method. As this is open source, I suggest you step
> through the code in a debugger to see what's going on. Did you step into
> asQuery already?
>
> Thanks
> Holger
>
>
>
>
> On 3/27/2012 20:58, Martynas Jusevicius wrote:
>>
>> Hey Holger,
>>
>> the setup looks pretty much like this:
>>
>>   # base ontology
>>   @base<http://ontology/base/>  .
>>   <>  a owl:Ontology ; owl:imports<http://ontology/imported>  .
>>   <http://localhost/resource>
>>  x:query<http://ontology/imported/SPINResource>  .
>>
>>   # imported ontology
>>   @base<http://ontology/imported/>  .
>>   <>  a owl:Ontology .
>>   <SPINResource>  a sp:Construct ;
>>     sp:templates ( ... # full query goes here, converted with
>> http://spinservices.org/spinrdfconverter.html
>>
>> The SPIN query is referenced in the base ontology, but is actually
>> described in the imported one.
>>
>> Then I load the base ontology into OntModel using OntDocumentManager
>> (import processing set to true), and do this:
>>
>>   SPINFactory.asQuery(
>>
>> getOntModel().getResource("http://localhost/resource";).getPropertyResourceValue(X.query)
>>   );
>>
>> I can see that OntResourceImpl of
>> <http://ontology/imported/SPINResource>  is passed here, but asQuery()
>> returns null.
>> Afterwards my own code is throwing an NPE because of that -- SPIN is
>> not throwing any exception, I was incorrect in my previous email.
>> Does this explain something? Wouldn't the solution be for SPINFactory
>> also to accept OntResources? Just guessing.
>>
>> Martynas
>> graphity.org
>>
>> On Tue, Mar 27, 2012 at 1:21 AM, Holger Knublauch<[email protected]>
>>  wrote:
>>>
>>> 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
>>>
>

Reply via email to