[Activerdf] RDF Container processing

Benno Blumenthal benno at iri.columbia.edu
Thu Apr 5 14:56:29 IST 2007


Eyal Oren wrote:

> If anybody cares to help, it wouldn't be too hard a patch to support 
> this.
> In the meantime, just access collections as ordinary resources. E.g. 
> for a list, just use rdf:first etc. 
> Mind you, there is a big problem when these collections are blank 
> nodes and you want to access them over SPARQL. It's a long story (and 
> it will happen in any RDF-OO mapping but the short story is: it 
> doesn't work.
>
Well I started to look at implementing Collection aka rdf:List support 
(could be really easy -- all we need is to define an 'each' method and 
then all the methods in the Enumerable module should work), and I 
quickly found I am really interested in that story.

Here is my sample program

> #!/usr/local/bin/ruby
> # debugging on export ACTIVE_RDF_LOG_LEVEL=0
> require 'rubygems'
> # we load activerdf
> require_gem 'activerdf','>= 1.2.2'
>
> # we add an existing SPARQL database as datasource
> adapter = ConnectionPool.add_data_source :type => :redland
>
> adapter.load 'http://iri.columbia.edu/~benno/rdflist.owl','rdfxml'
> #adapter.load '/beluga/data/benno/iri_html/rdflist.owl','rdfxml'
>
> # now we can access all RDF properties of a person as Ruby attributes:
>
> Namespace.register :lst, 'http://iri.columbia.edu/~benno/rdflist.owl#'
> #ObjectManager.construct_classes
>
>
> owner = RDFS::Resource.new 
> 'http://iri.columbia.edu/~benno/rdflist.owl#anOwner'
> # See if we actually found something
> puts owner.type
> # check if the property to a URI object works
> puts owner.lst::hasOther
> # check if the property to a blank node works
> puts owner.lst::hasList


which produces

./rubylist
LST::Sampleowner
RDFS::Resource
<http://iri.columbia.edu/~benno/rdflist.owl#Item1>
nil

i.e. I cannot see the top node of my three item list because 
(presumably) it is a blank node.   List nodes will pretty much always be 
blank codes -- even if the top node gets named, the subsequent nodes 
will probably not be.

So

1) I want to define an each operator for an RDFS::Resource that works 
for rdf:type   rdf:List,  and

2) that each operator is going to need to iterate over blank nodes.

My guess is the naming scheme for blank nodes is part of the problem -- 
could it be fixed in the context of an intrinsic operator like 'each'?

Benno


-- 
Dr. M. Benno Blumenthal          benno at iri.columbia.edu
International Research Institute for climate and society
The Earth Institute at Columbia University
Lamont Campus, Palisades NY 10964-8000   (845) 680-4450






-------------- next part --------------
#!/usr/local/bin/ruby
# debugging on export ACTIVE_RDF_LOG_LEVEL=0 
require 'rubygems'
# we load activerdf
require_gem 'activerdf','>= 1.2.2'

# we add an existing SPARQL database as datasource
adapter = ConnectionPool.add_data_source :type => :redland

adapter.load 'http://iri.columbia.edu/~benno/rdflist.owl','rdfxml'
#adapter.load '/beluga/data/benno/iri_html/rdflist.owl','rdfxml'

# now we can access all RDF properties of a person as Ruby attributes:

Namespace.register :lst, 'http://iri.columbia.edu/~benno/rdflist.owl#'
#ObjectManager.construct_classes


owner = RDFS::Resource.new 'http://iri.columbia.edu/~benno/rdflist.owl#anOwner'
# See if we actually found something
puts owner.type
# check if the property to a URI object works
puts owner.lst::hasOther
# check if the property to a blank node works
puts owner.lst::hasList



More information about the ActiveRDF mailing list