To parse serialized RDF formats in tests or without the OSGi environment
you can use this:
org.apache.clerezza.rdf.core.serializedform.Parser parser =
org.apache.clerezza.rdf.core.serializedform.Parser.getInstance();
Graph graph = parser.parse(
inputStream, formatString);
formatString can be any of the supported formats, e.g.
"application/rdf+xml" or "text/rdf+nt"
The required dependencies are:
For the Parser class
<dependency>
<groupId>org.apache.clerezza</groupId>
<artifactId>rdf.core</artifactId>
</dependency>
For the parsing providers:
<dependency>
<groupId>org.apache.clerezza</groupId>
<artifactId>rdf.jena.parser</artifactId>
</dependency>
You can also use the jena parser directly by instanciating it:
new org.apache.clerezza.rdf.jena.parser.JenaParserProvider();
To bind a parser in the OSGi environment you can use this:
@org.apache.felix.scr.annotations.Reference
private org.apache.clerezza.rdf.core.serializedform.Parser parser;
Note: Supported formats (by the jena parser) are:
"application/rdf+xml";
"text/turtle";
"application/x-turtle";
"text/rdf+nt";
"text/rdf+n3";
"application/rdf+json";
Hope this helps.
Daniel
On 12 November 2012 19:40, Luigi Selmi <[email protected]> wrote:
> Hello
> I am using Clerezza API to manage FOAF profiles. I need to parse foaf
> RDF/XML files and so I need the parser provided by the Clerezza platform
> but don't know how to bind a parsing provider. I would like to test the
> parser before creating the bundle to upload and activate on Felix. Is that
> possible ?
>
> Thanks
>
> Luigi
>