Re: Perl RDF parser

I am searching for a RDF parser to use with Wraf.
        http://uxn.nu/wraf/


Dave Beckett <dave.beckett@bristol.ac.uk> writes:

> Redland (C) reading from a Perl file handle.  Cross-language stuff
> like that is *hard* to do portably.  I'm presently working out how to
> do perl calling C calling perl in order to do callbacks.  And change
> perl to python, tcl, java ...

Ok.  I guess that I will just have to wait for a pure Perl RDF parser
wrapper module.

It should be able to parse diffrent syntaxes or source types.


> I'm considering making Redland run on CPAN but won't grab any top
> level RDF:: modules since there is no agreement on their interface.

For just a parser wrapper, it would be enough to just have a good
interface.  It could be extended to work with several types of
interfaces.  We will never reach agreement on their interface.  The
only way this will be done is by someone going ahead and doing it.


> If you just want the parser interface, tough, Redland is more than
> just a parser.  I could write a perl wrapper for Rapier, maybe I'll
> look at.

I would like Rapier to be a plugin for the general RDF parser wrapper
module.




The Redland perl parser wrapper works ok. But it's not just a parser.
It's not fully integrated with other CPAN modules.  And it comes
bundled with the rest of Redland.  My test program looks like this:


#!/usr/bin/perl -w
use strict;
use lib ( "redland-0.9.9/perl/blib/lib", "redland-0.9.9/perl/blib/arch" );
use RDF;

my $source_uri = new RDF::URI("file:test.rdf");
my $base_uri = $source_uri;

my $parser= new RDF::Parser("repat"); # One of several parsers
my $stream = $parser->parse_as_stream($source_uri, $base_uri)

while( not $stream->end )
{
    my $statement = $stream->next;

    my $pred = $statement->predicate;
    print "Pred   : ", $pred->uri->as_string, "\n";

    my $subj = $statement->subject;
    print "Subj   : ", $subj->uri->as_string, "\n";

    my $obj = $statement->object;
    if( $obj->type eq $RDF::Node::Type_Literal )
    {
	print "Literal: ", $obj->literal_value_as_latin1, "\n";
    }
    else
    {
	print "Obj    : ", $obj->uri->as_string, "\n";
    }

    print "\n";
}
__END__



Would anybody like to do a pure Perl RDF parser wrapper module, in the
style of DBI?

-- 
/ Jonas Liljegren

The Wraf project http://www.uxn.nu/wraf/
Sponsored by http://www.rit.se/

Received on Friday, 20 April 2001 11:35:14 UTC