Mark,

Thanks you for a complete, minimal, example which made the point perfectly.

The best way I could find for the current Jena release is to suppress warnings by setting the error handler to one that does not out warnings.

     RDFParser.create()
        .errorHandler(ErrorHandlerFactory.errorHandlerNoWarnings)
        .source("test-bad-warn.xml")
        .parse(model.getGraph());

But that's all warnings which is unsatisfactory.

The other way would be to create the underlying ARP parser and set options directly. That is poking around in non-public APIs.

JIRA ticket JENA-1494 [1] is for adding a way to set properties specific to RDF/XML reading.

There is a pull request [2] for next release which would enable RDF/XML specific settings:

    Map<String, Object> properties = new HashMap<>();
    // See class ARPErrorNumbers for the possible ARP properies.
    properties.put("WARN_BAD_NAME", "EM_IGNORE");

    // Put a properties object into the Context.
    Context cxt = new Context();
    cxt.set(SysRIOT.sysRdfReaderProperties, properties);

    Model model = ModelFactory.createDefaultModel();
    // Build and run a parser
    RDFParser.create()
         .source("test-bad-warn.xml")
         .context(cxt)
         .parse(model);

Example file in the PR:
https://github.com/afs/jena/blob/27771c3faf67634dc53287fb0d99ee37ef8befb2/jena-arq/src-examples/arq/examples/riot/ExRIOT_RDFXML_ReaderProperties.java

    Andy

[1] https://issues.apache.org/jira/browse/JENA-1494
[2] https://github.com/apache/jena/pull/366

On 23/02/18 15:47, Mark Anderson wrote:
Please find attached an example.

Unzip and execute "mvn compile exec:java" to see the WARN.

Thanks,
Mark

On Wed, 21 Feb 2018 at 15:59 Andy Seaborne <[email protected] <mailto:[email protected]>> wrote:

    Hi,

    Could you please turn this into complete, minimal example by supplying a
    small amount of data that illustrates the problem.

          Andy

    On 21/02/18 12:19, Mark Anderson wrote:
     > I'm reading a RDF/XML file that results in a large number of
    warnings such
     > as
     >
     > WARN  Feb 21 11:13:05.966 2803 [main] org.apache.jena.riot [line:
    16610,
     > col: 45] {W108} Not an XML Name: &apos;883553724818784620&apos;
     >
     > My understanding was that I could ignore these by reading the
    RDF/XML as
     > follows:
     >
     > Model model = ModelFactory.createDefaultModel();
     > RDFReader reader = model.getReader();
     > reader.setProperty("WARN_BAD_NAME", "EM_IGNORE");
     > reader.read(model, inputStream, base);
     >
     > However, setting the property has no impact. What options to I
    need to set
     > to ignore these warnings?
     >
     > Thanks,
     > Mark
     >

Reply via email to