Extend StreamRDFWrapper and call super.triple() otherwise the data will not flow down the pipeline. There are prefixes as well and quads if the input is trig etc.

 @Override
 public void triple(Triple triple) {
   ... process triple ... create newTriple ...
   super.triple(newTriple);
}

    Andy


On 03/08/18 12:53, ajs6f wrote:
Since I want triple processing...is extending the StreamRDFBase and overriding 
the method `public void triple(Triple triple)` an option? Is it the best option?

That's a reasonable option, or try StreamRDFWrapper [1] and override where 
appropriate. Keep in mind that triple-level processing can occur well after 
parsing, if that's what makes sense for your application; although you won't 
have the advantages of streaming, you will have random-access to the rest of 
your data.

ajs6f

[1] 
https://jena.apache.org/documentation/javadoc/arq/org/apache/jena/riot/system/StreamRDFWrapper.html

On Aug 3, 2018, at 7:33 AM, [email protected] wrote:



On 2018/08/03 10:10:34, Andy Seaborne <[email protected]> wrote:


On 02/08/18 22:17, [email protected] wrote:
I'm converting a JSON-LD input to RDF using Jena:

Model m = ModelFactory.createDefaultModel;
String str_reader = new StringReader(json.noSpaces)
RDFDataMgr.read(m, str_reader, "", RDFFormat.JSONLD.getLang)
                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Lang.JSONLD

I want to be able to have a custom serializer for String Literals. My end goal 
is to convert a plain String literal to a xsd:date or xsd:dateTime Literal 
whenever a desired format is found.

Look at StreamRDF and RDFDataMgr.parse
(or build your parser for more control with RDFParser.create())

All parsers send their output to a output to a StreamRDF.

RDFDataMgr.read uses a StreamRDF that puts triples/quads into a graph.


StreamRDFs combine so you can build a pipeline

Parser -> convert strings -> store in graph.

Streams as well so works for large data if the syntax streams (JSON-LD
does not).

I know this is handled by jsonld-java which in turn relies on jackson. Is there 
anyone who can give me a hint on how to add this type of custom serialization?

Jackson is the JSON parser.

jsonld-java is the JSON-LD algorithms.

What you seem to want is triple processing and be syntax agnostic.

     Andy

Thanks for your reply. That's informative. I see that I can use 
RDFParser.create() to customize the StreamRDF (using 
RDFParser.create().parse(stream)).

Since I want triple processing...is extending the StreamRDFBase and overriding 
the method `public void triple(Triple triple)` an option? Is it the best option?

Reply via email to