[redland] Re: model vs. triple

Alberto Reggiori areggiori at webweaving.org
Fri Jun 1 13:45:56 BST 2001


Dan Brickley <danbri at w...> wrote:
> 
> 
> Hi all

Hello Dan

> Having a "resource centric" view of one's RDF data turns out to be really
> nice, particularly in more dynamic languages like Perl where there's the
> potential to rid application code of all the RDF-specific words. I have an
> implementation in Perl that tries to push the node-centric idea as far as
> it can go; this API is complementary to (and sits on top of) Mozilla-like
> graph/datasource APIs (Redland etc).

As more I write code using my API as more I see its limitations; in most
cases
I need "atoms" and not statements/models as perl vars. I am currently on
the way to implement a perl-style "node centric" api (see  below)

> Cool! I intend to make a concrete proposal (with running code) to the RDF
> lists. I've no interest in building the One True Implementation of it, but
> having played around a bit I'm happy its a useful technique that
> copmlements existing APIs.

+1 for the proposal (I got running code too)

> IMHO things can't get much simpler than this. There are some issues to
> work out: currently I return strings instead of further Node objects, for
> eg., and I suspect that's wrong. But the general approach I like.

As a perl mother tongue I sketched a perl tie interface over properties,
resources, 
literals and statements. I.e.

tie $a, "RDFStore::Literal";
$a = 'A nice literal'; #utf8 string
tie $b, "RDFStore::Litaral";
$b={ a => 'a nicer literal' }; # a blob

#create an anonymous resource
tie %resource,"RDFStore::Resource";
# add property 'email' with object literal 'foo at bar.com'
$resource{email} = "foo at bar.com"; #no default namespace.
delete $resource{email};

use DC;
$resource{$DC::title} = "The Semantic  Web?";
#create an anonymous resource in a model
tie %resource,"RDFStore::Resource",new RDFStore::Model( Style => DBMS,
Host => foo.com );
my $classification = tie %classification,"RDFStore::Resource",
			"http://etbdemo.jrc.it/thesaurus/eurydice/da/Baskien";
$resource{'http://dublincore.org/2000/03/13-dces#subject'} =
$classification;
print $resource->toStrawmanRDF;

use RDF;
tie @bag, "RDFStore::Resource",$RDF::Bag;
push @bag, new RDFStore::Resource($DC::title); #'sort @bag' would croak
tie @seq, "RDFStore::Resource",$RDF::Seq;
push @seq, at bag;

tie %statement, RDFStore::Statement;
$statement{subject}=$bag[0];
$statement{predicate}=$seq[3];
$statement{object}=$a;

#...and so on :)

> > A suggestion: do not "pollute" the perl RDF:: package namespace
> 
> Good plan. I'm using RDF::RDFWeb for new stuff now; if I can have that
> corner to "pollute" I'll be happy!

I have my small corner too but I would really like to see the CPAN RDF::
namespace
populated at some stage.

Yours

Alberto






More information about the redland-dev mailing list