You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Don Gourley <do...@gmail.com> on 2011/08/06 03:13:31 UTC

newbie question about fuseki/tdb rdf namespace prefixes

I have a thesaurus in SKOS format that I want to publish as linked
data. I am using a simple httpd/fuseki/tdb stack to do this without
any custom programming. httpd does the content negotiation, and with
mod_rewrite and mod_proxy passes DESCRIBE queries to the fuseki server
to deliver RDF responses.

fuseki (or TDB?) assigns prefixes like 'j.0' for the namespaces it
doesn't know about (even though declared in the SKOS input to
tdbloader). I would like the namespace prefix for
"http://www.w3.org/2004/02/skos/core#" to be 'skos' as in my original
SKOS file. Is there any way to specify this without writing my own
java code for the SPARQL server?

For example, see: http://lod.nal.usda.gov/nalt/2111.rdf

Let me know if there is any other information about my (very simple)
setup that would inform a solution. I understand that this is purely
an aesthetic human-readability aspect to my RDF, but it could help
sell our early efforts with linked open data in the organization.

thanks, Don

Re: newbie question about fuseki/tdb rdf namespace prefixes

Posted by Don Gourley <do...@gmail.com>.
Andy, I get the same result as you when I use curl. The problem is that I
don't want to expose my fuseki server to the world for any kind of SPARQL
query but am proxying through httpd and httpd will not leave the hash alone,
whether encoded as %23 or literal # or escaped \#. So the Fuseki server ends
up with a parse error or by not recognizing the URI.

So I wonder how to set my prefix - "simply add a model (it does not have to
have any triples) in Turtle or RDF/XML i.e. a format that does have
prefixes." as you suggested?

I am using Fuseki 0.2.0 and TDB 0.8.10. I created the data set like this:

TDB-0.8.10/bin/tdbloader --tdb=Fuseki-0.2.0/naltdb.ttl
data/NALT_PURIs+qfix_SKOS.xml

where the .ttl file is the one quoted below and the .xml file is a file of
the SKOS/XML that I excerpted one Concept from below. I start the fuseki
server like so:

nohup ./fuseki-server --desc=naltdb.ttl /nalt &

When I run a query without the PREFIX (because I can't get that to go
through httpd) the resulting triples define the 'j.0' prefix instead of
using the 'skos' prefix that was in the original source file:

<?xml version="1.0"?>
<rdf:RDF
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:j.0="http://www.w3.org/2004/02/skos/core#"
    xmlns:skos="http://www.w3.org/2004/02/skos/core3" >
  <rdf:Description rdf:about="http://lod.nal.usda.gov/nalt/907">
    <j.0:broader rdf:resource="http://lod.nal.usda.gov/nalt/912"/>
    <j.0:altLabel xml:lang="es">(s)-2-hidroxiacido oxidasa</j.0:altLabel>
    <j.0:altLabel xml:lang="en">hydroxy-acid oxidase B</j.0:altLabel>
    <j.0:altLabel xml:lang="en">hydroxy-acid oxidase A</j.0:altLabel>
    <j.0:altLabel xml:lang="en">glycolate oxidase</j.0:altLabel>

    <j.0:altLabel xml:lang="en">EC 1.1.3.15</j.0:altLabel>
    <j.0:prefLabel xml:lang="es">(s)-2-hidroxiácido oxidasa</j.0:prefLabel>
    <j.0:prefLabel xml:lang="en">(s)-2-hydroxy-acid oxidase</j.0:prefLabel>
    <rdf:type rdf:resource="http://www.w3.org/2004/02/skos/core#Concept"/>
  </rdf:Description>
</rdf:RDF>

thanks, Don

On Tue, Aug 9, 2011 at 4:45 AM, Andy Seaborne <andy.seaborne@epimorphics.com
> wrote:

>
>
> On 09/08/11 03:01, Don Gourley wrote:
>
>> Hi Andy, thanks for the response. I have put off answering because I can't
>> get to http://openjena.org/TDB/ to see if the RDF description of the
>> triple
>> store I used with tdbloader to create the database is where I can define a
>> model as you describe. So my response below is even more un-informed than
>> I
>> would like.
>>
>
> Don't worry - openjena got taken out by the Amazon Web Services problems in
> EU-West at the weekend.  We've just managed to get a machine back, and it's
> EBS back but it needs resetting.
>
>
>  I can add the prefix declaration to the query and that works when I submit
>> directly to the Fuseki server, e.g.:
>>
>> curl 'http://localhost:3030/nalt/**query?query=PREFIX+skos:+<http://localhost:3030/nalt/query?query=PREFIX+skos:+>
>> <
>> http://www.w3.org/2004/02/**skos/core%23<http://www.w3.org/2004/02/skos/core%23>
>> >+DESCRIBE+<
>> http://lod.nal.usda.gov/nalt/**2111 <http://lod.nal.usda.gov/nalt/2111>>'
>>
>> But I can't figure out how to do that in my Apache frontend because
>> mod_rewrite insists on escaping the trailing hash in the prefix IRI.
>>
>
> Should be fine - it should be unencoded inside Fuseki.  (Raw # is a
> fragment id, and fragment ids don't go over HTTP as you have in curl above.)
>
>
>  So I am going to have to look into the model suggestion you made, although
>> I
>> admit I need to learn what that means exactly.
>>
>> My triple store was loaded from a SKOS file that looks like this:
>>
>> <rdf:RDF
>>    xmlns:rdfs="http://www.w3.org/**2000/01/rdf-schema#<http://www.w3.org/2000/01/rdf-schema#>
>> "
>>     xmlns:rdf="http://www.w3.org/**1999/02/22-rdf-syntax-ns#<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
>> "
>>     xmlns:skos="http://www.w3.org/**2004/02/skos/core#<http://www.w3.org/2004/02/skos/core#>
>> ">
>>
>> <skos:Concept rdf:about="http://lod.nal.**usda.gov/nalt/907<http://lod.nal.usda.gov/nalt/907>
>> ">
>> <skos:prefLabel xml:lang="en">(s)-2-hydroxy-**acid
>> oxidase</skos:prefLabel>
>> <skos:altLabel xml:lang="en">EC 1.1.3.15</skos:altLabel>
>> <skos:broader rdf:resource="http://lod.nal.**usda.gov/nalt/912<http://lod.nal.usda.gov/nalt/912>
>> "/>
>> </skos:Concept>
>>
>
> How did you load it?  If loaded as RDF/XML direcly, there should be
> prefixes in the database.
>
>
>  I tried using an RDF description of the triple store that declared the
>> namespace but that didn't help (is this a model?):
>>
>> @prefix tdb:<http://jena.hpl.hp.com/**2008/tdb#<http://jena.hpl.hp.com/2008/tdb#>>
>>  .
>> @prefix rdf:<http://www.w3.org/1999/**02/22-rdf-syntax-ns#<http://www.w3.org/1999/02/22-rdf-syntax-ns#>>
>>  .
>> @prefix rdfs:<http://www.w3.org/2000/**01/rdf-schema#<http://www.w3.org/2000/01/rdf-schema#>>
>>  .
>> @prefix ja:<http://jena.hpl.hp.com/**2005/11/Assembler#<http://jena.hpl.hp.com/2005/11/Assembler#>>
>>  .
>> @prefix tdb:<http://jena.hpl.hp.com/**2008/tdb#<http://jena.hpl.hp.com/2008/tdb#>>
>>  .
>> @prefix skos:<http://www.w3.org/2004/**02/skos/core#<http://www.w3.org/2004/02/skos/core#>>
>>  .
>>
>> [] ja:loadClass "com.hp.hpl.jena.tdb.TDB" .
>> tdb:DatasetTDB  rdfs:subClassOf  ja:RDFDataset .
>> tdb:GraphTDB    rdfs:subClassOf  ja:Model .
>>
>> <#dataset>  rdf:type      tdb:DatasetTDB ;
>>      tdb:location "/usr/local/jena/NALTDB" ;
>>     .
>>
>> Can I modify the .ttl file to declare the namespace prefix to be used by
>> the
>> Fuseki SPARQL server without the prefix being explicitly declared in the
>> query?
>>
>> thanks, Don
>>
>
> Couple of things:
>
> 1/ Which version of the code is this?
>
> 2/ Could you send what the server does output?
>
>
> I did the following:
>
> # D.rdf has your data above.
> tdbloader --loc DB D.rdf
> fuseki-server --loc DB /ds
>
> then did:
>
>  curl 'http://localhost:3030/ds/**query?query=PREFIX+skos:+<http://localhost:3030/ds/query?query=PREFIX+skos:+>
> <http**://www.w3.org/2004/02/skos/**core%23<http://www.w3.org/2004/02/skos/core%23>
> >+DESCRIBE+<http://lod.**nal.usda.gov/nalt/907<http://lod.nal.usda.gov/nalt/907>
> >'
>
> (curl changed to /nalt/907)
>
> and got
>
> <?xml version="1.0"?>
> <rdf:RDF
>
>    xmlns:rdf="http://www.w3.org/**1999/02/22-rdf-syntax-ns#<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
> "
>    xmlns:skos="http://www.w3.org/**2004/02/skos/core#<http://www.w3.org/2004/02/skos/core#>"
> >
>  <rdf:Description rdf:about="http://lod.nal.**usda.gov/nalt/907<http://lod.nal.usda.gov/nalt/907>
> ">
>
>    <skos:broader rdf:resource="http://lod.nal.**usda.gov/nalt/912<http://lod.nal.usda.gov/nalt/912>
> "/>
>    <skos:altLabel xml:lang="en">EC 1.1.3.15</skos:altLabel>
>    <skos:prefLabel xml:lang="en">(s)-2-hydroxy-**acid
> oxidase</skos:prefLabel>
>    <rdf:type rdf:resource="http://www.w3.**org/2004/02/skos/core#Concept<http://www.w3.org/2004/02/skos/core#Concept>
> "**/>
>  </rdf:Description>
> </rdf:RDF>
>
> I also did it by deleteing the old DB and uploading the data through the
> Fuseki control panel - same output.
>
> But I did it on the development version.
>
> In case it take a while to get the server back:
>
> svn co https://svn.apache.org/repos/**asf/incubator/jena/Jena2/**
> Fuseki/trunk<https://svn.apache.org/repos/asf/incubator/jena/Jena2/Fuseki/trunk>
> mvn clean package
>
>        Andy
>

Re: newbie question about fuseki/tdb rdf namespace prefixes

Posted by Andy Seaborne <an...@epimorphics.com>.

On 09/08/11 03:01, Don Gourley wrote:
> Hi Andy, thanks for the response. I have put off answering because I can't
> get to http://openjena.org/TDB/ to see if the RDF description of the triple
> store I used with tdbloader to create the database is where I can define a
> model as you describe. So my response below is even more un-informed than I
> would like.

Don't worry - openjena got taken out by the Amazon Web Services problems 
in EU-West at the weekend.  We've just managed to get a machine back, 
and it's EBS back but it needs resetting.

> I can add the prefix declaration to the query and that works when I submit
> directly to the Fuseki server, e.g.:
>
> curl 'http://localhost:3030/nalt/query?query=PREFIX+skos:+<
> http://www.w3.org/2004/02/skos/core%23>+DESCRIBE+<
> http://lod.nal.usda.gov/nalt/2111>'
>
> But I can't figure out how to do that in my Apache frontend because
> mod_rewrite insists on escaping the trailing hash in the prefix IRI.

Should be fine - it should be unencoded inside Fuseki.  (Raw # is a 
fragment id, and fragment ids don't go over HTTP as you have in curl above.)

> So I am going to have to look into the model suggestion you made, although I
> admit I need to learn what that means exactly.
>
> My triple store was loaded from a SKOS file that looks like this:
>
> <rdf:RDF
>     xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
>      xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
>      xmlns:skos="http://www.w3.org/2004/02/skos/core#">
>
> <skos:Concept rdf:about="http://lod.nal.usda.gov/nalt/907">
> <skos:prefLabel xml:lang="en">(s)-2-hydroxy-acid oxidase</skos:prefLabel>
> <skos:altLabel xml:lang="en">EC 1.1.3.15</skos:altLabel>
> <skos:broader rdf:resource="http://lod.nal.usda.gov/nalt/912"/>
> </skos:Concept>

How did you load it?  If loaded as RDF/XML direcly, there should be 
prefixes in the database.

> I tried using an RDF description of the triple store that declared the
> namespace but that didn't help (is this a model?):
>
> @prefix tdb:<http://jena.hpl.hp.com/2008/tdb#>  .
> @prefix rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>  .
> @prefix rdfs:<http://www.w3.org/2000/01/rdf-schema#>  .
> @prefix ja:<http://jena.hpl.hp.com/2005/11/Assembler#>  .
> @prefix tdb:<http://jena.hpl.hp.com/2008/tdb#>  .
> @prefix skos:<http://www.w3.org/2004/02/skos/core#>  .
>
> [] ja:loadClass "com.hp.hpl.jena.tdb.TDB" .
> tdb:DatasetTDB  rdfs:subClassOf  ja:RDFDataset .
> tdb:GraphTDB    rdfs:subClassOf  ja:Model .
>
> <#dataset>  rdf:type      tdb:DatasetTDB ;
>       tdb:location "/usr/local/jena/NALTDB" ;
>      .
>
> Can I modify the .ttl file to declare the namespace prefix to be used by the
> Fuseki SPARQL server without the prefix being explicitly declared in the
> query?
>
> thanks, Don

Couple of things:

1/ Which version of the code is this?

2/ Could you send what the server does output?


I did the following:

# D.rdf has your data above.
tdbloader --loc DB D.rdf
fuseki-server --loc DB /ds

then did:

  curl 
'http://localhost:3030/ds/query?query=PREFIX+skos:+<http://www.w3.org/2004/02/skos/core%23>+DESCRIBE+<http://lod.nal.usda.gov/nalt/907>'

(curl changed to /nalt/907)

and got

<?xml version="1.0"?>
<rdf:RDF
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
     xmlns:skos="http://www.w3.org/2004/02/skos/core#" >
   <rdf:Description rdf:about="http://lod.nal.usda.gov/nalt/907">
     <skos:broader rdf:resource="http://lod.nal.usda.gov/nalt/912"/>
     <skos:altLabel xml:lang="en">EC 1.1.3.15</skos:altLabel>
     <skos:prefLabel xml:lang="en">(s)-2-hydroxy-acid 
oxidase</skos:prefLabel>
     <rdf:type rdf:resource="http://www.w3.org/2004/02/skos/core#Concept"/>
   </rdf:Description>
</rdf:RDF>

I also did it by deleteing the old DB and uploading the data through the 
Fuseki control panel - same output.

But I did it on the development version.

In case it take a while to get the server back:

svn co https://svn.apache.org/repos/asf/incubator/jena/Jena2/Fuseki/trunk
mvn clean package

	Andy

Re: newbie question about fuseki/tdb rdf namespace prefixes

Posted by Don Gourley <do...@gmail.com>.
Hi Andy, thanks for the response. I have put off answering because I can't
get to http://openjena.org/TDB/ to see if the RDF description of the triple
store I used with tdbloader to create the database is where I can define a
model as you describe. So my response below is even more un-informed than I
would like.

I can add the prefix declaration to the query and that works when I submit
directly to the Fuseki server, e.g.:

curl 'http://localhost:3030/nalt/query?query=PREFIX+skos:+<
http://www.w3.org/2004/02/skos/core%23>+DESCRIBE+<
http://lod.nal.usda.gov/nalt/2111>'

But I can't figure out how to do that in my Apache frontend because
mod_rewrite insists on escaping the trailing hash in the prefix IRI.

So I am going to have to look into the model suggestion you made, although I
admit I need to learn what that means exactly.

My triple store was loaded from a SKOS file that looks like this:

<rdf:RDF
   xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:skos="http://www.w3.org/2004/02/skos/core#">

<skos:Concept rdf:about="http://lod.nal.usda.gov/nalt/907">
<skos:prefLabel xml:lang="en">(s)-2-hydroxy-acid oxidase</skos:prefLabel>
<skos:altLabel xml:lang="en">EC 1.1.3.15</skos:altLabel>
<skos:broader rdf:resource="http://lod.nal.usda.gov/nalt/912"/>
</skos:Concept>

I tried using an RDF description of the triple store that declared the
namespace but that didn't help (is this a model?):

@prefix tdb:     <http://jena.hpl.hp.com/2008/tdb#> .
@prefix rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs:    <http://www.w3.org/2000/01/rdf-schema#> .
@prefix ja:      <http://jena.hpl.hp.com/2005/11/Assembler#> .
@prefix tdb:     <http://jena.hpl.hp.com/2008/tdb#> .
@prefix skos:    <http://www.w3.org/2004/02/skos/core#> .

[] ja:loadClass "com.hp.hpl.jena.tdb.TDB" .
tdb:DatasetTDB  rdfs:subClassOf  ja:RDFDataset .
tdb:GraphTDB    rdfs:subClassOf  ja:Model .

<#dataset> rdf:type      tdb:DatasetTDB ;
     tdb:location "/usr/local/jena/NALTDB" ;
    .

Can I modify the .ttl file to declare the namespace prefix to be used by the
Fuseki SPARQL server without the prefix being explicitly declared in the
query?

thanks, Don


On Sat, Aug 6, 2011 at 3:56 PM, Andy Seaborne <an...@epimorphics.com>
wrote:
>
>
> On 06/08/11 02:13, Don Gourley wrote:
>>
>> I have a thesaurus in SKOS format that I want to publish as linked
>> data. I am using a simple httpd/fuseki/tdb stack to do this without
>> any custom programming. httpd does the content negotiation, and with
>> mod_rewrite and mod_proxy passes DESCRIBE queries to the fuseki server
>> to deliver RDF responses.
>>
>> fuseki (or TDB?) assigns prefixes like 'j.0' for the namespaces it
>> doesn't know about (even though declared in the SKOS input to
>> tdbloader). I would like the namespace prefix for
>> "http://www.w3.org/2004/02/skos/core#" to be 'skos' as in my original
>> SKOS file. Is there any way to specify this without writing my own
>> java code for the SPARQL server?
>>
>> For example, see: http://lod.nal.usda.gov/nalt/2111.rdf
>>
>> Let me know if there is any other information about my (very simple)
>> setup that would inform a solution. I understand that this is purely
>> an aesthetic human-readability aspect to my RDF, but it could help
>> sell our early efforts with linked open data in the organization.
>>
>> thanks, Don
>
> Don,
>
> The prefixes come from two places:
>
> * The dataset being queried
> * The query
>
> If loaded from n-triples, there will not be any triples in the dataset.
>
> You an add them later - simply add a model (it does not have to have any
> triples) in Turtle or RDF/XML i.e. a format that does have prefixes.
>
> If that does not work (there was a bug loading in Turtle prefixes IIRC),
> then please coudl you provide a complete, minimal example.
>
> The query should also contribute prefixes, whether used in the pattern or
> not.
>
>        Andy
>

Re: newbie question about fuseki/tdb rdf namespace prefixes

Posted by Andy Seaborne <an...@epimorphics.com>.

On 06/08/11 02:13, Don Gourley wrote:
> I have a thesaurus in SKOS format that I want to publish as linked
> data. I am using a simple httpd/fuseki/tdb stack to do this without
> any custom programming. httpd does the content negotiation, and with
> mod_rewrite and mod_proxy passes DESCRIBE queries to the fuseki server
> to deliver RDF responses.
>
> fuseki (or TDB?) assigns prefixes like 'j.0' for the namespaces it
> doesn't know about (even though declared in the SKOS input to
> tdbloader). I would like the namespace prefix for
> "http://www.w3.org/2004/02/skos/core#" to be 'skos' as in my original
> SKOS file. Is there any way to specify this without writing my own
> java code for the SPARQL server?
>
> For example, see: http://lod.nal.usda.gov/nalt/2111.rdf
>
> Let me know if there is any other information about my (very simple)
> setup that would inform a solution. I understand that this is purely
> an aesthetic human-readability aspect to my RDF, but it could help
> sell our early efforts with linked open data in the organization.
>
> thanks, Don

Don,

The prefixes come from two places:

* The dataset being queried
* The query

If loaded from n-triples, there will not be any triples in the dataset.

You an add them later - simply add a model (it does not have to have any 
triples) in Turtle or RDF/XML i.e. a format that does have prefixes.

If that does not work (there was a bug loading in Turtle prefixes IIRC), 
then please coudl you provide a complete, minimal example.

The query should also contribute prefixes, whether used in the pattern 
or not.

	Andy