You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Stian Soiland-Reyes <st...@apache.org> on 2015/09/03 03:11:30 UTC

Fwd: RDF parser interface for Commons RDF

Just in case you were interested in Commons RDF - I made a quick
experiment to use Jena's RIOT parsers to populate Commons RDF graphs.


Note that this is NOT the Commons RDF binding for Jena (JENA-1015) -
that would mean implementing Graph, Triple, etc. backed by Jena.


The parsed graph is stored in any Commons RDF implementation -
currently tested with the in-memory "simple" implementation.

See below:


---------- Forwarded message ----------
From: Stian Soiland-Reyes <st...@apache.org>
Date: 3 September 2015 at 02:07
Subject: RDF parser interface for Commons RDF
To: dev <de...@commonsrdf.incubator.apache.org>


I am not sure if we should be saying anything about RDF parser and
writer interfaces.

Anyhow, I still felt a need to parse generic RDF files with Commons
RDF, and Apache Jena RIOT has a great collection of RDF parsers, so I
wrote a quick binding to see how it can generate and populate
arbitrary Commons RDF Graphs:

https://github.com/stain/commonsrdf-parser-jena


This works with a configurable Graph and RDFTermFactory implementation
together with Jena's StreamRDF - so no intermediate Jena graphs would
be in existence during parsing.


I was playing a bit with what kind of interface parsing would look
like - and ended up with a Factory pattern:

    Parser parser = new JenaParser();
    Path filePath = Paths.get("/tmp/file.rdf");
    Graph g = parser.contentType(Parser.RDFXML).path(examplePath).parse();


This way you don't need to have multiple parse() methods, and can
support many of the optionals easily, e.g. base or content type.  As
even the source is a method, then if path(), url() or inputStream() is
not appropriate for you, you can add a fourth source type by
extension.


A similar interface for writing could be made, but I didn't get too far.


Note that this is not Jena's Commons RDF implementation
https://issues.apache.org/jira/browse/JENA-1015


--
Stian Soiland-Reyes
Apache Taverna (incubating), Apache Commons RDF (incubating)
http://orcid.org/0000-0001-9842-9718


-- 
Stian Soiland-Reyes
Apache Taverna (incubating), Apache Commons RDF (incubating)
http://orcid.org/0000-0001-9842-9718