You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Gunnar Aastrand Grimnes <gu...@dfki.de> on 2012/03/06 16:12:57 UTC
SPIN-API and Jena in my own application?
Hi Jena users (and hopefully some TopQuadrant people),
I've been trying to use the open-source parts of SPIN-API in my own
application, i.e. outside of topbraid composer.
The plan is to use the qudspin library for on-the-fly conversion of qudt
units.
Now documentation is a bit sparse, but so far I've done:
Load a model with all of:
* SPIN Documents from http://spinrdf.org/spin,spl,sp
* QUDT defn, i.e. all of qudt-units, qudt-dtype, etc.
* The qudspin library - the version from
http://topbraid.org/spin/qudspin uses the old namespace for qudt, I've
changed this.
add a triple:
Model m = getNamedModel("urn:mygraph");
Resource r = m.createResource("urn:resource");
Property p = m.createProperty("urn:p");
m.add(r, p, m.createTypedLiteral(2, "http://qudt.org/vocab/unit#Meter"));
m=getUnionModel();
SPINModuleRegistry.get().registerAll(m,null);
Then I pose the query:
PREFIX qudspin: <http://topbraid.org/spin/qudspin#>
PREFIX unit: <http://qudt.org/vocab/unit#>
SELECT * WHERE {
<urn:resource> <urn:p> ?v .
BIND ( qudspin:convertLiteral(?v, unit:Furlong ) as ?length )
}
But this doesn't work :( - ?length never gets any value.
There is a chance there is still some namespace issues - I just wanted
to check if there is something SPIN related I've misunderstood?
Anyone here had SPIN working outside TB Composer?
Cheers!
- Gunnar
Re: SPIN-API and Jena in my own application?
Posted by Gunnar Aastrand Grimnes <gu...@dfki.de>.
Thanks Holger, Andy!
When I made a standalone test-case, it suddenly worked.
It turns out the problem was querying the DataSet (with each qudt part,
spin, etc. in different named graphs) - if I change to querying the
UninonModel it works fine.
Thanks!
- Gunnar
On 07/03/12 01:21, Holger Knublauch wrote:
> Hi Gunnar,
>
> [for SPIN API questions it might be best to move them to the TopBraid mailing list, and yes there is some traffic of people using it in their own applications. On that list, ideally prefix your question with [SPIN API] so that we can categorize it more easily].
>
> https://groups.google.com/d/forum/topbraid-users
>
> If your specific query did not work, please make sure that the new functions and magic properties are registered, using
>
> SPINModuleRegistry.get().registerAll(model, null)
>
> You should see a warning somewhere if the function (e.g. qudspin:convertLiteral) isn't found. If I am on the wrong track, please post a "complete" example source code to our list and I can take a look there.
>
> HTH,
> Holger
>
>
> On Mar 7, 2012, at 1:12 AM, Gunnar Aastrand Grimnes wrote:
>
>> Hi Jena users (and hopefully some TopQuadrant people),
>>
>> I've been trying to use the open-source parts of SPIN-API in my own application, i.e. outside of topbraid composer.
>>
>> The plan is to use the qudspin library for on-the-fly conversion of qudt units.
>>
>> Now documentation is a bit sparse, but so far I've done:
>>
>> Load a model with all of:
>> * SPIN Documents from http://spinrdf.org/spin,spl,sp
>> * QUDT defn, i.e. all of qudt-units, qudt-dtype, etc.
>> * The qudspin library - the version from http://topbraid.org/spin/qudspin uses the old namespace for qudt, I've changed this.
>>
>> add a triple:
>>
>> Model m = getNamedModel("urn:mygraph");
>>
>> Resource r = m.createResource("urn:resource");
>> Property p = m.createProperty("urn:p");
>> m.add(r, p, m.createTypedLiteral(2, "http://qudt.org/vocab/unit#Meter"));
>>
>> m=getUnionModel();
>>
>> SPINModuleRegistry.get().registerAll(m,null);
>>
>> Then I pose the query:
>>
>>
>> PREFIX qudspin:<http://topbraid.org/spin/qudspin#>
>> PREFIX unit:<http://qudt.org/vocab/unit#>
>> SELECT * WHERE {
>> <urn:resource> <urn:p> ?v .
>> BIND ( qudspin:convertLiteral(?v, unit:Furlong ) as ?length )
>> }
>>
>>
>> But this doesn't work :( - ?length never gets any value.
>>
>> There is a chance there is still some namespace issues - I just wanted to check if there is something SPIN related I've misunderstood?
>>
>> Anyone here had SPIN working outside TB Composer?
>>
>> Cheers!
>>
>> - Gunnar
>>
>
>
Re: SPIN-API and Jena in my own application?
Posted by Holger Knublauch <ho...@knublauch.com>.
Hi Gunnar,
[for SPIN API questions it might be best to move them to the TopBraid mailing list, and yes there is some traffic of people using it in their own applications. On that list, ideally prefix your question with [SPIN API] so that we can categorize it more easily].
https://groups.google.com/d/forum/topbraid-users
If your specific query did not work, please make sure that the new functions and magic properties are registered, using
SPINModuleRegistry.get().registerAll(model, null)
You should see a warning somewhere if the function (e.g. qudspin:convertLiteral) isn't found. If I am on the wrong track, please post a "complete" example source code to our list and I can take a look there.
HTH,
Holger
On Mar 7, 2012, at 1:12 AM, Gunnar Aastrand Grimnes wrote:
> Hi Jena users (and hopefully some TopQuadrant people),
>
> I've been trying to use the open-source parts of SPIN-API in my own application, i.e. outside of topbraid composer.
>
> The plan is to use the qudspin library for on-the-fly conversion of qudt units.
>
> Now documentation is a bit sparse, but so far I've done:
>
> Load a model with all of:
> * SPIN Documents from http://spinrdf.org/spin,spl,sp
> * QUDT defn, i.e. all of qudt-units, qudt-dtype, etc.
> * The qudspin library - the version from http://topbraid.org/spin/qudspin uses the old namespace for qudt, I've changed this.
>
> add a triple:
>
> Model m = getNamedModel("urn:mygraph");
>
> Resource r = m.createResource("urn:resource");
> Property p = m.createProperty("urn:p");
> m.add(r, p, m.createTypedLiteral(2, "http://qudt.org/vocab/unit#Meter"));
>
> m=getUnionModel();
>
> SPINModuleRegistry.get().registerAll(m,null);
>
> Then I pose the query:
>
>
> PREFIX qudspin: <http://topbraid.org/spin/qudspin#>
> PREFIX unit: <http://qudt.org/vocab/unit#>
> SELECT * WHERE {
> <urn:resource> <urn:p> ?v .
> BIND ( qudspin:convertLiteral(?v, unit:Furlong ) as ?length )
> }
>
>
> But this doesn't work :( - ?length never gets any value.
>
> There is a chance there is still some namespace issues - I just wanted to check if there is something SPIN related I've misunderstood?
>
> Anyone here had SPIN working outside TB Composer?
>
> Cheers!
>
> - Gunnar
>
Re: SPIN-API and Jena in my own application?
Posted by Andy Seaborne <an...@apache.org>.
On 06/03/12 15:12, Gunnar Aastrand Grimnes wrote:
> Hi Jena users (and hopefully some TopQuadrant people),
>
> I've been trying to use the open-source parts of SPIN-API in my own
> application, i.e. outside of topbraid composer.
>
> The plan is to use the qudspin library for on-the-fly conversion of qudt
> units.
>
> Now documentation is a bit sparse, but so far I've done:
>
> Load a model with all of:
> * SPIN Documents from http://spinrdf.org/spin,spl,sp
> * QUDT defn, i.e. all of qudt-units, qudt-dtype, etc.
> * The qudspin library - the version from
> http://topbraid.org/spin/qudspin uses the old namespace for qudt, I've
> changed this.
>
> add a triple:
>
> Model m = getNamedModel("urn:mygraph");
>
> Resource r = m.createResource("urn:resource");
> Property p = m.createProperty("urn:p");
> m.add(r, p, m.createTypedLiteral(2, "http://qudt.org/vocab/unit#Meter"));
>
> m=getUnionModel();
???
>
> SPINModuleRegistry.get().registerAll(m,null);
>
> Then I pose the query:
>
>
> PREFIX qudspin: <http://topbraid.org/spin/qudspin#>
> PREFIX unit: <http://qudt.org/vocab/unit#>
> SELECT * WHERE {
> <urn:resource> <urn:p> ?v .
> BIND ( qudspin:convertLiteral(?v, unit:Furlong ) as ?length )
> }
>
>
> But this doesn't work :( - ?length never gets any value.
Do you get a row with an unbound ?length or no rows?
It looks like qudspin:convertLiteral(?v, unit:Furlong ) is throwing
an exception.
Andy
> There is a chance there is still some namespace issues - I just wanted
> to check if there is something SPIN related I've misunderstood?
>
> Anyone here had SPIN working outside TB Composer?
>
> Cheers!
>
> - Gunnar
>