English 中文(简体)
如何使用Jana插入/更新卢旺达国防军档案?
原标题:How to insert/update an RDF file using Jena?

我想在我的卢旺达国防军档案中添加一个节点。 我知道,有SPARQL插入/更新了辛塔克斯,但如何利用杰宁这样做。 一个例子将非常有用。

问题回答

你们是否确信需要利用SPARQL最新消息? 在杰宁,斜线(资源或字面)本身在<代码>Model上,但仅作为模型中三重(即Statement)的一部分。 如果您的代码中有<代码>Model的标语,则使用<代码>addStatement的许多变量之一,在图表中添加某种资源或字面。

Addendum

你在评论中澄清,你想在磁盘上添加一个文件后,你可以照《Roger V》的话说话,并修改<条码>Model,然后再次书写。 这确实是这样做的正确方式。 然而,你可能认为,开展快速和ir脏的工作是有益的。 如果您的档案载于Turtle <>/code>或N-Triples格式,你就可以在文档结尾处(显然,你可在XML中查阅)。 因此,内容大致如下:

File f = new File( "where.your.file.is" );
FileOutputStream out = new FileOutputStream( f, true );
out.write( ":john :loves :jane.
" );
out.close();

工作。 它没有真正建议,因为你冒着以下风险:(a) 不存在正确的名称空间,(b) 引入同义词错误(因为你不再使用Jana的作者);(c) 产生三重重复,但有时在紧凑的情况下产生一种有用的trick。 显然,你只能利用这一技术增加信息,而不是更新或删除现有的三倍。

Directly appending to the end of an N-triples file is a valid and useful technique when collecting large volumes of data from ongoing logging or monitoring applications.

审判

   Model m = ModelFactory.createDefaultModel();
        m.read("/Users/heshanjayasinghe/Documents/A-enigmaProject/jena_Enigma/src/jena_enigma/Enigma.RDF", "RDF/XML");
        String NS="http://www.heshjayasinghe.webatu.com/Enigma.RDF#";

        Resource r = m.createResource(NS+"user8");//like subject
        Property p1 =m.createProperty(NS+"lname");
        Property p2 =m.createProperty(NS+"email");
        Property p3 =m.createProperty(NS+"fname");
        Property p4 =m.createProperty(NS+"password");


        r.addProperty(p1, "thathasara", XSDDatatype.XSDstring);
        r.addProperty(p2, "nt@gmail.com", XSDDatatype.XSDstring);
        r.addProperty(p3, "nipun", XSDDatatype.XSDstring);
        r.addProperty(p4, "t123", XSDDatatype.XSDstring);
      //   m.write(System.out,"thurtle");
          m.write(new FileOutputStream("/Users/heshanjayasinghe/Documents/A-enigmaProject/jena_Enigma/src/jena_enigma/Enigma.RDF"), "RDF/XML");

Use ARQs (Jena s SPARQL processor library) UpdateFactory to create an update and then the UpdateExecutionFactory to create an UpdateProcessor which can evaluate the updates.

它的参与略多于此,因为你们也需要一个数据集来评价最新情况。 我真心不明白,从单一模式中建立一个数据集是多么容易,但可以想象这种数据是困难的。





相关问题
Defining cardinality for a RDF statement

Im having a problem with RDF. I have a couple of triples defined as : <User rdf:about="#T"> <hasName rdf:datatype="http://www.w3.org/2001/XMLSchema#string">T</hasName> <...

Duplicate triple in RDF, authoritative view?

if a triple store contains twice the same triple, what is (if any exist) the authoritative position about this redundancy ? Additionally, should a triplestore be allowed to store twice the same ...

Pick and RDF/SPARQL

Anyone have any interest in intergrating RDF and/or SPARQL with a PICK database? Has anyone tried this yet? I have some thoughts about what to try. One idea is to figure out how to create a file with ...

Using contexts in rdflib

I am having trouble finding a clear, sensible example of usage of context with rdflib. ConjunctiveGraph does not accept contexts, and Graph is deprecated. How am I supposed to create and operate on ...

What is the difference between RDF and OWL? [closed]

I am trying to grasp the concept of Semantic Web. I am finding it hard to understand what exactly is the difference between RDF and OWL. Is OWL an extension of RDF or these two are totally different ...

Problem with SPARQLWrapper (Python)

I m making a SPARQL query against the Sesame store in localhost, using SPARQLWrapper: sparql = SPARQLWrapper( http://localhost:8080/openrdf-sesame/repositories/rep/statements ) sparql.setQuery(...