[Activerdf] Re: sparql example on wiki page

Eyal Oren eyal.oren at deri.org
Mon Oct 30 19:06:57 GMT 2006


On 10/29/06/10/06 23:12 -0800, Disha Al Baqui wrote:
>Hi Eyal,
Hi!
[responding to the list, since it might be interesting for others too]

>I'm trying to make rdflite and activerdf work together. I was wondering if you
Just clarifying: you speak about the rdflite adapter, but your code uses 
the SPARQL adapter.
>could help me figure out this error. I'm using the test code that's in http://
>sw.deri.org/wiki/ActiveRDF/faq and I keep getting this error. I tried to change
>the adapter and still get the error.

>Uninitialized constant FOAF (NameError)
>
>This is the source code:
>
>require 'active_rdf'
>require 'adapter/sparql'
>
># we add an existing SPARQL database as datasource
>ConnectionPool.add_data_source :type => :sparql, :host => 'm3pe.org', :context
>=> 'test-people'
>
># now we can access all RDF properties of a person as Ruby attributes:
>eyal = RDFS::Resource.new 'http://eyaloren.org/#me'
>eyal.firstName = 'eyal'
>eyal.lastName = 'oren'
>
># we register a short-hand notation for foaf data
>Namespace.register(:foaf, 'http://xmlns.com/foaf/0.1/')
>
># now we construct Ruby classes for the currently existing RDFS classes
>ObjectManager.construct_classes
>
># and we can use these classes
>armin = FOAF::Person.new 'http://armin-haller.com/#me'
>armin.firstName = 'armin'
>armin.age = 30
>
>I can't seem to find an answer to this error while googling it either. Can you
>help?
The example on the wiki is wrong, because that SPARQL endpoint does not 
contain any FOAF data. That instance right now contains some mockup 
test-data.  If you just print all resources with 'puts 
RDFS::Resource.find_all', you'll see that there is no FOAF data in there.

What happens then is: construct_classes works, but it doesn't create any 
class in the FOAF namespace since it doesn't know about them.  Then the 
FOAF::Person.new fails, since ActiveRDF doesnt know about FOAF::Person.

The whole example would work fine if the data would contain some foaf 
information. I will upload some mockup foaf data soon (to the context 
'test-foaf') so that the example would work.

 -eyal


More information about the Activerdf mailing list