Add triple statement (SimpleStatement) using rdf4j library

104 Views Asked by At

I try to add a statement to an existing *.ttl file I can add a required text but in some different structure:

                    InputStream in  = new FileInputStream("62692504.ttl");
                    Model model = Rio.parse(in, RDFFormat.TURTLE );
                    Resource publication = iri("https://../fcrepo/rest/ajax-mingoo/"+fileName);
                    IRI namePublication = iri("http://ndl.go.jp/dcndl/publicationPlace");
                    Literal publicationValue = literal(publication_place);
                    model.add(publication, namePublication,  publicationValue);
                    FileOutputStream out = new FileOutputStream("62692504_NEW.ttl");
                    Rio.write(model, out, RDFFormat.TURTLE);

In debug mode, the new line differs from the others, but I want to have the same type. The new line should be SimpleStatement and not from type ContextStatement.

How I can change the type from "default" to SimpleStatement?

enter image description here

1

There are 1 best solutions below

0
On

I already found:

ValueFactory factory = SimpleValueFactory.getInstance();
Statement nameStatement = factory.createStatement(publication, namePublication, publicationValue);
model.add(nameStatement);