On 24/07/16 10:35, Martynas Jusevičius wrote:
Let me put it that way: can I successfully parse a Model with invalid URI
values and also get a report saying which values were invalid and why? So
that it could be presented to the user as error messages.

ParserProfile is closer to the parsing process (not for RDF/XML for JSON-LD)

It is ParserProfileChecker that does the URI checking and error reporting.

URI nodes are made by a FactoryRDF in ParserProfileBase. It has the string and the line/column information.

You'll need to look at makeIRI/resolveIRI as well (used in prefix handling).

For RDF/XML see LangRDFXML.HandlerSink

For JSON-LD is is hard to get the line/colun because the parser does all JSON parsing, forms an intermediate form then hands it over to RIOT.

    Andy


On Sat, 23 Jul 2016 at 01:37, Martynas Jusevičius <marty...@graphity.org>
wrote:

Is it possible to let the Model parse silently and afterwards somehow
retrieve org.apache.jena.iri.Violation instances from the
ErrorHandler?

Currently I'm implementing a custom ErrorHandler that would collect
violations instead of logging them. But ErrorHandler only provides
String message, long line, long col and doesn't know which IRI value
caused the violation (which I would like to get).

On Fri, Jul 8, 2016 at 11:28 PM, Andy Seaborne <a...@apache.org> wrote:
On 08/07/16 18:57, A. Soroka wrote:

This may or may not be close to what you are looking for, but you might
try something like oaj.riot.RDFDataMgr::parse with a wrapper around
oaj.riot.system.StreamRDFLib::graph. You can subclass
oaj.riot.system.StreamRDFWrapper for that. Then you have tuple-level
control
over the process and can throw exceptions or execute side-effects as
desired.

---
A. Soroka
The University of Virginia Library

On Jul 8, 2016, at 1:46 PM, Martynas Jusevičius <marty...@graphity.org

wrote:

Hey,

I have implemented an RDF/POST parser which extends ReaderRIOTBase:


https://github.com/AtomGraph/Core/blob/master/src/main/java/org/graphity/core/riot/lang/RDFPostReader.java

It silently accepts broken URIs, so I want the behavior to depend on
ParserProfile, and throw exceptions in case of strict error handler.

I'm reading Model using Model.read(InputStream in, String base, String
lang), so the question is: how do I set the (strict) error handler
before reading it?


Model.read does not expose

See ExRIOT_2 which sets the ErrorHandler.


https://github.com/apache/jena/blob/master/jena-arq/src-examples/arq/examples/riot/ExRIOT_2.java

Create a ReaderRIOT, set the error handler.

See also:
ErrorHandlerFactory.setDefaultErrorHandler

Or, for specifically IRIs, you might want to use ParserProfileBase or a
derivative rather than ParserProfileChecker



Also, what is the difference/connection between ErrorHandler and
RDFErrorHandler?


https://jena.apache.org/documentation/javadoc/arq/org/apache/jena/riot/system/ErrorHandler.html


https://jena.apache.org/documentation/javadoc/jena/org/apache/jena/rdf/model/RDFErrorHandler.html


RDFErrorHandler is used the ARP, for RDF/XML parsing.

It is adapted to ErrorHandler by RIOT.


Thanks,

Martynas
atomgraph.com






Reply via email to