首页 > 解决方案 > 如何将新的命名个人添加到 XML/RDF owl 文件?

问题描述

我正在使用 apache jena fuseki。我必须从 php 网页获取一些变量并将其发送到 apache jena fuseki sparql 表单。

我想在我的本体中插入新的个体?但我对此一无所知。这是我文件的一部分。我想用 sparql 查询插入另一个这样的人吗?

<rdf:RDF xmlns="http://www.semanticweb.org/ozgur/ontologies/2019/9/untitled-ontology-2#"
 xml:base="http://www.semanticweb.org/ozgur/ontologies/2019/9/untitled-ontology-2"
 xmlns:owl="http://www.w3.org/2002/07/owl#"
 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
 xmlns:uni="http://www.semanticweb.org/ozgur/ontologies/2019/9/untitled-ontology-2#"
 xmlns:xml="http://www.w3.org/XML/1998/namespace"
 xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
 xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
<owl:Ontology rdf:about="http://www.semanticweb.org/ozgur/ontologies/2019/9/untitled-ontology-2"/>

 <owl:NamedIndividual rdf:about="http://www.semanticweb.org/ozgur/ontologies/2019/9/untitled-ontology-2#Student1">
    <rdf:type rdf:resource="http://www.semanticweb.org/ozgur/ontologies/2019/9/untitled-ontology-2#Student"/>
    <studies rdf:resource="http://www.semanticweb.org/ozgur/ontologies/2019/9/untitled-ontology-2#CS101"/>
    <studies rdf:resource="http://www.semanticweb.org/ozgur/ontologies/2019/9/untitled-ontology-2#M201"/>
    <studies rdf:resource="http://www.semanticweb.org/ozgur/ontologies/2019/9/untitled-ontology-2#M204"/>
    <first_name rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Josef</first_name>
    <last_name rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Baker</last_name>
    <studentID rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">266814</studentID>
</owl:NamedIndividual>

标签: phpsparqljenafuseki

解决方案


考虑使用 Turtle 代替 RDF/XML……

这是您当前的数据,转换后-

@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix ns0: <http://www.semanticweb.org/ozgur/ontologies/2019/9/untitled-ontology-2#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

<http://www.semanticweb.org/ozgur/ontologies/2019/9/untitled-ontology-2> 
   a               owl:Ontology .

<http://www.semanticweb.org/ozgur/ontologies/2019/9/untitled-ontology-2#Student1>
   a               owl:NamedIndividual , 
                   <http://www.semanticweb.org/ozgur/ontologies/2019/9/untitled-ontology-2#Student> ;
   ns0:studies     ns0:CS101 , 
                   ns0:M201 , 
                   ns0:M204 ;
   ns0:first_name  "Josef"^^xsd:string ;
   ns0:last_name   "Baker"^^xsd:string ;
   ns0:studentID   266814 .

我敢打赌,你可以看到复制“Josef”“Baker”个人的节是多么容易,并将其编辑为“Josefine”“Chef”……

如果您确实需要使用 SPARQL,您可能正在使用一些工具,确定哪些工具可以让我们更轻松地为您提供帮助。


推荐阅读