incubator-clerezza-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Luigi Selmi <luigise...@gmail.com>
Subject Re: parser binding
Date Tue, 13 Nov 2012 15:11:54 GMT
Hello Daniel,
thank you for the response. The solution that uses an instance of a parser
doesn't work I think for the reason that I have written, there is no
instance available outside the OSGi service platform (Fuseki). The code
that I use is

org.apache.clerezza.rdf.core.serializedform.Parser parser =
org.apache.clerezza.rdf.core.serializedform.Parser.getInstance();
InputStream is = subjectUrl.openStream();
Graph subjectGraph = parser.parse(is, SupportedFormat.RDF_XML);

returns an UnsupportedFormatException

For the solution with the Jena parser I need a MGraph implemetation since
the parse method of the Jena parser requires the graph as an attribute.

org.apache.clerezza.rdf.jena.parser.JenaParserProvider parser = new
org.apache.clerezza.rdf.jena.parser.JenaParserProvider();
InputStream is = subjectUrl.openStream();
MGraph subjectGraph = <???>
parser.parse(<???>, is, SupportedFormat.RDF_XML, null);

Can you tell me what kind of implementation of the MGraph can I use to pass
to the parse method of the JenaParserProvider ?

Best

Luigi



2012/11/13 Daniel Spicar <dspicar@apache.org>

> 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 <luigiselmi@gmail.com> 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
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message