Dave Beckett's blog

Parsing RDF/XML with Perl RDF::Simple

2003-09-01 21:25

Jo Walsh has written a new Perl module

RDF-Simple-0.03 now available in CPAN. It's goal seems clear by the simple in the title - RDF made easy from Perl. It consists of a pure Perl RDF/XML parser based on Sean B. Palmer's rdfxml.py 10K python one (the python metaphors are very clear) and a serialiser to RDF/XML. The bit in-between is just a perl array of triples, where each triple is a reference to a 3-array of scalars: @triples=([$subject, $predicate, $object]) if you read perl.

The simplicity does have a cost, since there are just scalars, you can't distinguish URIs from Literals or blank node identifiers except by heuristics (does it start with "http" etc.). And you lose language from literals, etc. But simplicity does rock :)

It would be nice to get access to the pure Perl parser on it's own. The 10k python/perl parser is nearly a complete and up-to-date RDF/XML parser - it only misses XML Canonicalization available in both languages as a library and Unicode Normal Form C (NFC) checking. I'm sure that's in Perl 5.8 since it has full Unicode support and I know Python has a library for that.