The Redland library and the RDF::Redland bindings for Perl are very well documented when it comes to creating a persistent store and a model and parsing an RDF/XML file into it, for instance here and here.
On the other hand, I cannot find any example about how to retrieve the model from my persistent store, and the obvious way does not work.
This is how I created the store:
my $storage =
new RDF::Redland::Storage( "hashes", "test",
"new='yes',hash-type='bdb',dir='data'" )
or die "Failed to create RDF::Redland::Storage\n";
my $model = new RDF::Redland::Model( $storage, "" )
or die "Failed to create RDF::Redland::Model for storage\n";
my $uri = new RDF::Redland::URI("file:test.rdf");
my $parser = new RDF::Redland::Parser( "rdfxml", "application/rdf+xml" )
or die "Failed to find parser\n";
my $stream = $parser->parse_as_stream( $uri, $uri );
my $count = 0;
while ( !$stream->end ) {
$model->add_statement( $stream->current );
$count++;
$stream->next;
}
$stream = undef;
$storage = undef;
$model = undef;
print "Done. There were $count statements.\n";
This works and informs me that I have 300k-something statements.
Then I try to retrieve this data with another script:
my $storage =
new RDF::Redland::Storage( "hashes", "test",
"hash-type='bdb',dir='data'" )
or die "Failed to create RDF::Redland::Storage\n";
my $model = new RDF::Redland::Model( $storage, "" )
or die "Failed to create RDF::Redland::Model for storage\n";
$model->sync; # tried with and without this line
my $stream = $model->as_stream;
while ( !$stream->end ) {
print "Statement: ", $stream->current->as_string, "\n";
$stream->next;
}
This prints absolutely nothing.
Thanks for any help!