On 16/08/2022 15:38, Jared Whiklo wrote:
Hey Andy,

Sorry for the delay in responding.

It appears that we were using the assembly plugin, I've been able to switch to the shade plugin and it seems to have resolved the issue.

Thanks for the update.

    Andy

For anyone else looking to repack Jena:

Specifically it is this transformer that combines various META-INF/services/* files into one file in the shaded jar.

<transformer
implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>


Thanks for the help.

cheers,
jared

On 2022-08-04 3:56 p.m., Andy Seaborne wrote:


On 04/08/2022 20:00, Jared Whiklo wrote:
Alright, that is good to know.

Thank you very much, I was able to make a simple exchange

-   triples.write(output, Lang.NTRIPLES.getName());
+  NTriplesWriter.write(output, triples.getGraph().find());



triples.write(output, Lang.NTRIPLES.getName());

should work ... if Jena has been repackaged correctly (e.g. shading)

Try

 RDFDataMgr.write(output, model, Lang.NTRIPLES);

    Andy

and it works correctly. I'll make note to check anywhere else we are outputting triples.

cheers,
jared

On 2022-08-04 1:07 p.m., Andy Seaborne wrote:


On 03/08/2022 21:13, Jared Whiklo wrote:
Sorry I forgot to also say we are using Jena 4.2.0

NTripleWriter in jena-core is not the usual N-Triples writer. It is old, legacy Yes, it could be fixed but if the problem is what I think it is, there are going to be other problems.

Normally, NTriplesWriter in org.apache.jena.riot.writer is the output code.

And you must have RIOT on the classpath because you use "Lang" so ...

has Jena been repackaged? If so, then the Java ServiceLoader files need to be combined.

https://jena.apache.org/documentation/notes/jena-repack.html


This calls both old and current:
"D.rdf" is the RDF/XML from your first message.

    public static void main(String...args) {
        final var model = ModelFactory.createDefaultModel();
        try (final var is = IO.openFileBuffered("D.rdf") ) {
            RDFDataMgr.read(model, is, Lang.RDFXML);
        } catch (IOException e) {
            e.printStackTrace();
            return;
        }
        // Wrong writer
        new org.apache.jena.rdf.model.impl.NTripleWriter()
            .write(model, System.out, null);
        System.out.println("----");
        // Correct
        new org.apache.jena.riot.writer.NTriplesWriter()
            .write(System.out, model.getGraph(), null,  null, null);
        //model.write(System.out, Lang.NTRIPLES.getName());
    }


    Andy


On 2022-08-03 2:54 p.m., Jared Whiklo wrote:
Hi Andy,

This problem is being encountered in https://github.com/fcrepo-exts/migration-utils

The code we are using is reading in an RDF-XML file and then serializing to N-Triples. So an example input is

<rdf:RDF xmlns:METS="http://www.loc.gov/METS/"; xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
  <rdf:Description rdf:about="info:fedora/example:11">
    <cc:useGuidelines xmlns:cc="http://web.resource.org/cc/"; xml:lang="en">This resource is free of copyright restrictions and is published under the Public Domain Mark 1.0.</cc:useGuidelines>
  </rdf:Description>
</rdf:RDF>

And the output of the above is

<info:fedora/example:11> <http://web.resource.org/cc/useGuidelines> "This resource is free of copyright restrictions and is published under the Public Domain Mark 1.0."@en^^<http://www.w3.org/1999/02/22-rdf-syntax-ns#langString> .

We read in the rdfXml here: https://github.com/fcrepo-exts/migration-utils/blob/3a794b504ca04016e0ee91b0f17e88d152b0bfd5/src/main/java/org/fcrepo/migration/handlers/ocfl/ArchiveGroupHandler.java#L873-L883

And serialize it out here: https://github.com/fcrepo-exts/migration-utils/blob/3a794b504ca04016e0ee91b0f17e88d152b0bfd5/src/main/java/org/fcrepo/migration/handlers/ocfl/ArchiveGroupHandler.java#L947-L961

I realize that is fair from transparent.

From what I can discern I think the problem is here https://github.com/apache/jena/blob/31dc0d328c4858401e5d3fa99702c97eba0383a0/jena-core/src/main/java/org/apache/jena/rdf/model/impl/NTripleWriter.java#L198-L203

It seems like it should print either the "@lang" OR the "^^<datatypeURI>" but not both.

If it would help I could try and make a much smaller proof-of-concept code.

cheers,
jared

On 2022-08-03 2:11 p.m., Andy Seaborne wrote:
Hi Jared,

On 03/08/2022 18:35, Jared Whiklo wrote:
Hi,

We are experiencing an issue where N-Triples produced by Jena cannot be parsed by Jena. The issue seems to be how the Model outputs a literal like

example:123 @cc:useGuidelines "This is some text."@en;

Model.toString isn't supposed to be RDF syntax.

Which version of Jena are you using?
Do you have an an example N-Triples file? Or short code that creates the statement?

    Andy

It stores this triple properly (or seems to in the graph) but when serialized as N-Triples it has both a datatypeUri and a langString and so prints out.

<example:123> <http://web.resource.org/cc/useGuidelines> "This is some text."@en^^<http://www.w3.org/1999/02/22-rdf-syntax-ns#langString> .

My understanding is that you can _either_ have a language or a datatype but not both. We'd like to retain the language as that seems more important that "langString".

I am unable to see how to alter the LiteralImpl to get a plain literal output instead of a typed one?

Any help is appreciated.

cheers,
jared

Reply via email to