简体   繁体   中英

Add triple statement (SimpleStatement) using rdf4j library

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?

在此处输入图像描述

I already found:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM