On 31/08/13 17:45, Darius Miliauskas wrote:
Dear All,

thanks, Andy, for a piece of advice! So, I followed your advices, and
rewrite the code in that way. However, at the end met some problems. In the
case I use "UpdateExecutionFactory", I need GraphStore as a variable which
I do not have because I have only ontology, not a graph.

Ontologies are graphs.

      Anyway, it compiles after some changes, but I can not see any changes
in the file. My code looks the following way:

This works for me: I don't have your data. The output shows that it contains the triple added.

If this does not work for you as you expect, please provide a complete, minimal example, a description of what does happen for you and the reason why it is not as you expect.

        Andy


public class R2 {
    public static void main(String...args) {
        Model model =
            //ModelFactory.createDefaultModel() ;

ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM_MICRO_RULE_INF, null);
        //RDFDataMgr.read(model, "D.ttl") ;
String updateString = "PREFIX base: <http://www.semanticweb.org/darius/ontologies/2013/6/mymodel#>"
            + "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> "
            + "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>"
            + "PREFIX owl: <http://www.w3.org/2002/07/owl#>"
+ "INSERT DATA {<http://www.semanticweb.org/darius/ontologies/2013/6/mymodel#Kristina> a base:Person.} ";

        UpdateRequest query = UpdateFactory.create(updateString);
        UpdateAction.execute(query, model);

// Resource r = model.createResource("http://www.semanticweb.org/darius/ontologies/2013/6/mymodel#Kristina";) ;
//        StmtIterator siter = r.listProperties() ;
//        for ( ; siter.hasNext() ; )
//            System.out.println(siter.next()) ;

        RDFDataMgr.write(System.out, model, Lang.TTL) ;
        model.close(); //OntModel is closed as well.
    }
}

Reply via email to