[redland] Re: Perl RDF parser
Dave Beckett
dave.beckett at bristol.ac.uk
Fri Apr 20 15:07:10 BST 2001
>>>Jonas Liljegren said:
> I am looking for a RDF parser for Perl.
>
> Redland provides a perl API for some parsers. 'repat' seams to be
> default.
Yes, this week at least. Rapier is coming along nicely but still
some fixes to work on.
http://ilrt.org/discovery/swsw/pt?command=show-parser-detail&uri=http%3A%2F%2Fwww.redland.opensource.ac.uk%2Frapier%2F
> I like the API:
>
> my $uri = new RDF::URI("file:test.rdf");
> my $parser= new RDF::Parser("repat");
> my $stream = $parser->parse_as_stream($uri, $uri)
> while( $stream and not $stream->end )
> {
> my $statement = $stream->next;
> print $statement->as_string, "\n";
> }
>
> I could do without all those classes. But it's ok.
You can collapse them a bit
my $uri = new RDF::URI("file:test.rdf");
my $stream = RDF::Parser->new("repat")->parse_as_stream($uri, $uri)
maybe even further later (raw URI strings automagically=> RDF URI
objects where necessary).
> The above work for a local file. But I get segmentations faults for
> variations.
>
> It segfaults if the file is not found or if its a http URL. (It also
> segfaults if the second $url is undef or if I use 'rapier'.)
>
> What is happening? Could I maby get som error responses?
There is no non file: URI in Redland - I'm sure I mention that
somewhere. I have to integrate with other libraries to get that
e.g. libwww, curl, pico-http inside libxml.
If you want to fetch some URL off the net, use Perl's HTTP modules to
store it in a file and then use something like:
my $store_uri = new RDF::URI("file:/tmp/34567.rdf");
my $base_uri = new RDF::URI("http://example.com/test.rdf");
my $stream=$parser->parse_as_stream($store_uri, $base_uri)
> I'm evaluationg the parsers for use with Wraf. I would like to have
> the parser separated from the RDF::Model and RDF::Storage modules.
It is in Redland. The parse_as_stream method of model returns a
stream of RDF::Statement which you can store in a model, print, throw
away
All the above applies to other Redland language interfaces - Python,
Tcl, C.
There are other perl RDF parsers with varing levels of completion but
I'd wait till they participated in my parser test suite
http://ilrt.org/discovery/swsw/pt
to make some conclusioon on how good they are.
Dave
More information about the redland-dev
mailing list